platform/BaseLib/bot.py
Administrator 9e7fc7b4c1 initial
2023-09-23 16:13:11 +03:00

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"Ошибка на проекте YourGols.\nПодробности: \n{get_traceback(sys.exc_info()[2])}\n{str(exc)}")