mirror of
https://gitlab.com/vylion/velascobot.git
synced 2025-04-19 21:46:35 +02:00
Velasco 3.0
- Added GIF support - Added general Animation support
This commit is contained in:
parent
c6053724c8
commit
8b1fb2bfb8
3 changed files with 19 additions and 4 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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(' ')
|
||||
|
|
18
velasco.py
18
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:"
|
||||
|
|
Loading…
Reference in a new issue