From 2d85eae50a79e9d8e5397a2888ecc053ab9ca1e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 18 Apr 2019 16:34:56 +0200 Subject: [PATCH] rename tg methods --- delojza.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/delojza.py b/delojza.py index 706eda1..16e59c7 100755 --- a/delojza.py +++ b/delojza.py @@ -48,13 +48,13 @@ class DelojzaBot: dp.add_handler(CommandHandler("start", self.tg_start)) dp.add_error_handler(self.tg_error) - dp.add_handler(MessageHandler(Filters.entity(MessageEntity.URL), self.handle_url)) + dp.add_handler(MessageHandler(Filters.entity(MessageEntity.URL), self.tg_handle_url)) dp.add_handler( MessageHandler( Filters.photo | Filters.video | Filters.video_note | Filters.audio | Filters.voice | Filters.document, - self.handle_rest)) - dp.add_handler(MessageHandler(Filters.entity(MessageEntity.HASHTAG), self.handle_hashtag)) - dp.add_handler(MessageHandler(Filters.text, self.handle_text)) + self.tg_handle_rest)) + dp.add_handler(MessageHandler(Filters.entity(MessageEntity.HASHTAG), self.tg_handle_hashtag)) + dp.add_handler(MessageHandler(Filters.text, self.tg_handle_text)) if tumblr_keys: self.client = pytumblr.TumblrRestClient(*tumblr_keys) @@ -131,7 +131,7 @@ class DelojzaBot: hashtag = "PRAS" return hashtag - def handle_hashtag(self, _, update): + def tg_handle_hashtag(self, _, update): hashtags = list(map(update.message.parse_entity, list(filter(lambda e: e.type == 'hashtag', update.message.entities)))) if len(hashtags) > 0: @@ -171,7 +171,7 @@ class DelojzaBot: if "Timed out" not in str(exc_value): message.reply_text("Something is FUCKED: %s" % exc_value) - def handle_url(self, _, update): + def tg_handle_url(self, _, update): urls = list(map(lambda e: update.message.parse_entity(e), filter(lambda e: e.type == 'url', update.message.entities))) ytdl_urls = [url for url in urls if self.ytdl_can(url)] @@ -184,7 +184,7 @@ class DelojzaBot: self.handle(image_urls, update.message, self.download_raw) # noinspection PyBroadException - def handle_rest(self, bot, update): + def tg_handle_rest(self, bot, update): file, filename, tumblr = None, None, False if len(update.message.photo) > 0: photo = max(update.message.photo, key=lambda p: p.width) @@ -206,7 +206,7 @@ class DelojzaBot: url = bot.getFile(file).file_path self.handle([url], update.message, self.download_raw, filename=filename) - def handle_text(self, _, update): + def tg_handle_text(self, _, update): if self.markov: self.markov.add_to_corpus(update.message.text) @@ -219,7 +219,7 @@ class DelojzaBot: if update is not None: default = "Mmmm, I like it..." update.message.reply_text((self.markov.make_sentence(tries=100) if self.markov else default) or default) - self.handle_rest(bot, update) + self.tg_handle_rest(bot, update) else: if update is not None: update.message.reply_text("Something is fucked: %s" % error)