Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xjxckk authored Mar 7, 2022
1 parent 922b27d commit 0099d7e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion alerts/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
from .alerts import setup
import traceback, telegram

class setup:
def __init__(self, telegram_token, telegram_channel, full_error=False, raise_error=False):
self.bot = telegram.Bot(token=telegram_token)
self.channel = telegram_channel
self.full_error = full_error
self.raise_error = raise_error
def send(self, title, exception):
error = str(exception)
if self.full_error:
error = traceback.format_exc()
message = f'{title}: {error}'
self.bot.send_message(self.channel, message)
print(message)
print()
if self.raise_error:
raise Exception('Raiser') from exception

0 comments on commit 0099d7e

Please sign in to comment.