summaryrefslogtreecommitdiff
path: root/tgbot.py
diff options
context:
space:
mode:
Diffstat (limited to 'tgbot.py')
-rwxr-xr-xtgbot.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/tgbot.py b/tgbot.py
index 99d6351..72e7aa9 100755
--- a/tgbot.py
+++ b/tgbot.py
@@ -3,8 +3,10 @@
import os
import time, threading, schedule
import telebot
-from fortniteStatusWrapper import *
-from fortniteStatusFormatter import *
+from FortniteStatusWrapper import *
+from FortniteStatusFormatter import *
+from FortniteClient import *
+from FortniteEvents import *
from persistence import UserRepository
if "TELEBOT_BOT_TOKEN" not in os.environ:
@@ -13,6 +15,7 @@ if "TELEBOT_BOT_TOKEN" not in os.environ:
bot = telebot.TeleBot(os.environ["TELEBOT_BOT_TOKEN"])
userRepository = UserRepository('db.sqlite')
fortniteStatusWrapper = FortniteStatusWrapper()
+fortniteClient = FortniteClient()
@bot.message_handler(commands = ['start'])
def startCommand(message):
@@ -28,9 +31,20 @@ class FortniteStatusObserver(Observer):
parse_mode='MarkdownV2'
)
+class FortnitePresenceObserver(PresenceObserver):
+ def update(self, display_name: str, playing: bool) -> None:
+ for user in userRepository.getAllUsers():
+ bot.send_message(
+ user[0],
+ 'Fortnite observer {}, playing {}'.format(display_name, playing),
+ parse_mode='MarkdownV2'
+ )
+
if __name__ == '__main__':
fortniteStatusWrapper.attach(FortniteStatusObserver())
+ fortniteClient.attach(FortnitePresenceObserver())
main_thread = threading.Thread(target=bot.infinity_polling, name='bot_infinity_polling', daemon=True)
main_thread.start()
- main_thread.join() \ No newline at end of file
+ #main_thread.join()
+ fortniteClient.run() \ No newline at end of file