From a3464d866ef859b50a7e0cb8bf3b66109fe17f5f Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sun, 17 Jun 2018 17:41:43 +0530 Subject: [PATCH] Add /wiki for wikipedia --- command_list.txt | 3 ++- webhook.php | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/command_list.txt b/command_list.txt index 7f5b61f..0701c05 100644 --- a/command_list.txt +++ b/command_list.txt @@ -3,7 +3,8 @@ word - Get a random word words - Get n random words kys - Kill yourself coin - Tosses a coin -wiki - search the Arch wiki +wiki - search Wikipedia +arch_wiki - search the Arch wiki is - Is are - Are can - Can diff --git a/webhook.php b/webhook.php index 9313e34..3fbff07 100644 --- a/webhook.php +++ b/webhook.php @@ -151,7 +151,7 @@ function rand_question() send_text($question); } -function arch_wiki() +function media_wiki($base_url) { global $command_list; $search_query = ""; @@ -165,7 +165,7 @@ function arch_wiki() send_text('Missing search query'); return; } - $url = "https://wiki.archlinux.org/api.php?action=opensearch&format=json&search=" . urlencode($search_query); + $url = $base_url . "?action=opensearch&format=json&search=" . urlencode($search_query); $a = json_decode(file_get_contents($url)); $names = $a[1]; $urls = $a[3]; @@ -271,9 +271,13 @@ $modules = array( "command" => "/question", "function" => "rand_question();" ), + array( + "command" => "/arch_wiki", + "function" => "media_wiki('https://wiki.archlinux.org/api.php');" + ), array( "command" => "/wiki", - "function" => "arch_wiki();" + "function" => "media_wiki('https://en.wikipedia.org/w/api.php');" ), array( "command" => "/coin",