PGO-mapscan-opt icon indicating copy to clipboard operation
PGO-mapscan-opt copied to clipboard

[crash]telegrambot

Open dikkedeur opened this issue 8 years ago • 14 comments

dont know how to reproduce, it crashes constantly now,

Traceback (most recent call last): File "telebot.py", line 459, in main() File "telebot.py", line 353, in main f.write(u'{}\n'.format(log_queue.get(1))) UnicodeEncodeError: 'ascii' codec can't encode character u'\u274c' in position 48: ordinal not in range(128)

dikkedeur avatar Sep 30 '16 08:09 dikkedeur

What does it say before that crash? Maybe it helps to just delete your log file.

seikur0 avatar Sep 30 '16 08:09 seikur0

[10:31:12] [N] Notified user Job (237699614) of Squirtle 1245.0m away! [10:31:53] [N] Notified user Job (237699614) of Charmander 1639.0m away! [10:33:03] [N] Notified user Job (237699614) of Pikachu 3468.0m away! [10:33:34] [N] Notified user Job (237699614) of Wartortle 2269.0m away! ^X^CTraceback (most recent call last): File "telebot.py", line 459, in main() File "telebot.py", line 354, in main time.sleep(time_between_cycles)

dikkedeur avatar Sep 30 '16 08:09 dikkedeur

Okay, and what's in your log file before the crash? That combo though, Squirtle, Charmander,Pikachu,Wartortle? xD

seikur0 avatar Sep 30 '16 08:09 seikur0

I also had a problem with Telegram, had to change the following line from

telebot.sendMessage(chat_id=telegram, text=u'<b>{}</b><br>{}'.format(notification_text,time_text), parse_mode='HTML', disable_web_page_preview=False, disable_notification=False)

to

telebot.sendMessage(chat_id=telegram, text=u'<b>{}</b>\n{}'.format(notification_text,time_text), parse_mode='HTML', disable_web_page_preview=False, disable_notification=False)

Zyrix avatar Sep 30 '16 09:09 Zyrix

@Zyrix That's not really in the main0.py anymore.

seikur0 avatar Sep 30 '16 09:09 seikur0

@dikkedeur i bypassed the problem setting log_to_file to false in telebotsettings

aldder avatar Sep 30 '16 10:09 aldder

@seikur0 [11:05:19] [N] Notified user Job (237699614) of Scyther 2886.0m away! [11:05:27] [l] Location received: Steve (243072456): [52.953103,4.762625] [11:05:34] [t] Text received: Steve (243072456): "500m" [11:06:00] [N] Notified user Job (237699614) of Bulbasaur 1603.0m away! [11:08:10] [N] Notified user Job (237699614) of Charmander 1250.0m away! [11:09:11] [N] Notified user Job (237699614) of Pikachu 2330.0m away! [11:11:12] [N] Notified user Job (237699614) of Pikachu 429.0m away!

@aldder will try that out.

dikkedeur avatar Sep 30 '16 11:09 dikkedeur

The one for a time of around [10:33:34]. And try deleting it rather than just disabling it first.

seikur0 avatar Sep 30 '16 11:09 seikur0

it seems that everytime you update you location this crash can happen.. i have log off now, see what happens when i spam it

dikkedeur avatar Sep 30 '16 11:09 dikkedeur

[10:25:58] [t] Text received: Steve (243072456): "600m" [10:25:58] [t] Text received: Steve (243072456): "600m" [10:25:59] [t] Text received: Steve (243072456): "600m" [10:25:59] [t] Text received: Steve (243072456): "600m" [10:26:07] [t] Text received: Steve (243072456): "1000m" [10:26:50] [N] Notified user Job (237699614) of Pikachu 2814.0m away! [10:28:01] [N] Notified user Job (237699614) of Pikachu 2151.0m away! [10:29:32] [N] Notified user Job (237699614) of Squirtle 3570.0m away! [10:31:02] [N] Notified user Job (237699614) of Scyther 2392.0m away! [10:31:12] [N] Notified user Job (237699614) of Squirtle 1245.0m away! [10:31:53] [N] Notified user Job (237699614) of Charmander 1639.0m away! [10:33:03] [N] Notified user Job (237699614) of Pikachu 3468.0m away! [10:33:34] [N] Notified user Job (237699614) of Wartortle 2269.0m away! [10:33:54] [+] Telegram bot for PGO-mapscan-opt started!

dikkedeur avatar Sep 30 '16 11:09 dikkedeur

okay now with the log on..

[13:12:30] [N] Job (237699614) got maximum notifications per cycle [13:12:33] [l] Location received: Job (237699614): [52.960746,4.753247] [13:12:36] [l] Location received: Job (237699614): [52.960746,4.753247] [13:12:38] [l] Location received: Job (237699614): [52.960746,4.753247] [13:12:41] [N] Notified user Job (237699614) of Squirtle 1086.0m away! [13:12:41] [l] Location received: Job (237699614): [52.960746,4.753247] [13:12:41] [N] Notified user Job (237699614) of Squirtle 1631.0m away! [13:12:41] [N] Notified user Job (237699614) of Pikachu 3448.0m away! [13:12:43] [l] Location received: Job (237699614): [52.960718,4.753325] [13:12:46] [l] Location received: Job (237699614): [52.960718,4.753325] [13:12:46] [N] Notified user Job (237699614) of Pikachu 3273.0m away! [13:12:46] [N] Job (237699614) got maximum notifications per cycle [13:12:49] [l] Location received: Job (237699614): [52.960716,4.753366] [13:12:53] [t] Text received: Job (237699614): "📝 Ignored pokemon" [13:12:54] [t] Text received: Job (237699614): "🏠 Go back to main menu" [13:12:56] [N] Notified user Job (237699614) of Wartortle 2414.0m away! [13:12:57] [l] Location received: Job (237699614): [52.96071,4.753488] [13:12:57] [N] Notified user Job (237699614) of Pikachu 3779.0m away! Traceback (most recent call last): File "telebot.py", line 459, in main() File "telebot.py", line 353, in main f.write(u'{}\n'.format(log_queue.get(1))) UnicodeEncodeError: 'ascii' codec can't encode character u'\U0001f4dd' in position 48: ordinal not in range(128)

spammed the menu on update your location,

dikkedeur avatar Sep 30 '16 11:09 dikkedeur

again you see [13:12:56] [N] Notified user Job (237699614) of Wartortle 2414.0m away! that wartortle... might be something.. ?

dikkedeur avatar Sep 30 '16 11:09 dikkedeur

I get nearly the same error when sending "about the bot":

[15:21:23] [t] Text received: @nglsr (3422302): "ℹ About the bot" Traceback (most recent call last): File "telebot.py", line 459, in main() File "telebot.py", line 353, in main f.write(u'{}\n'.format(log_queue.get(1))) UnicodeEncodeError: 'ascii' codec can't encode character u'\u2139' in position 49: ordinal not in range(128)

The line before that ("ℹ About the bot") is obviously the problem. I've added debug statements before and after the f.write() and it crashed when trying to log exactly that.

nyxdis avatar Sep 30 '16 13:09 nyxdis

@seikur0 Sorry, I guess I had an old version of the file.

The problem described here is connected to trying to write Unicode to file without encoding it properly. To fix it you have to change line 353 in telebot.py from

f.write(u'{}\n'.format(log_queue.get(1)))

to

f.write(u'{}\n'.format(log_queue.get(1)).encode('utf8'))

The bot is working for me now. Good job, I like the new bot.

Zyrix avatar Sep 30 '16 13:09 Zyrix