pyTelegramBotAPI icon indicating copy to clipboard operation
pyTelegramBotAPI copied to clipboard

Formatting error in telebot

Open stmotw opened this issue 11 years ago • 1 comments

When 502 Bad Gateway error happens while requesting tg api, such error repeats several times and bot stops listening to any messages:

2015-10-15 00:58:48,846 (__init__.py:158) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 502 Bad Gateway. Response body:
[<html> 
<head><title>502 Bad Gateway</title></head> 
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.6.2</center>
</body> 
</html> 
]"
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
msg = self.format(record) 
File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
return fmt.format(record) 
File "/usr/lib/python2.7/logging/__init__.py", line 467, in format
s = self._fmt % record.__dict__ 
ValueError: unsupported format character ']' (0x5d) at index 60 
Logged from file __init__.py, line 158

stmotw avatar Oct 15 '15 10:10 stmotw

I think this can help:

# Upon calling this function, TeleBot starts polling the Telegram servers for new messages.
# - none_stop: True/False (default False) - Don't stop polling when receiving an error from the Telegram servers
# - interval: True/False (default False) - The interval between polling requests
#           Note: Editing this parameter harms the bot's response time
# - block: True/False (default True) - Blocks upon calling this function
tb.polling(none_stop=False, interval=0, block=True)

Try setting none_stop=True in your polling() call.

pitasi avatar Feb 08 '16 15:02 pitasi