From a37d442cda4b1246ea775068054fc131db61869f Mon Sep 17 00:00:00 2001 From: none Date: Wed, 28 Feb 2024 00:46:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B8=20=D0=B3=D0=BE?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D0=BE=D0=B2=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- anon.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/anon.py b/anon.py index b04fe6a..79b21dd 100644 --- a/anon.py +++ b/anon.py @@ -313,7 +313,7 @@ def me(message): -@bot.message_handler(func=lambda message: True, content_types=['photo','text']) +@bot.message_handler(func=lambda message: True, content_types=['photo','text', 'document', 'voice']) def catch_all_messages(message): try: db = read_db() @@ -350,8 +350,18 @@ def catch_all_messages(message): else: caption = "" - bot.send_photo(db[channel]["id"], img_id, f"{telebot.formatting.hcode(':'+nick)} + avatar" + caption, parse_mode="HTML") + bot.send_photo(db[channel]["id"], img_id, f"{telebot.formatting.hcode(':'+nick) + avatar}" + caption, parse_mode="HTML") + elif "document" in message.json: + doc_id = message.json['document']['file_id'] + if "caption" in message.json: + caption = "\n" + message.json['caption'] + else: + caption = "" + bot.send_document(db[channel]["id"], doc_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}" + caption, parse_mode="HTML") + elif "voice" in message.json: + voice_id = message.json['voice']['file_id'] + bot.send_document(db[channel]["id"], voice_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}", parse_mode="HTML") else: bot.send_message(db[channel]["id"], f"{telebot.formatting.hcode(':'+nick) + avatar}\n" + message.text, parse_mode="HTML") @@ -365,7 +375,7 @@ def catch_all_messages(message): catch_error(message) #### POLLING #### -mode = 1 +mode = 0 # Normal - 0, debug - 1 if mode == 0: