feat: catbot has dogs now
This commit is contained in:
parent
92520761d8
commit
54d1a38a80
@ -26,3 +26,26 @@ class CatBot(Plugin):
|
||||
)
|
||||
else:
|
||||
await evt.reply("couldn't fetch a cat image :(")
|
||||
|
||||
@command.new("dog")
|
||||
async def dog_command(self, evt: MessageEvent) -> None:
|
||||
async with self.http.get("https://random.dog/woof.json") as response:
|
||||
if response.status == 200:
|
||||
image_link = await response.json()
|
||||
else:
|
||||
await evt.reply("couldn't fetch a dog image :(")
|
||||
return
|
||||
|
||||
async with self.http.get(image_link['url']) 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="dog",
|
||||
msgtype=MessageType.IMAGE,
|
||||
)
|
||||
)
|
||||
else:
|
||||
await evt.reply("couldn't fetch a dog image :(")
|
||||
|
@ -1,6 +1,6 @@
|
||||
maubot: 0.5.0
|
||||
id: com.juggalol.catbot
|
||||
version: 0.1.12
|
||||
version: 0.2.1
|
||||
license: MIT
|
||||
modules:
|
||||
- catbot
|
||||
|
Loading…
Reference in New Issue
Block a user