From cea8fdf0a12d4a095e3c8b672fb6afe4a0c12c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Sat, 22 Jun 2024 19:33:45 -0300 Subject: [PATCH] Implement Sentry --- bin/run_bot.py | 9 +++++++++ pyproject.toml | 1 + 2 files changed, 10 insertions(+) diff --git a/bin/run_bot.py b/bin/run_bot.py index a33422a..13c7ce5 100644 --- a/bin/run_bot.py +++ b/bin/run_bot.py @@ -1,5 +1,8 @@ import os + from telegram.ext import Application, MessageHandler, filters +import sentry_sdk + from pycamp_bot.commands import auth from pycamp_bot.commands import voting from pycamp_bot.commands import manage_pycamp @@ -12,6 +15,12 @@ from pycamp_bot.models import models_db_connection from pycamp_bot.logger import logger + +SENTRY_DATA_SOURCE_NAME_ENVVAR = 'SENTRY_DATA_SOURCE_NAME' +if SENTRY_DATA_SOURCE_NAME_ENVVAR in os.environ: + sentry_sdk.init(dsn=os.environ[SENTRY_DATA_SOURCE_NAME_ENVVAR]) + + async def unknown_command(update, context): text = "No reconozco el comando, para ver comandos válidos usá /ayuda" await context.bot.send_message(chat_id=update.message.chat_id, text=text) diff --git a/pyproject.toml b/pyproject.toml index 4e8d1c4..755cc96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ dependencies = [ "munch==4.0.0", "python-telegram-bot==21.3", "peewee==3.17.5", + "sentry-sdk==2.6.0", ] requires-python = "==3.10.*" authors = [