mirror of
https://gitlab.com/vylion/velascobot.git
synced 2025-04-19 21:46:35 +02:00
Velasco 3.1
- Added a "print" marker for the end of chat loading - Added some code for future possible video compatibility in a panic when normal Animation support didn't work
This commit is contained in:
parent
8b1fb2bfb8
commit
348e451d77
3 changed files with 29 additions and 3 deletions
|
@ -59,6 +59,10 @@ class Chatlog(object):
|
||||||
self.gen.add_text(STICKER_TAG + ' ' + file_id + ' ' + TAIL)
|
self.gen.add_text(STICKER_TAG + ' ' + file_id + ' ' + TAIL)
|
||||||
self.count += 1
|
self.count += 1
|
||||||
|
|
||||||
|
def add_video(self, file_id):
|
||||||
|
self.gen.add_text(VIDEO_TAG + ' ' + file_id + ' ' + TAIL)
|
||||||
|
self.count += 1
|
||||||
|
|
||||||
def add_animation(self, file_id):
|
def add_animation(self, file_id):
|
||||||
self.gen.add_text(ANIM_TAG + ' ' + file_id + ' ' + TAIL)
|
self.gen.add_text(ANIM_TAG + ' ' + file_id + ' ' + TAIL)
|
||||||
self.count += 1
|
self.count += 1
|
||||||
|
|
|
@ -7,6 +7,7 @@ HEAD = "\n^MESSAGE_SEPARATOR^"
|
||||||
TAIL = "^MESSAGE_SEPARATOR^"
|
TAIL = "^MESSAGE_SEPARATOR^"
|
||||||
STICKER_TAG = "^IS_STICKER^"
|
STICKER_TAG = "^IS_STICKER^"
|
||||||
ANIM_TAG = "^IS_ANIMATION^"
|
ANIM_TAG = "^IS_ANIMATION^"
|
||||||
|
VIDEO_TAG = "^IS_VIDEO^"
|
||||||
|
|
||||||
def trim_and_split(text):
|
def trim_and_split(text):
|
||||||
words = text.replace('\n', '\n ').split(' ')
|
words = text.replace('\n', '\n ').split(' ')
|
||||||
|
|
27
velasco.py
27
velasco.py
|
@ -95,7 +95,7 @@ def echo(bot, update):
|
||||||
update.message.reply_text(text)
|
update.message.reply_text(text)
|
||||||
|
|
||||||
def error(bot, update, error):
|
def error(bot, update, error):
|
||||||
logger.warn('Update "%s" caused error "%s"' % (update, error))
|
logger.warning('Update "%s" caused error "%s"' % (update, error))
|
||||||
|
|
||||||
def get_chatname(chat):
|
def get_chatname(chat):
|
||||||
if chat.title is not None:
|
if chat.title is not None:
|
||||||
|
@ -121,10 +121,15 @@ def read(bot, update):
|
||||||
if update.message.text is not None:
|
if update.message.text is not None:
|
||||||
chatlog.add_msg(update.message.text)
|
chatlog.add_msg(update.message.text)
|
||||||
elif update.message.sticker is not None:
|
elif update.message.sticker is not None:
|
||||||
|
#print("I received a sticker")
|
||||||
chatlog.add_sticker(update.message.sticker.file_id)
|
chatlog.add_sticker(update.message.sticker.file_id)
|
||||||
elif update.message.animation is not None:
|
elif update.message.animation is not None:
|
||||||
|
#print("I received an animation")
|
||||||
chatlog.add_animation(update.message.animation.file_id)
|
chatlog.add_animation(update.message.animation.file_id)
|
||||||
|
elif update.message.video is not None:
|
||||||
|
#print("I received a video")
|
||||||
|
chatlog.add_video(update.message.video.file_id)
|
||||||
|
# print("Read a message of id "update.message.message_id)
|
||||||
if chatlog.get_count()%chatlog.freq == 1:
|
if chatlog.get_count()%chatlog.freq == 1:
|
||||||
chatlog.restart_replyables(update.message.message_id)
|
chatlog.restart_replyables(update.message.message_id)
|
||||||
else:
|
else:
|
||||||
|
@ -204,6 +209,18 @@ def send_message(bot, update, msg, reply_id=None):
|
||||||
else:
|
else:
|
||||||
bot.sendAnimation(update.message.chat_id, words[1])
|
bot.sendAnimation(update.message.chat_id, words[1])
|
||||||
|
|
||||||
|
elif words[0] == VIDEO_TAG:
|
||||||
|
if reply_id is not None:
|
||||||
|
try:
|
||||||
|
update.message.reply_animation(words[1])
|
||||||
|
except:
|
||||||
|
update.message.reply_video(words[1])
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
bot.sendAnimation(update.message.chat_id, words[1])
|
||||||
|
except:
|
||||||
|
bot.sendVideo(update.message.chat_id, words[1])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if reply_id is not None:
|
if reply_id is not None:
|
||||||
bot.sendMessage(update.message.chat.id, msg, reply_to_message_id=reply_id)
|
bot.sendMessage(update.message.chat.id, msg, reply_to_message_id=reply_id)
|
||||||
|
@ -356,13 +373,17 @@ def main():
|
||||||
|
|
||||||
# on noncommand i.e message - echo the message on Telegram
|
# on noncommand i.e message - echo the message on Telegram
|
||||||
# dp.add_handler(MessageHandler(Filters.text, echo))
|
# dp.add_handler(MessageHandler(Filters.text, echo))
|
||||||
dp.add_handler(MessageHandler((Filters.text | Filters.sticker), read))
|
dp.add_handler(MessageHandler((Filters.text | Filters.sticker | Filters.animation), read))
|
||||||
|
|
||||||
# log all errors
|
# log all errors
|
||||||
dp.add_error_handler(error)
|
dp.add_error_handler(error)
|
||||||
|
|
||||||
wake(updater.bot)
|
wake(updater.bot)
|
||||||
|
|
||||||
|
print("-----")
|
||||||
|
print("Finished loading.")
|
||||||
|
print("-----")
|
||||||
|
|
||||||
# Start the Bot
|
# Start the Bot
|
||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue