zachkont / dotaUpdatesBot

A telegram bot for dota2 updates
GNU General Public License v3.0
23 stars 23 forks source link

Fix commands not working #25

Closed TimJentzsch closed 7 years ago

TimJentzsch commented 7 years ago

When typing /start, the bot spams the welcoming message 16 times, the other commands don't work at all for me anymore.

Edit: Now /start doesn't do anything anymore, too.

Screenshot:

Commands Bug

zachkont commented 7 years ago

Hmm that's a weird one... I couldn't even login to the server, had to manually reboot it... It should be working fine now but I'll leave this open and please let me know if it happens again

TimJentzsch commented 7 years ago

Still bugged, this time it happened with /dotanews. It seems like the bot gets in a loop when you write an other command before it processed the first one and then crashes. Notice how it first properly processed the commands I wrote when it was down. Then I wrote 2 commands right after each other, because I thought it already crashed again (turns out the response time is just way slower than before) and it got in a loop again, posting the dotanews 22 times. Now it doesn't responde anymore again, probably crashed. In the second screenshot you can see that it was the same in my earlier post.

This problem probably didn't accure earlier, because the response time was faster, so that it was impossible to write 2 commands before he processed the first one. The 10 second refresh rate seems to have slowed it down though.

Screenshot 1:

Commands Bug

Screenshot 2:

Commands Bug

zachkont commented 7 years ago

Github auto-closed this because I used the resolve keyword in my commit... sorry I attempted a fix, let me know if it happens again For future reference, apparently using the bot.polling() command inside a loop opens new threads indefinitely despite the if __main__ check

zachkont commented 7 years ago

However, that reopens issue #5

TimJentzsch commented 7 years ago

The looping is fixed, but /dotablog doesn't work. That was probably the origin of the looping issue, it didn't occur when typing 2 commands after each other, it apparently occurred after typing /dotablog and then another command.

After typing that, the bot doesn't respond to any more commands. However, after writing /start, it works again after about 1 minute delay. When typing /dotablog it stops working again and so on and so on.

zachkont commented 7 years ago

Yep, you are right, the /dotablog command raises this error:

Traceback (most recent call last):
  File "./main.py", line 191, in <module>
    bot.polling(none_stop=True, interval=0)
  File "/home/user/.local/lib/python2.7/site-packages/telebot/__init__.py", line 174, in polling
    self.__threaded_polling(none_stop, interval, timeout)
  File "/home/user/.local/lib/python2.7/site-packages/telebot/__init__.py", line 198, in __threaded_polling
    self.worker_pool.raise_exceptions()
  File "/home/user/.local/lib/python2.7/site-packages/telebot/util.py", line 102, in raise_exceptions
    six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
  File "/home/user/.local/lib/python2.7/site-packages/telebot/util.py", line 53, in run
    task(*args, **kwargs)
  File "./main.py", line 70, in dota_blog
    content=content)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 12: ordinal not in range(128)
Exception in thread WorkerThread2 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
  File "/home/user/.local/lib/python2.7/site-packages/telebot/util.py", line 56, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Empty'
Exception in thread WorkerThread1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
  File "/home/user/.local/lib/python2.7/site-packages/telebot/util.py", line 56, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Empty'
TimJentzsch commented 7 years ago

First, I'd recommend to change from ASCII- to Unicode-Encoding, one part of the bug is that some characters are not available in ASCII.

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 12: ordinal not in range(128)
zachkont commented 7 years ago

Turns out the problem was with the text strings, which need a u appended in order to be treated as unicode strings. Everything should work fine now