bastienboutonnet / datafrittata-twitch-chatbot

MIT License
0 stars 1 forks source link

Chatbot crashes with > TypeError: 'NoneType' < since user country is a feature #21

Closed dataCobra closed 3 years ago

dataCobra commented 3 years ago

Hey @bastienboutonnet,

I've merged your latest upstream changes into my main branch. Since then as soon as a I type in twitch chat the chatbot crashes.

Here is the full Traceback about the crash:

Connecting to irc.chat.twitch.tv on port 6667...
Joining #datacobra
Traceback (most recent call last):
  File "/usr/local/stow/python-3.9.4/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/stow/python-3.9.4/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/chatbot/__main__.py", line 29, in <module>
    chatbot.bot.main()
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/chatbot/bot.py", line 161, in main
    bot.start()
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/bot.py", line 354, in start
    super(SingleServerIRCBot, self).start()
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 1202, in start
    self.reactor.process_forever()
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 846, in process_forever
    consume(repeatfunc(one))
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/more_itertools/recipes.py", line 139, in consume
    deque(iterator, maxlen=0)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 827, in process_once
    self.process_data(in_)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 792, in process_data
    conn.process_data()
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 268, in process_data
    self._process_line(line)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 299, in _process_line
    handler(arguments, command, source, tags)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 343, in _handle_message
    self._handle_event(event)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 376, in _handle_event
    self.reactor._handle_event(self, event)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 922, in _handle_event
    result = handler.callback(connection, event)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/venv/lib/python3.9/site-packages/irc/client.py", line 1159, in _dispatcher
    method(connection, event)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/chatbot/bot.py", line 110, in on_pubmsg
    user_country_emoji = self.db_connector.get_user_country(user_id=user_id)
  File "/home/datacobra/Repositories/datafrittata-twitch-chatbot/chatbot/db.py", line 87, in get_user_country
    return row[0]
TypeError: 'NoneType' object is not subscriptable
bastienboutonnet commented 3 years ago

Uh oh! I thought I had encountered this error on stream and fixed it. But I guess not. I'll have a look next time I stream, but feel free to contribute if you want. I indeed need to make this all a bit more robust! Need also more try excepts because all sorts of things might happen.

Thanks for testing it!

bastienboutonnet commented 3 years ago

Resolved in #22