diff --git a/data/settings.json b/data/settings.json index 7f004cc..c45113c 100644 --- a/data/settings.json +++ b/data/settings.json @@ -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" } diff --git a/main.py b/main.py index 46adb54..dcc901b 100644 --- a/main.py +++ b/main.py @@ -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