diff options
author | Dmitrii Morozov <snoopdesigns@gmail.com> | 2024-04-08 23:40:24 +0200 |
---|---|---|
committer | Dmitrii Morozov <snoopdesigns@gmail.com> | 2024-04-08 23:40:24 +0200 |
commit | 7b992afe70925f244ca6e9746071ae71e497b54e (patch) | |
tree | 8c3b0184f5060c8e3adc632f27ff694a1b22c0e2 /tgbot.py | |
parent | 733e7e23a14588358607a65c2bb1f2677c1e53c6 (diff) |
Observe status of friends
Diffstat (limited to 'tgbot.py')
-rwxr-xr-x | tgbot.py | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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 |