diff --git a/chatlog.py b/chatlog.py index 62142b0..2947a2a 100644 --- a/chatlog.py +++ b/chatlog.py @@ -59,6 +59,10 @@ class Chatlog(object): self.gen.add_text(STICKER_TAG + ' ' + file_id + ' ' + TAIL) self.count += 1 + def add_animation(self, file_id): + self.gen.add_text(ANIM_TAG + ' ' + file_id + ' ' + TAIL) + self.count += 1 + def speak(self): return self.gen.generate_markov_text() diff --git a/markov.py b/markov.py index 8f99e7d..522a183 100644 --- a/markov.py +++ b/markov.py @@ -6,6 +6,7 @@ import json HEAD = "\n^MESSAGE_SEPARATOR^" TAIL = "^MESSAGE_SEPARATOR^" STICKER_TAG = "^IS_STICKER^" +ANIM_TAG = "^IS_ANIMATION^" def trim_and_split(text): words = text.replace('\n', '\n ').split(' ') diff --git a/velasco.py b/velasco.py index cd04e4a..fb6c327 100755 --- a/velasco.py +++ b/velasco.py @@ -122,6 +122,8 @@ def read(bot, update): chatlog.add_msg(update.message.text) elif update.message.sticker is not None: chatlog.add_sticker(update.message.sticker.file_id) + elif update.message.animation is not None: + chatlog.add_animation(update.message.animation.file_id) if chatlog.get_count()%chatlog.freq == 1: chatlog.restart_replyables(update.message.message_id) @@ -189,16 +191,24 @@ def speak(bot, update): chatlogs[chatlog.id] = chatlog def send_message(bot, update, msg, reply_id=None): - words = msg.split() + words = msg.split(maxsplit=1) if words[0] == STICKER_TAG: if reply_id is not None: update.message.reply_sticker(words[1]) else: bot.sendSticker(update.message.chat_id, words[1]) - elif reply_id is not None: - bot.sendMessage(update.message.chat.id, msg, reply_to_message_id=reply_id) + + elif words[0] == ANIM_TAG: + if reply_id is not None: + update.message.reply_animation(words[1]) + else: + bot.sendAnimation(update.message.chat_id, words[1]) + else: - bot.sendMessage(update.message.chat.id, msg) + if reply_id is not None: + bot.sendMessage(update.message.chat.id, msg, reply_to_message_id=reply_id) + else: + bot.sendMessage(update.message.chat.id, msg) def get_chatlogs(bot, update): m = "I have these chatlogs:"