--- a/enanobot.php Wed Dec 31 21:54:19 2008 -0500
+++ b/enanobot.php Thu Jan 01 00:18:34 2009 -0500
@@ -76,6 +76,8 @@
require('config.php');
require('database.php');
+$enanobot_version = '0.5-unstable';
+
@ini_set('display_errors', 'on');
error_reporting(E_ALL);
@@ -182,6 +184,20 @@
$irc->close($quitmessage, true);
return 'BREAK';
}
+ else if ( in_array($message['nick'], $privileged_list) && preg_match('/^re(?:hash|load)?(?:config)?(?: |$)/', $message['message']) )
+ {
+ require('config.php');
+ $GLOBALS['privileged_list'] = $privileged_list;
+ $GLOBALS['alert_list'] = $alert_list;
+ $irc->privmsg($message['nick'], "Reloaded privileged_list and alert_list. privileged = " . str_replace("\n", '', print_r($privileged_list, true)) . "; alert = " . str_replace("\n", '', print_r($alert_list, true)));
+ }
+ else if ( substr($message['message'], 0, 1) == "\x01" && substr($message['message'], -1) == "\x01" )
+ {
+ $msg = trim($message['message'], "\x01");
+ list($ctcp) = explode(' ', $msg);
+ $params = substr($msg, strlen($ctcp)+1);
+ eval(eb_fetch_hook('event_ctcp'));
+ }
else if ( $message['action'] == 'PRIVMSG' )
{
eval(eb_fetch_hook('event_privmsg'));
--- a/libirc.php Wed Dec 31 21:54:19 2008 -0500
+++ b/libirc.php Thu Jan 01 00:18:34 2009 -0500
@@ -239,6 +239,23 @@
}
/**
+ * Sends a notice.
+ * @param string Nick or channel
+ * @param string Message
+ */
+
+ public function notice($nick, $message)
+ {
+ $message = str_replace("\r\n", "\n", $message);
+ $message = explode("\n", $message);
+ foreach ( $message as $line )
+ {
+ $line = $this->filter_message($line);
+ $this->put("NOTICE $nick :$line\r\n");
+ }
+ }
+
+ /**
* Parse bold (<b>...</b>) tags and color tags in a text into IRC speak, and process /me commands. Colors are <cyan>...</cyan>, specify background with <fg:bg>...</fgcolor:bgcolor>. Valid colors are white, black, navy, green, red, maroon, purple, orange, yellow, lime, teal, aqua, cyan, blue, pink, grey, and silver
* @param string Text to filter
* @return string
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ctcp.php Thu Jan 01 00:18:34 2009 -0500
@@ -0,0 +1,27 @@
+<?php
+
+eb_hook('event_ctcp', 'handle_ctcp($ctcp, $params, $message);');
+
+function handle_ctcp($ctcp, $params, $message)
+{
+ global $irc;
+ global $alert_list;
+ switch($ctcp)
+ {
+ case 'PING':
+ $irc->notice($message['nick'], "\x01PING $params\x01");
+ break;
+ case 'VERSION':
+ global $nick, $enanobot_version;
+ $irc->notice($message['nick'], "\x01VERSION $nick-$enanobot_version on PHP/" . PHP_VERSION . " (" . PHP_OS . ")\x01");
+ break;
+ default:
+ eval(eb_fetch_hook('event_custom_ctcp'));
+ break;
+ }
+ $now = date('r');
+ foreach ( $alert_list as $alertme )
+ {
+ $irc->privmsg($alertme, "Received CTCP \"$ctcp\" from {$message['nick']}, " . $now);
+ }
+}
--- a/modules/echo.php Wed Dec 31 21:54:19 2008 -0500
+++ b/modules/echo.php Thu Jan 01 00:18:34 2009 -0500
@@ -17,16 +17,16 @@
{
global $privileged_list;
- if ( in_array($message['nick'], $privileged_list) && preg_match("/^\!echo-([^\007, \r\n\a\t]+) /", $message['message'], $match) )
+ if ( in_array($message['nick'], $privileged_list) && preg_match("/^(?:\!echo-|\/msg )([^\007, \r\n\a\t]+) /", $message['message'], $match) )
{
global $libirc_channels;
$channel_name =& $match[1];
if ( isset($libirc_channels[$channel_name]) && is_object($libirc_channels[$channel_name]) )
{
- $libirc_channels[$channel_name]->msg(eb_censor_words(preg_replace("/^\!echo-([^\007, \r\n\a\t]+) /", '', $message['message'])), true);
+ $libirc_channels[$channel_name]->msg(eb_censor_words(preg_replace("/^(?:\!echo-|\/msg )((?:#|&)[^\007, \r\n\a\t]+) /", '', $message['message'])), true);
}
}
- else if ( in_array($message['nick'], $privileged_list) && preg_match("/^\!pm ([^\007, \r\n\a\t]+) (.+)/", $message['message'], $match) )
+ else if ( in_array($message['nick'], $privileged_list) && preg_match("/^(?:\!pm|\/msg) ([^\007, \r\n\a\t]+) (.+)/", $message['message'], $match) )
{
global $irc;
$irc->privmsg($match[1], eb_censor_words($match[2]));