summaryrefslogtreecommitdiff
path: root/tgbot.py
diff options
context:
space:
mode:
authorDmitrii Morozov <snoopdesigns@gmail.com>2024-05-07 17:15:25 +0200
committerDmitrii Morozov <snoopdesigns@gmail.com>2024-05-07 17:15:25 +0200
commitee3e87a6ec19878d56e8f386b20c58e4d9b211b3 (patch)
treec111165b0310581abeea0cecbfd9dabe2933e0d9 /tgbot.py
parentcfa79cbbaf42a8f74a2cd4bca4d1d495b4d597f1 (diff)
Modules
Diffstat (limited to 'tgbot.py')
-rwxr-xr-xtgbot.py68
1 files changed, 0 insertions, 68 deletions
diff --git a/tgbot.py b/tgbot.py
deleted file mode 100755
index 6fbd07c..0000000
--- a/tgbot.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python3
-
-import os, time, telebot, asyncio, telebot.async_telebot, nest_asyncio, sys
-from fortnite_status_notifier import *
-from formatter import *
-from fortnite_client import *
-from fortnite_events import *
-from persistence import UserRepository, StatsRepository, PresenceRepository
-from telegram_bot import TelegramBot, CommandHandler
-from commands import *
-
-class FortniteStatusObserverImpl(FortniteStatusObserver):
-
- telegram_bot: TelegramBot
-
- def __init__(self, telegram_bot: TelegramBot):
- self.__telegram_bot = telegram_bot
-
- async def update(self, fortnite_status) -> None:
- await self.__telegram_bot.send_message_to_all(format_fortnite_status(fortnite_status))
-
-user_repository = UserRepository()
-stats_repository = StatsRepository()
-presence_repository = PresenceRepository()
-telegram_bot = TelegramBot(user_repository)
-fortnite_status_notifier = FortniteStatusNotifier(FortniteStatusObserverImpl(telegram_bot))
-
-fortnite_client = FortniteClient(
- ClientInitObserverImpl(),
- FriendPresenceObserverImpl(telegram_bot, presence_repository))
-
-record_stats_command = RecordStatsCommand(fortnite_client, stats_repository)
-
-telegram_bot.register_command_handler('start', StartCommand(telegram_bot, user_repository))
-telegram_bot.register_command_handler('status', GetStatusCommand(telegram_bot))
-telegram_bot.register_command_handler('friends', GetFriendsCommand(telegram_bot, fortnite_client))
-telegram_bot.register_command_handler('stats', GetStatsCommand(telegram_bot, fortnite_client))
-telegram_bot.register_command_handler('todaystats', GetTodayStatsCommand(telegram_bot, fortnite_client, stats_repository))
-telegram_bot.register_command_handler('recordstats', record_stats_command)
-
-async def run_tgbot():
- await telegram_bot.run()
-
-async def run_fortnite_status_notifier():
- await fortnite_status_notifier.run()
-
-async def run_fortnite_client():
- fortnite_client.run()
-
-async def run_record_stats():
- while True:
- t = time.localtime()
- if t.tm_hour == 5: # only at 05:00
- await recordStatsCommand.handle(None)
- await asyncio.sleep(60 * 60) # 1 hour
-
-async def run_all():
- await asyncio.gather(
- run_tgbot(),
- run_fortnite_status_notifier(),
- run_fortnite_client(),
- run_record_stats())
-
-if __name__ == '__main__':
- nest_asyncio.apply()
- loop = asyncio.get_event_loop()
- loop.run_until_complete(run_all())
- loop.close() \ No newline at end of file