Last active
December 26, 2015 15:39
-
-
Save robot56/7174517 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($args)){ | |
echo "wiki, isup, status, mojira, hopper"; | |
return; | |
} | |
$cmdargs = preg_replace("#".$arg[0]."#", "", $args); | |
$cmd = array( | |
'raw' => $args, | |
'command' => $arg[0], | |
'command_args' => $cmdargs, | |
'command_arg' => $cmd = explode(" ", $cmdargs), | |
); | |
switch ($arg[0]) { | |
case "wiki": | |
echo mc_wiki($cmd); | |
break; | |
case "isup": | |
echo mc_isup($cmd); | |
break; | |
case "status": | |
echo mc_status($cmd); | |
break; | |
case "mojia": | |
echo mc_mojira($cmd); | |
break; | |
case "hopper": | |
echo mc_hopper($cmd); | |
break; | |
} | |
return; | |
function mc_wiki($cmd) { | |
if(!$cmd['command_args']){ | |
return "What do you want to search?"; | |
} | |
$mcw_api = 'http://minecraft.gamepedia.com/api.php?format=json&action=query&list=search&srprop=timestamp&srsearch='; | |
$mcw_api .= urlencode($cmd['command_args']); | |
$mcw_json = json_decode(file_get_contents($mcw_api), true); | |
$mcw_page = $mcw_json['query']['search'][0]['title']; | |
if(!$mcw_page) { | |
return "No results."; | |
} else { | |
return "http://minecraftwiki.net/wiki/".urlencode($mcw_page); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment