rename tg methods

This commit is contained in:
Tomáš Mládek 2019-04-18 16:34:56 +02:00 committed by Tomáš Mládek
parent cb63f80fe2
commit 2d85eae50a

View file

@ -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)