Skip to content

Commit

Permalink
Add sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiosangregorio committed Mar 24, 2019
1 parent 1b62477 commit 7957a3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions reddit_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from telepot.namedtuple import InlineKeyboardMarkup, InlineKeyboardButton
from chatbase import Message
from sentry_sdk import capture_exception

from config import MAX_REDDIT_POST_LENGTH
from secret import CHATBASE_TOKEN as TOKEN
Expand Down Expand Up @@ -54,9 +55,8 @@ def send_post(bot, chat_id, subreddit=None, post_url=None):

post_is_gif, gif_url = is_gif(post_url)
except Exception as e:
print(e)
send_exception_message(bot, chat_id, f"I'm sorry, an error occurred in retrieving\nthe post from {subreddit} :(\n"\
"The developer must have missed an if statement!")
"The developer must have missed an if statement!", e)

try:
# check if the post is a text post
Expand All @@ -78,12 +78,12 @@ def send_post(bot, chat_id, subreddit=None, post_url=None):
intent="random_post")
msg.send()
except Exception as e:
print(e)
send_exception_message(bot, chat_id, f"I'm sorry, an error occurred in sending\nthe post from {subreddit} :(\n"\
"The developer must have missed an if statement!")
"The developer must have missed an if statement!", e)


def send_exception_message(bot, chat_id, msg):
def send_exception_message(bot, chat_id, msg, e):
capture_exception(e)
keyboard = InlineKeyboardMarkup(inline_keyboard=[
[InlineKeyboardButton(text='Try again', callback_data='reddit')]
])
Expand Down
Binary file modified requirements.txt
Binary file not shown.
2 changes: 2 additions & 0 deletions telereddit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import time
import telepot
import sentry_sdk

from secret import TELEGRAM_TOKEN as TOKEN
import reddit_linker
Expand Down Expand Up @@ -41,6 +42,7 @@ def main():
time.sleep(3)


sentry_sdk.init("https://[email protected]/1422477")
bot = telepot.Bot(TOKEN)

if __name__ == "__main__":
Expand Down

1 comment on commit 7957a3c

@fabiosangregorio
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.