initial commit
This commit is contained in:
commit
246bf983bb
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.idea/
|
||||
venv/
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.mbp
|
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# maubot-plugins
|
||||
repository of example code and custom plugins
|
28
catbot/catbot/__init__.py
Normal file
28
catbot/catbot/__init__.py
Normal file
@ -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 :(")
|
7
catbot/maubot.yaml
Normal file
7
catbot/maubot.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
maubot: 0.5.0
|
||||
id: com.juggalol.catbot
|
||||
version: 0.1.12
|
||||
license: MIT
|
||||
modules:
|
||||
- catbot
|
||||
main_class: CatBot
|
3
catbot/requirements.txt
Normal file
3
catbot/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
maubot
|
||||
mautrix
|
||||
aiohttp
|
8
hello/hello/__init__.py
Normal file
8
hello/hello/__init__.py
Normal file
@ -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!")
|
7
hello/maubot.yaml
Normal file
7
hello/maubot.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
maubot: 0.5.0
|
||||
id: com.juggalol.hello
|
||||
version: 1.0.0
|
||||
license: MIT
|
||||
modules:
|
||||
- hello
|
||||
main_class: HelloBot
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
maubot
|
||||
mautrix
|
Loading…
Reference in New Issue
Block a user