From b744401e792418b7ed75bb4ec85f4ef4247c092c Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Tue, 1 Nov 2022 23:40:48 -0700 Subject: [PATCH] relogin on every handle --- wiki_postbot/clients/discord_client.py | 2 +- wiki_postbot/interfaces/mediawiki.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wiki_postbot/clients/discord_client.py b/wiki_postbot/clients/discord_client.py index 1c91722..ecd5b29 100644 --- a/wiki_postbot/clients/discord_client.py +++ b/wiki_postbot/clients/discord_client.py @@ -149,7 +149,7 @@ def main(): discord_creds = Discord_Creds.from_json(directory / 'discord_creds.json') wiki_creds = Mediawiki_Creds.from_json(directory / 'mediawiki_creds.json') - wiki = Wiki(url=args.wiki, log_dir=log_dir) + wiki = Wiki(url=args.wiki, log_dir=log_dir, creds=wiki_creds) wiki.login(wiki_creds) client = DiscordClient(wiki=wiki, log_dir=log_dir) diff --git a/wiki_postbot/interfaces/mediawiki.py b/wiki_postbot/interfaces/mediawiki.py index b698012..be6cb13 100644 --- a/wiki_postbot/interfaces/mediawiki.py +++ b/wiki_postbot/interfaces/mediawiki.py @@ -20,14 +20,16 @@ import pdb class Wiki: - def __init__(self, url:str, api_suffix:str="/api.php", index_page="Discord Messages", + def __init__(self, url:str, creds:Mediawiki_Creds, + api_suffix:str="/api.php", index_page="Discord Messages", log_dir:Path=Path('/var/www/wikibot')): self.url = url self.api_url = urljoin(self.url, api_suffix) + self.creds = creds self.sess = None self.index_page = index_page self.logger = init_logger('wiki_interface', basedir=log_dir) - + self.login(self.creds) def login(self, creds:Mediawiki_Creds): # get token to log in @@ -140,6 +142,7 @@ class Wiki: Not being precious about this, just implementing and will worry about generality later! """ + self.login(self.creds) # Get message in mediawiki template formatting template_str = TemplateMessage.format_discord(msg)