cvs: pearbot /modules pearbugs.php
[email protected] ("Mirco 'meebey' Bauer") Sun, 04 May 2008 11:37:51 -0000
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvsmeebey1209901071@cvsserver> |
meebey Sun May 4 11:37:51 2008 UTC
Added files:
/pearbot/modules pearbugs.php
Log:
- moved and updated (by amir) from svn.qnetp.net/phpbitch repository.
http://cvs.php.net/viewvc.cgi/pearbot/modules/pearbugs.php?view=markup&rev=1.1
Index: pearbot/modules/pearbugs.php
+++ pearbot/modules/pearbugs.php
<?php
/**
* $Id: pearbugs.php,v 1.1 2008/05/04 11:37:51 meebey Exp $
* $Revision: 1.1 $
* $Author: meebey $
* $Date: 2008/05/04 11:37:51 $
*
* Copyright (c) 2006 Amir Mohammad Saied <[email protected]>
*/
require_once 'HTTP/Request.php';
require_once 'PEAR/XMLParser.php';
class Net_SmartIRC_module_pearbugs
{
var $name = 'pearbugs';
var $description = 'Will return PEAR bugs info';
var $author = 'Amir Mohammad Saied <[email protected]>';
var $version = '$Revision: 1.1 $';
var $license = 'GPL';
var $actionids = array();
function module_init(&$irc)
{
$this->actionids[] = $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL,
'^!bug', $this, 'bug');
}
function module_exit(&$irc)
{
foreach ($this->actionids as $value) {
$irc->unregisterActionid($value);
}
}
function bug(&$irc, &$data)
{
global $bot;
if (!$bot->isMastah($irc, $data)) {
return;
}
if (isset($data->messageex[1])) {
$bugurl = 'http://pear.php.net/bugs/rss/bug.php?format=xml&id=';
$bugurl .= (int)$data->messageex[1];
$req =& new HTTP_Request($bugurl);
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->sendRequest();
if (PEAR::isError($req->sendRequest())) {
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
'Connection to PEAR server failed!');
} else {
$body = $req->getResponseBody();
if ($body == "Nothing found") {
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
'Invalid bug Number');
} else {
$parser = new PEAR_XMLParser;
$parseError = $parser->parse($body);
if (PEAR::isError($parseError)) {
var_dump($parseError->getMessage());
return PEAR::raiseError(
'Invalid XML file: '.$parseError->getMessage(), 0);
}
$content = $parser->getData();
$final_output = array();
$final_output[] = $content['bug_type'].' #'.$content['id'].
' (Status: '.$content['status'].', Package: '.
$content['package_name'].') ['.$content['ts1'].']';
$final_output[] = $content['sdesc'];
$final_output[] = 'http://pear.php.net/bugs/bug.php?id='.$content['id'];
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
$final_output);
}
}
} else {
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel,
'usage: !bug <bug_number>');
}
}
}
?>