blabber markov sentences at random files & urls also

This commit is contained in:
Tomáš Mládek 2019-12-17 13:40:18 +01:00
parent 6311672c9e
commit 5011077da6

View file

@ -488,6 +488,10 @@ class DelojzaBot:
file = message.voice.file_id
if file is not None:
if self.markov and random.random() > .66:
sentence = self.markov.make_sentence()
if sentence:
message.reply_text(sentence)
url = bot.getFile(file).file_path
return self.handle([url], message, hashtag, self.download_raw, filetitle=filetitle)
else:
@ -497,6 +501,11 @@ class DelojzaBot:
urls = list(map(lambda e: message.parse_entity(e),
filter(lambda e: e.type == 'url', message.entities)))
if len(urls) > 0 and self.markov and random.random() > .66:
sentence = self.markov.make_sentence()
if sentence:
message.reply_text(sentence)
ytdl_res = False
ytdl_urls = [url for url in urls if self.ytdl_can(url)]
if len(ytdl_urls) > 0: