def test_03EnableDiscordWebHook(self): DiscordWebHooks(name="Youtube LoadingReadyRun", key="invalidKey").add() res = DiscordWebHooks(name="Youtube").findAllByName() if len(res) >= 1: assert True else: assert False
def getDiscordList(self, siteName: str) -> List[DiscordWebHooks]: h = list() dwh = DiscordWebHooks(name=siteName).findAllByName() if len(dwh) >= 1: for i in dwh: h.append(i) return h
def checkReddit(self): for i in self.e.reddit_values: r1 = f"Reddit {i.site}" Sources(name=r1, url=f"https://reddit.com/r/{i.site}").add() if i.icon != "": Icons(site=f"Custom Reddit {i.site}", fileName=i.icon).update() for h in i.hooks: DiscordWebHooks(name=r1, key=h).add()
def getHooks(self, newsSource: str) -> List[str]: hooks = list() try: dwh = DiscordWebHooks(name=newsSource).findAllByName() for i in dwh: hooks.append(i.key) return hooks except Exception as e: self.logger.critical( f"Unable to find DiscordWebhook for {newsSource.siteName}")
def checkSite(self, siteName: str, siteValues: List[EnvDetails]): for i in siteValues: if siteName == i.name: r1 = i.name elif siteName == "Reddit": r1 = f"{siteName} {i.site}" else: r1 = f"{siteName} {i.name}" Sources(name=r1, url=i.site).add() if i.icon != "": Icons(site=f"Custom {r1}", fileName=i.icon).update() for h in i.hooks: DiscordWebHooks(name=r1, key=h).add()
def test_add(self): try: d = DiscordWebHooks(name="test", key="badurl") d.add() res = d.findAllByName() if res[0].name == "test" and res[0].key == "badurl": assert True d.clearTable() else: assert False except: assert False
def checkFinalFantasyXIV(self): if self.e.ffxiv_all == True or self.e.ffxiv_topics == True: Sources( name="Final Fantasy XIV Topics", url="https://na.finalfantasyxiv.com/lodestone/topics/", ).add() if self.e.ffxiv_all == True or self.e.ffxiv_notices == True: Sources( name="Final Fantasy XIV Notices", url="https://na.finalfantasyxiv.com/lodestone/news/category/1", ).add() if self.e.ffxiv_all == True or self.e.ffxiv_maintenance == True: Sources( name="Final Fantasy XIV Maintenance", url="https://na.finalfantasyxiv.com/lodestone/news/category/2", ).add() if self.e.ffxiv_all == True or self.e.ffxiv_updates == True: Sources( name="Final Fantasy XIV Updates", url="https://na.finalfantasyxiv.com/lodestone/news/category/3", ).add() if self.e.ffxiv_all == True or self.e.ffxiv_status == True: Sources( name="Final Fantasy XIV Status", url="https://na.finalfantasyxiv.com/lodestone/news/category/4", ).add() for i in self.e.ffxiv_hooks: DiscordWebHooks(name="Final Fantasy XIV", key=i).add() if self.e.ffxiv_icon != "": Icons(site=f"Custom Final Fantasy XIV", fileName=self.e.ffxiv_icon).update()
def isDiscordEnabled(self, siteName: str) -> bool: dwh = DiscordWebHooks(name=siteName).findAllByName() if len(dwh) >= 1: return True else: return False
def clearOldRecords(self) -> None: # clear our the table cache from last startup Sources().clearTable() DiscordWebHooks().clearTable()
def test_init01(self): d = DiscordWebHooks(name="test") if d.name == "test" and d.key == "": assert True else: assert False
def test_clearTable(self): DiscordWebHooks().clearTable() res = len(DiscordWebHooks()) if res == 0: assert True
def test_init02(self): d = DiscordWebHooks(key="url") if d.name == "" and d.key == "url": assert True else: assert False