This script is similar to the IRC Bot in the Anope Support channel except this script returns the actual Module URL unlike the Anope Modbot.
This script works on PITC v1.0 and above.
Usage: ? smod modulename
Example:
(13:53) ? smod bs_fantasy_ext
(13:53) -FudgieWudgie:#j.test- bs_fantasy_ext - http://modules.anope.org/index.php?page=view&id=42
<?php
$api->log(" = Anope Modbot Loaded =");
$api->addTextHandler("modbot_text");
function modbot_text($args) {
global $api;
$chan = $args['channel'];
$msg = explode(" ",$args['text']);
if (strtolower($msg[0]) == "?" && strtolower($msg[1]) == "smod") {
if (isset($msg[2])) {
$urls = modurl($msg[2]);
if (count($urls[1]) == 0) {
$api->notice($chan,"No modules found.");
}
else {
$api->notice($chan,$api->bold("{$urls[2][0]}")." - http://modules.anope.org/index.php?page=view&id={$urls[1][0]}");
}
}
else {
$api->notice($chan,"Usage: ".$msg[0]." ".$msg[1]." ModName");
}
}
}
function modurl($name) {
// Performs Search of Anope.org Modules site
$data = file_get_contents("http://modules.anope.org/index.php?page=browse&name={$name}");
preg_match_all("/<a href=\"index\.php\?page=view&id=([0-9]+)\">([0-9a-z_ ]+)<\/a>/",$data,$data);
return $data;
}
?>