Add archwiki command

This commit is contained in:
deadcade 2022-06-28 09:53:24 +02:00
parent af8e2d9b53
commit 165047581f
2 changed files with 14 additions and 2 deletions

View file

@ -18,7 +18,8 @@
"roll",
"xkcd",
"help",
"httpcat"
"httpcat",
"aw"
],
"help_messages": {
"help": "{prefix}help (command): Get information on commands",
@ -28,7 +29,8 @@
"httpcat": "{prefix}httpcat (Status Code): Get a HTTP Cat",
"shrug": "{prefix}shrug {text}: Append ¯\\_(ツ)_/¯ to the text",
"emoji_size": "{prefix}emoji_size {size}: Set the default emoji size",
"emoji_list": "{prefix}emoji_list: Get a list of usable custom emojis"
"emoji_list": "{prefix}emoji_list: Get a list of usable custom emojis",
"aw": "{prefix}aw (Search term): Search the Arch Wiki"
},
"source_url": "https://g.deadca.de/deadcade/Matrix-Selfbot"
}

10
main.py
View file

@ -282,6 +282,16 @@ async def httpcat(args, room, event):
else:
return await send_text(room.room_id, "Failed to get HTTP Cat!")
async def aw(args, room, event):
if len(args) > 0:
search = "+".join(args)
r = requests.get("https://wiki.archlinux.org/index.php?search=" + search)
if r.status_code == 200:
return await send_text(room.room_id, r.url)
else:
return await send_text(room.room_id, "https://wiki.archlinux.org/index.php?search=" + search)
else:
return await send_text(room.room_id, "Please provide a search term.")
async def message_callback(room: nio.MatrixRoom, event: nio.RoomMessageText) -> None:
global client, settings, emojis