X Tutup
Skip to content

Exception in 'commandhandler' when catching edited messages #601

@evgfilim1

Description

@evgfilim1

Steps to reproduce

  1. Create a simple bot with CommandHandler and set allow_edited=True
  2. Set up logging so you can see error message

Expected behaviour

Edited command should be handled without exceptions

Actual behaviour

ERROR:telegram.ext.dispatcher:An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/home/evgen/Work/test_bot/telegram/ext/dispatcher.py", line 264, in process_update
    if handler.check_update(update):
  File "/home/evgen/Work/test_bot/telegram/ext/commandhandler.py", line 102, in check_update
    update.message.bot.username)  # in case the command was send without a username
AttributeError: 'NoneType' object has no attribute 'bot'

Configuration

Operating System:

ArchLinux x86_64 linux-4.10.14-ck

Version of Python, python-telegram-bot & dependencies:

$ python -m telegram
python-telegram-bot 5.3.1
urllib3 dev
certifi 2017.04.17
future 0.16.0
Python 3.6.1 (default, Mar 27 2017, 00:27:06)  [GCC 6.3.1 20170306]

(using git version based on this commit)

$ git log --oneline
ed49bdb Merge pull request #592 from python-telegram-bot/snake_case
...
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

Logs

DEBUG:telegram.bot:Entering: get_updates
DEBUG:telegram.bot:Getting updates: [279281268]
DEBUG:telegram.bot:[<telegram.update.Update object at 0x7fc1241a14e0>]
DEBUG:telegram.bot:Exiting: get_updates
DEBUG:telegram.bot:Entering: get_updates
DEBUG:telegram.ext.dispatcher:Processing Update: {'update_id': 279281268, 'message': {'message_id': 108491, 'date': 1494546512, 'chat': {'id': -1001087615537, 'type': 'supergroup', 'title': 'IT-Koт Devs'}, 'text': '//any msg.reply_text("test")', 'entities': [], 'photo': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False, 'from': {'id': 230130383, 'first_name': 'Evgen', 'last_name': '// MEOW!', 'username': 'evgfilim1'}}}
DEBUG:telegram.bot:Entering: send_message
DEBUG:telegram.bot:{'message_id': 108492, 'date': 1494546513, 'chat': {'id': -1001087615537, 'type': 'supergroup', 'title': 'IT-Koт Devs'}, 'reply_to_message': {'message_id': 108491, 'date': 1494546512, 'chat': {'id': -1001087615537, 'type': 'supergroup', 'title': 'IT-Koт Devs'}, 'text': '//any msg.reply_text("test")', 'entities': [], 'photo': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False, 'from': {'id': 230130383, 'first_name': 'Evgen', 'last_name': '// MEOW!', 'username': 'evgfilim1'}}, 'text': 'test', 'entities': [], 'photo': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False, 'from': {'id': 202213802, 'first_name': 'TestBot', 'username': 'test_evgfilim1_bot'}}
DEBUG:telegram.bot:Exiting: send_message
DEBUG:telegram.bot:Getting updates: [279281269]
DEBUG:telegram.bot:[<telegram.update.Update object at 0x7fc1241a1780>]
DEBUG:telegram.bot:Exiting: get_updates
DEBUG:telegram.ext.dispatcher:Processing Update: {'update_id': 279281269, 'edited_message': {'message_id': 108491, 'date': 1494546512, 'chat': {'id': -1001087615537, 'type': 'supergroup', 'title': 'IT-Koт Devs'}, 'edit_date': 1494546517, 'text': '//any msg.reply_text("test_edit")', 'entities': [], 'photo': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False, 'from': {'id': 230130383, 'first_name': 'Evgen', 'last_name': '// MEOW!', 'username': 'evgfilim1'}}}
ERROR:telegram.ext.dispatcher:An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/home/evgen/Work/test_bot/telegram/ext/dispatcher.py", line 264, in process_update
    if handler.check_update(update):
  File "/home/evgen/Work/test_bot/telegram/ext/commandhandler.py", line 102, in check_update
    update.message.bot.username)  # in case the command was send without a username
AttributeError: 'NoneType' object has no attribute 'bot'
DEBUG:telegram.bot:Entering: get_updates
DEBUG:telegram.bot:No new updates found.
DEBUG:telegram.bot:[]
DEBUG:telegram.bot:Exiting: get_updates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup