cvs: pearbot /modules pearcmds.php
[email protected] ("Mirco 'meebey' Bauer") Sat, 26 Jul 2003 11:00:16 -0000
| Newsgroups | php.pear.bot |
|---|---|
| Message-ID | <cvsmeebey1059217216@cvsserver> |
meebey Sat Jul 26 07:00:16 2003 EDT
Added files:
/pearbot/modules pearcmds.php
Log:
- first import (written by [email protected])
Index: pearbot/modules/pearcmds.php
+++ pearbot/modules/pearcmds.php
<?php
/**
* $Id: pearcmds.php,v 1.1 2003/07/26 11:00:16 meebey Exp $
* $Revision: 1.1 $
* $Author: meebey $
* $Date: 2003/07/26 11:00:16 $
*
* Copyright (c) 2003 Nicolas CHAILLAN <[email protected]>
*/
class Net_SmartIRC_module_pearcmds
{
var $name = 'pearcmds';
var $description = '!pear* commands';
var $author = 'Nicolas CHAILLAN <[email protected]>';
var $license = 'LGPL';
var $pear_binary = '/usr/local/bin/pear';
var $actionids = array();
function module_init(&$irc)
{
$this->actionids[] = $irc->registerActionhandler(SMARTIRC_TYPE_QUERY|SMARTIRC_TYPE_NOTICE, '^!pear', $this, 'pear');
}
function module_exit(&$irc)
{
foreach ($this->actionids as $value) {
$irc->unregisterActionid($value);
}
}
/* !pear command */
function pear(&$irc, &$data)
{
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'Helping '.$data->nick.' in private...');
if (!isset($data->messageex[1])) {
$print = $this->pear_help();
}
else {
switch ($data->messageex[1]) {
case 'info':
case 'remote-info':
if (!isset($data->messageex[2]) || empty($data->messageex[2])) {
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $data->nick.': syntax: !pear info package');
return;
}
$print = $this->pear_info($data->messageex[2]);
break;
case 'list':
case 'lists':
case 'list-all':
case 'remote-list':
$print = $this->pear_listing();
break;
case 'search':
case 'find':
if (!isset($data->messageex[2]) || empty($data->messageex[2])) {
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $data->nick.': syntax: !pear search search_for');
return;
}
$print = $this->pear_search($data->messageex[2]);
break;
case 'help':
default:
$print = $this->pear_help();
break;
}
}
$irc->message(SMARTIRC_TYPE_QUERY, $data->nick, $print);
}
function pear_info($package)
{
passthru($this->pear_binary.' remote-info '.$package, $buf);
$buf = 'This is the PEARbot:\n\nHere are the informations for '.$package.':\n\n'.$buf;
return $buf;
}
function pear_listing()
{
passthru($this->pear_binary.' remote-list', $buf);
$buf = 'This is the PEARbot:\n\nHere are the PEAR\'s packages:\n\n'.$buf;
return $buf;
}
function pear_search($search_for)
{
passthru($this->pear_binary.' search '.$search_for, $buf);
$buf = 'This is the PEARbot:\n\nHere are the PEAR\'s packages that match '.$search_for.':\n\n'.$buf;
return $buf;
}
function pear_help()
{
return 'This is the PEARbot:\n.
PEAR Helps commands:\n
Every commands start with !pear\n
-help: gives this information
-info package: gives the info of a PEAR package
-list: list all packages
-search search_for: searchs all packages that contain search_for.';
}
}
?>