From 570dba09a65f3f889da739da3d00461023f930b9 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 9 May 2022 15:34:00 -0400 Subject: move to using config.py parser stuff --- tooter.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tooter.py') diff --git a/tooter.py b/tooter.py index 8a54a68..6447801 100644 --- a/tooter.py +++ b/tooter.py @@ -1,10 +1,11 @@ #!/usr/bin/env python3 -from mastodon import Mastodon -from irctokens import build, Line +from .config import Config from ircrobots import Bot as BaseBot -from ircrobots import Server as BaseServer from ircrobots import ConnectionParams, SASLUserPass +from ircrobots import Server as BaseServer +from irctokens import build, Line +from mastodon import Mastodon import asyncio import emoji import glob @@ -68,6 +69,14 @@ def think(line): class Server(BaseServer): + def __init__(self, + bot: BaseBot, + name: str, + config: Config): + + super().__init__(bot, name) + self._config = config + async def line_send(self, line: Line): print(f"{self.name} > {line.format()}") @@ -102,12 +111,13 @@ class Bot(BaseBot): async def main(): params = ConnectionParams( - config["botnick"], - host=config["address"], - port=config["port"], - tls=config["tls"], + config.get("botnick", "tooter"), + config.get("address", "127.0.0.1"), + config.get("port", 6667), + config.get("tls", False), sasl=SASLUserPass(account["username"], account["password"]), ) + bot = Bot() await bot.add_server("tilde", params) await bot.run() -- cgit 1.4.1