summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Formatter.py4
-rwxr-xr-xtgbot.py12
2 files changed, 12 insertions, 4 deletions
diff --git a/Formatter.py b/Formatter.py
index e43b782..07499e5 100644
--- a/Formatter.py
+++ b/Formatter.py
@@ -61,9 +61,9 @@ def formatFriendOnline(display_name: str, party_size: int):
if party_size == 1:
text = 'is playing Fortnite\!'
elif party_size == 2:
- text = 'is playing Fortnite with {} friend\!'.format(str(party_size - 1))
+ text = 'is playing Fortnite together with {} friend\!'.format(str(party_size - 1))
elif party_size > 2:
- text = 'is playing Fortnite with {} friends\!'.format(str(party_size - 1))
+ text = 'is playing Fortnite together with {} friends\!'.format(str(party_size - 1))
return formatting.format_text(
u'\u2b50',
formatting.mbold('{}'.format(display_name)),
diff --git a/tgbot.py b/tgbot.py
index 8c4fa03..a414682 100755
--- a/tgbot.py
+++ b/tgbot.py
@@ -1,6 +1,6 @@
#!/usr/bin/python3
-import os, time, telebot, asyncio, telebot.async_telebot, nest_asyncio
+import os, time, telebot, asyncio, telebot.async_telebot, nest_asyncio, sys, logging
from FortniteStatusNotifier import *
from Formatter import *
from FortniteClient import *
@@ -34,7 +34,15 @@ class FortnitePresenceObserver(PresenceObserver):
async def __notifyFriendPlaying(self, display_name: str, party_size: int):
await send_message_to_all(formatFriendOnline(display_name, party_size))
-bot = telebot.async_telebot.AsyncTeleBot(os.environ["TELEBOT_BOT_TOKEN"])
+class ExceptionHandler(telebot.ExceptionHandler):
+ def handle(self, exception):
+ logging.error('Exception happened: {}'.format(str(exception)))
+ sys.exit('Exiting with telebot exception')
+ return True
+
+bot = telebot.async_telebot.AsyncTeleBot(
+ token=os.environ["TELEBOT_BOT_TOKEN"],
+ exception_handler=ExceptionHandler())
userRepository = UserRepository('db.sqlite')
fortniteStatusWrapper = FortniteStatusNotifier(FortniteStatusObserver())
fortniteClient = FortniteClient(FortnitePresenceObserver())