linkchanbot

Telegram bot frontend proxy link substituter
git clone https://git.torresjrjr.com/linkchanbot.git
Log | Files | Refs | README | LICENSE

commit 9b4432dbd6ee7b598f48a82ff3d4ffdae538bdd0
parent 219624f2a86bc9a79fd6be3cc1b78608cde03533
Author: Byron Torres <b@torresjrjr.com>
Date:   Sat, 19 Mar 2022 19:52:26 +0000

Fix no effective_{user,message} bug

Diffstat:
Mlinkchanbot | 20++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/linkchanbot b/linkchanbot @@ -215,8 +215,10 @@ def logged(old_cb_func): status = mk_status(upd, 'cir', '::', oneline(upd.chosen_inline_result.result_id)) elif upd.inline_query: status = mk_status(upd, 'ilq', '?:', oneline(upd.inline_query.query)) - else: + elif upd.effective_message: status = mk_status(upd, 'ukn', '#:', upd.effective_message) + else: + status = mk_status(upd, 'ukn', '#:') logging.info(status) print(status) @@ -233,8 +235,15 @@ def mk_status(upd, utype, dl='::', text=None): or by callbacks for terminal output. """ uid = upd.update_id - user_id = upd.effective_user.id - user_name = upd.effective_user.name + if upd.effective_user: + user_id = upd.effective_user.id + user_name = upd.effective_user.name + elif upd.channel_post: + user_id = upd.channel_post.from_user.id + user_name = upd.channel_post.from_user.name + elif upd.poll: + user_id = '<Poll>' + user_name = '<Poll>' chat = upd.effective_chat if chat: @@ -249,7 +258,10 @@ def mk_status(upd, utype, dl='::', text=None): chat_name = '#' if not text: - text = upd.effective_message + if upd.effective_message: + text = upd.effective_message + else: + text = "?" status = f"{uid} [{utype}] - {user_id} <{user_name}> - {chat_id} ({chat_name}) - {dl} {text}" return status