From da66cbac828ef65b2f6de2d6ff248de2310c0f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 18 Apr 2019 12:54:10 +0200 Subject: [PATCH] cosmetics --- delojza.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/delojza.py b/delojza.py index ab004f0..588cd82 100755 --- a/delojza.py +++ b/delojza.py @@ -131,14 +131,14 @@ class DelojzaBot: hashtag = "PRAS" return hashtag - def handle_hashtag(self, bot, update): + def 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: self.last_hashtag = (update.message.from_user, hashtags[0]) # noinspection PyBroadException - def handle(self, urls, message, download, tumblr=False, filename=None): + def handle(self, urls, message, download_fn, filename=None): try: hashtag = self.get_first_hashtag(message) if hashtag is None: @@ -154,13 +154,14 @@ class DelojzaBot: reply += '...' extract = False - if hashtag in ('AUDIO', 'RADIO') and download != self.download_raw: + if hashtag in ('AUDIO', 'RADIO') and download_fn != self.download_raw: extract = True reply += ' (And also guessing you want to extract the audio)' + message.reply_text(reply) - filenames = download(urls, - hashtag or '.', message.date, - extract=extract, filename=filename) + + filenames = download_fn(urls, hashtag or '.', message.date, + extract=extract, filename=filename) if hashtag == 'TUMBLR': message.reply_text('(btw, queueing to tumblr)') for filename in filenames: @@ -171,11 +172,10 @@ class DelojzaBot: if "Timed out" not in str(exc_value): message.reply_text("Something is FUCKED: %s" % exc_value) - def handle_url(self, bot, update): - ytdl_urls = list(filter(self.ytdl_can, - map(lambda e: update.message.parse_entity(e), - filter(lambda e: e.type == 'url', - update.message.entities)))) + def handle_url(self, _, update): + urls = map(lambda e: update.message.parse_entity(e), + filter(lambda e: e.type == 'url', update.message.entities)) + ytdl_urls = list(filter(self.ytdl_can, urls)) if len(ytdl_urls) > 0: self.handle(ytdl_urls, update.message, self.download_ytdl) @@ -185,7 +185,6 @@ class DelojzaBot: if len(update.message.photo) > 0: photo = max(update.message.photo, key=lambda p: p.width) file = photo.file_id - tumblr = True elif update.message.document is not None: filename = update.message.document.file_name file = update.message.document.file_id @@ -201,12 +200,12 @@ class DelojzaBot: if file is not None: url = bot.getFile(file).file_path - self.handle([url], update.message, self.download_raw, tumblr=tumblr, filename=filename) + self.handle([url], update.message, self.download_raw, filename=filename) - def handle_text(self, bot, update): + def handle_text(self, _, update): self.markov.add_to_corpus(update.message.text) - def tg_start(self, bot, update): + def tg_start(self, _, update): update.message.reply_text(self.markov.make_sentence()) def tg_error(self, bot, update, error):