From b1b3f62d3792384e4d3bd34de376fd0fe6c96824 Mon Sep 17 00:00:00 2001 From: pwm Date: Sat, 7 Jun 2025 17:07:06 -0400 Subject: [PATCH] begin restructuring bot's fediverse client code --- bot/client.py | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/bot/client.py b/bot/client.py index 57f9f4e..053f981 100644 --- a/bot/client.py +++ b/bot/client.py @@ -1,6 +1,45 @@ +from abc import abstractmethod +from typing import Iterable, override + import misskey import config +class FediverseNote: + """Abstraction for notes Use this to talk to per-software implementations""" + def __init__(self, note): + pass -def client_connection() -> misskey.Misskey: - return misskey.Misskey(address=config.INSTANCE, i=config.KEY) +class FediverseClient: + def __init__(self, instance, software): + self.instance = instance + self.software = software + + @abstractmethod + def get_notifications(self) -> Iterable[FediverseNote]: + """Page through notifications from the instance""" + pass + + @abstractmethod + def create_note(self, text, visibility, addressee, attachment): + """Create a new note""" + pass + +class MisskeyClient(FediverseClient): + def __init__(self, instance, software): + super().__init__(instance, software) + + + def get_notifications(self) -> Iterable[FediverseNote]: + pass + + def create_note(self, text, visibility, addressee, attachment): + pass + +class PleromaClient(FediverseClient): + def __init__(self, instance, software): + super().__init__(instance, software) + + def get_notifications(self) -> Iterable[FediverseNote]: + pass + def create_note(self, text, visibility, addressee, attachment): + pass