WEEE-Open / weeelab-telegram-bot

Telegram bot for querying the weeelab log and some additional cool stuff.
GNU General Public License v3.0
8 stars 4 forks source link

Unhandled exception when an unknown user sends a message #77

Closed lvps closed 3 years ago

lvps commented 3 years ago

Even /start causes this

Connecting to LDAP
Search 1234567890
Disconnecting from LDAP
ERROR!
{'update_id': 9999999999, 'message': {'message_id': 44720, 'from': {'id': 1234567890, 'is_bot': False, 'first_name': 'Mario', 'last_name': 'Rossi', 'language_code': 'it'}, 'chat': {'id': 1234567890,>
Traceback (most recent call last):
  File "weeelab_bot.py", line 420, in __read_user
    self.user = self.users.get(self.__last_user_id, self.__last_user_nickname, self.conn)
  File "/home/bot/weeelab-telegram-bot/LdapWrapper.py", line 83, in get
    user = User.search(tgid, nickname, self.admin_groups, c, self.tree, self.invite_tree)
  File "/home/bot/weeelab-telegram-bot/LdapWrapper.py", line 278, in search
    raise e
  File "/home/bot/weeelab-telegram-bot/LdapWrapper.py", line 275, in search
    attributes, dn = User.__search_by_tgid(conn, invite_tree, tgid, tree)
  File "/home/bot/weeelab-telegram-bot/LdapWrapper.py", line 318, in __search_by_tgid
    raise AccountNotFoundError()
LdapWrapper.AccountNotFoundError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "weeelab_bot.py", line 1413, in main
    authorized = handler.read_user_from_message(last_update)
  File "weeelab_bot.py", line 415, in read_user_from_message
    return self.__read_user(last_update['message']['text'])
  File "weeelab_bot.py", line 433, in __read_user
    self.store_id()
  File "weeelab_bot.py", line 875, in store_id
    if 'last_name' in self.__last_from['from']:
KeyError: 'from'