~torresjrjr/linkchanbot

9b4432dbd6ee7b598f48a82ff3d4ffdae538bdd0 — Byron Torres 1 year, 6 months ago 219624f
Fix no effective_{user,message} bug
1 files changed, 16 insertions(+), 4 deletions(-)

M linkchanbot
M linkchanbot => linkchanbot +16 -4
@@ 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