commit 246bf983bb6bb6bdca178b5d1a4f3a97d23f6075 Author: agatha Date: Tue Sep 17 16:24:41 2024 -0400 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07ce4fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.idea/ +venv/ +__pycache__/ +*.py[cod] +*.mbp diff --git a/README.md b/README.md new file mode 100644 index 0000000..545e302 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# maubot-plugins +repository of example code and custom plugins diff --git a/catbot/catbot/__init__.py b/catbot/catbot/__init__.py new file mode 100644 index 0000000..f24eb02 --- /dev/null +++ b/catbot/catbot/__init__.py @@ -0,0 +1,28 @@ +import aiohttp +from maubot import Plugin, MessageEvent +from maubot.handlers import command +from mautrix.types import MessageType, MediaMessageEventContent + + +class CatBot(Plugin): + async def start(self) -> None: + self.http = aiohttp.ClientSession() + + async def stop(self) -> None: + await self.http.close() + + @command.new("cat") + async def cat_command(self, evt: MessageEvent) -> None: + async with self.http.get("https://cataas.com/cat") as response: + if response.status == 200: + image_data = await response.read() + mxc_uri = await self.client.upload_media(image_data, mime_type="image/jpeg") + await evt.respond( + content=MediaMessageEventContent( + url=mxc_uri, + body="cat", + msgtype=MessageType.IMAGE, + ) + ) + else: + await evt.reply("couldn't fetch a cat image :(") diff --git a/catbot/maubot.yaml b/catbot/maubot.yaml new file mode 100644 index 0000000..f84c73b --- /dev/null +++ b/catbot/maubot.yaml @@ -0,0 +1,7 @@ +maubot: 0.5.0 +id: com.juggalol.catbot +version: 0.1.12 +license: MIT +modules: + - catbot +main_class: CatBot \ No newline at end of file diff --git a/catbot/requirements.txt b/catbot/requirements.txt new file mode 100644 index 0000000..81989a4 --- /dev/null +++ b/catbot/requirements.txt @@ -0,0 +1,3 @@ +maubot +mautrix +aiohttp \ No newline at end of file diff --git a/hello/hello/__init__.py b/hello/hello/__init__.py new file mode 100644 index 0000000..4d1c187 --- /dev/null +++ b/hello/hello/__init__.py @@ -0,0 +1,8 @@ +from maubot import Plugin, MessageEvent +from maubot.handlers import command + + +class HelloBot(Plugin): + @command.new() + async def hello(self, evt: MessageEvent): + await evt.reply("yes hello!") diff --git a/hello/maubot.yaml b/hello/maubot.yaml new file mode 100644 index 0000000..6a4d96c --- /dev/null +++ b/hello/maubot.yaml @@ -0,0 +1,7 @@ +maubot: 0.5.0 +id: com.juggalol.hello +version: 1.0.0 +license: MIT +modules: + - hello +main_class: HelloBot \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b5f790b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +maubot +mautrix