diff --git a/bot/bot.py b/bot/bot.py index 9bd184e..d6b6f22 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -4,6 +4,7 @@ import config import logging import requests import re +from emoji import demojize from telegram.ext import Updater, MessageHandler, Filters logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - \ @@ -19,10 +20,10 @@ def get_text_or_type(msg, bot, truncate=False): x = re.compile('(<.*?>)(.*)') y = x.search(msg.text) z = y.group(2) - message += (z if len(z) <= 10 or not truncate else z[0:9] + "...") + message += (z if len(z) <= 20 or not truncate else z[0:19] + "...") else: - message += (msg.text if len(msg.text) <= 10 or not truncate else - msg.text[0:9] + "...") + message += (msg.text if len(msg.text) <= 20 or not truncate else + msg.text[0:19] + "...") elif msg.audio: message += "[Audio]" elif msg.document: @@ -52,8 +53,8 @@ def get_text_or_type(msg, bot, truncate=False): # If caption exists if msg.caption: - message += (msg.caption if len(msg.caption) <= 10 or not truncate else - msg.caption[0:9] + "...") + message += (msg.caption if len(msg.caption) <= 20 or not truncate else + msg.caption[0:19] + "...") # Set sender return_message = "" @@ -69,7 +70,7 @@ def get_text_or_type(msg, bot, truncate=False): return_message = y.group(1) + ": " + i + "\n" # Set the replied to message's contents if msg.reply_to_message: - return_message += ("[Reply to " + + return_message += ("[> " + get_text_or_type(msg.reply_to_message, bot, True).split("\n")[0] + f"] ") @@ -81,7 +82,7 @@ def get_text_or_type(msg, bot, truncate=False): def message_handling(bot, update): if update.message.chat.id in config.groups: message = get_text_or_type(update.message, bot) - params = {"message": message} + params = {"message": demojize(message)} requests.post("http://localhost:" + str(config.port) + "/post", data=params)