From 86ca0f14b6aa05fe3661adee8d54fc062fc1f605 Mon Sep 17 00:00:00 2001 From: Carl Chenet Date: Mon, 30 Dec 2019 22:11:19 +0100 Subject: [PATCH] new conf parameter toot_max_len to truncate toot max length --- feed2toot/confparse.py | 2 ++ feed2toot/confparsers/rss/tootmaxlen.py | 37 +++++++++++++++++++++++++ feed2toot/main.py | 2 +- feed2toot/message.py | 9 ++++-- 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 feed2toot/confparsers/rss/tootmaxlen.py diff --git a/feed2toot/confparse.py b/feed2toot/confparse.py index dcf6ee1..af31575 100644 --- a/feed2toot/confparse.py +++ b/feed2toot/confparse.py @@ -40,6 +40,7 @@ from feed2toot.confparsers.rss.toot import parsetoot from feed2toot.confparsers.rss.uri import parseuri from feed2toot.confparsers.rss.urilist import parseurilist from feed2toot.confparsers.rss.addtags import parseaddtags +from feed2toot.confparsers.rss.tootmaxlen import parsetootmaxlen class ConfParse: '''ConfParse class''' @@ -67,6 +68,7 @@ class ConfParse: # the rss section ########################### self.tweetformat = parsetoot(config) + options['tootmaxlen'] = parsetootmaxlen(config) ################################################# # pattern and patter_case_sensitive format option ################################################# diff --git a/feed2toot/confparsers/rss/tootmaxlen.py b/feed2toot/confparsers/rss/tootmaxlen.py new file mode 100644 index 0000000..f975469 --- /dev/null +++ b/feed2toot/confparsers/rss/tootmaxlen.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015-2019 Carl Chenet +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see tootmaxlen: + return ''.join([finaltweet[0:-3], '...']) + else: + return finaltweet def send_message_dry_run(config, entrytosend, finaltweet): '''simulate sending message using dry run mode'''