23 lines
599 B
Python
23 lines
599 B
Python
import os
|
|
import sys
|
|
|
|
import telebot
|
|
|
|
CHAT_ID = -914906133
|
|
TELEGRAM_TOKEN = os.getenv("TELEGRAM_TOKEN")
|
|
if TELEGRAM_TOKEN is not None:
|
|
bot = telebot.TeleBot(TELEGRAM_TOKEN)
|
|
|
|
|
|
def get_traceback(tb):
|
|
if tb.tb_next is not None:
|
|
next_tb = get_traceback(tb.tb_next)
|
|
else:
|
|
next_tb = ''
|
|
return str(tb.tb_frame) + '\n' + next_tb
|
|
|
|
|
|
def notify_if_needed(exc):
|
|
if type(exc) is not KeyboardInterrupt and TELEGRAM_TOKEN:
|
|
bot.send_message(CHAT_ID, f"Ошибка на проекте Platform.\nПодробности: \n{get_traceback(sys.exc_info()[2])}\n{str(exc)}")
|