from telebot import formatting import time from pythonFortniteStatus.FortniteStatus import * __polling_interval__ = 5 fortniteStatus = FortniteStatus() class Observer: async def update(self, fortniteStatus) -> None: pass class FortniteStatusWrapper: observers = [] fortniteStatus = None async def run(self): while True: await self.__readStatus() time.sleep(__polling_interval__) async def __readStatus(self): serviceStatusTmp = fortniteStatus.getStatus() if serviceStatusTmp != self.fortniteStatus: await self.__notify(serviceStatusTmp) self.fortniteStatus = serviceStatusTmp async def __notify(self, fortniteStatus): print("Fortnite status changed, notifying observers") for observer in self.observers: await observer.update(fortniteStatus) def attach(self, observer: Observer): self.observers.append(observer)