commit
fc2399346f
|
@ -23,6 +23,7 @@ class TelegramBot(Bot):
|
||||||
# return when telegram returns an error code
|
# return when telegram returns an error code
|
||||||
if update in [303, 404, 420, 500, 502]:
|
if update in [303, 404, 420, 500, 502]:
|
||||||
return reports
|
return reports
|
||||||
|
# log unusual telegram error messages
|
||||||
if isinstance(update, int):
|
if isinstance(update, int):
|
||||||
try:
|
try:
|
||||||
logger.error("City " + str(user.uid) +
|
logger.error("City " + str(user.uid) +
|
||||||
|
@ -31,18 +32,21 @@ class TelegramBot(Bot):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
logger.error("Unknown Telegram error code: " + str(update))
|
logger.error("Unknown Telegram error code: " + str(update))
|
||||||
return reports
|
return reports
|
||||||
|
# save the last message, so it doesn't get crawled again
|
||||||
user.save_seen_tg(update.update_id)
|
user.save_seen_tg(update.update_id)
|
||||||
|
# complain if message is a photo
|
||||||
if update.message.photo:
|
if update.message.photo:
|
||||||
tb.send_message(
|
tb.send_message(
|
||||||
update.message.sender.id,
|
update.message.sender.id,
|
||||||
"Sending Photos is not supported for privacy reasons. Can "
|
"Sending Photos is not supported for privacy reasons. Can "
|
||||||
"you describe it as text instead?")
|
"you describe it as text instead?")
|
||||||
continue
|
continue
|
||||||
if hasattr(update.message, 'text'):
|
# complain if message is a media file
|
||||||
|
if update.message.text is None:
|
||||||
tb.send_message(
|
tb.send_message(
|
||||||
update.message.sender.id,
|
update.message.sender.id,
|
||||||
"We only support text only reporting for privacy reasons."
|
"We only support text reporting for privacy reasons. Can "
|
||||||
"Can you describe it as text instead?")
|
"you describe it as text instead?")
|
||||||
continue
|
continue
|
||||||
if update.message.text.lower() == "/start":
|
if update.message.text.lower() == "/start":
|
||||||
user.add_telegram_subscribers(update.message.sender.id)
|
user.add_telegram_subscribers(update.message.sender.id)
|
||||||
|
|
Loading…
Reference in New Issue