Missed this option on BeBot and it's used a lot on the current IGN orgbot (which I'm replacing with BeBot), so I made it (quick and dirty).
help/info.txt
<font color=CCInfoHeader><pre>info [note]</font>
<font color=CCInfoText>Shows the note named [note] or the list of notes if no name is provided.</font>
help/note.txt
<font color=CCInfoHeader><pre>note <note> > <contents></font>
<font color=CCInfoText>Creates <note> with initial <contents>.
<font color=CCInfoHeader><pre>note add <note> > <contents></font>
Appends <contents> to <note>.
<font color=CCInfoHeader><pre>note del <note></font>
Removes <note>.</font>
InfoNote.php
<?php
/*
* InfoNote.php - InfoNote archive
* Module by MatHack
*/
$db -> query(
"CREATE TABLE IF NOT EXISTS info_note
(
name VARCHAR(50) NOT NULL PRIMARY KEY,
madeby VARCHAR(25),
contents TEXT
)"
);
$infoNote = new InfoNote($bot);
$commands["tell"]["info"] = &$infoNote;
$commands["tell"]["note"] = &$infoNote;
$commands["gc"]["info"] = &$infoNote;
class InfoNote
{
var $bot;
function InfoNote (&$bot)
{
$this -> bot = &$bot;
}
function tell($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "info$/i", $msg, $info))
{
$res = "<font color=CCInfoHeadline>::: List of notes :::</font>\n\n";
$result = $this -> bot -> db -> select("SELECT name, madeby FROM info_note ORDER BY name");
if (!empty($result))
{
foreach ($result as $val)
$res .= " - <a href='chatcmd:///tell <botname> <pre>info " . $val[0] . "'>" . $val[0] . "</a> (Author: " . $val[1] . ")\n";
}
$this -> bot -> send_tell($name, $this -> bot -> make_blob("List of notes", $res));
}
else if (preg_match("/^" . $this -> bot -> commpre . "info (.+)$/i", $msg, $info))
{
$result = $this -> bot -> db -> select("SELECT name, madeby, contents FROM info_note WHERE name = '" . $info[1] . "'");
if (!empty($result))
$this -> bot -> send_tell($name, $this -> bot -> make_blob($result[0][0], $result[0][2]) . " (Author: " . $result[0][1] . ")");
else
{
$res = "<font color=CCInfoHeadline>::: List of notes :::</font>\n\n";
$result = $this -> bot -> db -> select("SELECT name, madeby FROM info_note ORDER BY name");
if (!empty($result))
{
foreach ($result as $val)
$res .= " - <a href='chatcmd:///tell <botname> <pre>info " . $val[0] . "'>" . $val[0] . "</a> (Author: " . $val[1] . ")\n";
}
$this -> bot -> send_tell($name, $this -> bot -> make_blob("List of notes", $res));
}
}
else if (preg_match("/^" . $this -> bot -> commpre . "note del (.+)$/i", $msg, $info))
{
$result = $this -> bot -> db -> select("SELECT madeby FROM info_note WHERE name = '" . $info[1] . "'");
if (empty($result))
$this -> bot -> send_tell($name, "Note <font color=#ffff00>" . $info[1] . "</font> does not exist.");
else
{
if($this -> bot -> admin -> in_group($name, "admin") || $result[0][0] == $name)
{
$this -> bot -> db -> query("DELETE FROM info_note WHERE name = '" . $info[1] . "'");
$this -> bot -> send_tell($name, "Note <font color=#ffff00>" . $info[1] . "</font> has been deleted.");
}
else
$this -> bot -> send_tell($name, "You must be an admin to do this.");
}
}
else if (preg_match("/^" . $this -> bot -> commpre . "note add (.+) > (.+)$/i", $msg, $info))
{
$result = $this -> bot -> db -> select("SELECT madeby FROM info_note WHERE name = '" . $info[1] . "'");
if (empty($result))
$this -> bot -> send_tell($name, "Note <font color=#ffff00>" . $info[1] . "</font> does not exist.");
else
{
if($this -> bot -> admin -> in_group($name, "admin") || $result[0][0] == $name)
{
$info[2] = str_replace('"', """, $info[2]);
$info[2] = str_replace('<', "<", $info[2]);
$info[2] = str_replace('>', ">", $info[2]);
$this -> bot -> db -> query('UPDATE info_note SET contents = CONCAT(contents, "' . $info[2] . '") WHERE name = "' . $info[1] . '"');
$this -> bot -> send_tell($name, "Note <font color=#ffff00>" . $info[1] . "</font> has been edited.");
}
else
$this -> bot -> send_tell($name, "You must be an admin to do this.");
}
}
else if (preg_match("/^" . $this -> bot -> commpre . "note (.+) > (.+)$/i", $msg, $info))
{
$result = $this -> bot -> db -> select("SELECT madeby FROM info_note WHERE name = '" . $info[1] . "'");
if (!empty($result))
$this -> bot -> send_tell($name, "Note <font color=#ffff00>" . $info[1] . "</font> already exists.");
else
{
$info[2] = str_replace('"', """, $info[2]);
$info[2] = str_replace('<', "<", $info[2]);
$info[2] = str_replace('>', ">", $info[2]);
$this -> bot -> db -> query('INSERT INTO info_note (name, madeby, contents) VALUES ("' . $info[1] . '", "' . $name . '", "' . $info[2] . '")');
$this -> bot -> send_tell($name, "Note <font color=#ffff00>" . $info[1] . "</font> has been created.");
}
}
}
function gc($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "info$/i", $msg, $info))
{
$res = "<font color=CCInfoHeadline>::: List of notes :::</font>\n\n";
$result = $this -> bot -> db -> select("SELECT name, madeby FROM info_note ORDER BY name");
if (!empty($result))
{
foreach ($result as $val)
$res .= " - <a href='chatcmd:///tell <botname> <pre>info " . $val[0] . "'>" . $val[0] . "</a> (Author: " . $val[1] . ")\n";
}
$this -> bot -> send_gc($this -> bot -> make_blob("List of notes", $res));
}
else if (preg_match("/^" . $this -> bot -> commpre . "info (.+)$/i", $msg, $info))
{
$result = $this -> bot -> db -> select("SELECT name, madeby, contents FROM info_note WHERE name = '" . $info[1] . "'");
if (!empty($result))
$this -> bot -> send_gc($this -> bot -> make_blob($result[0][0], $result[0][2]) . " (Author: " . $result[0][1] . ")");
else
{
$res = "<font color=CCInfoHeadline>::: List of notes :::</font>\n\n";
$result = $this -> bot -> db -> select("SELECT name, madeby FROM info_note ORDER BY name");
if (!empty($result))
{
foreach ($result as $val)
$res .= " - <a href='chatcmd:///tell <botname> <pre>info " . $val[0] . "'>" . $val[0] . "</a> (Author: " . $val[1] . ")\n";
}
$this -> bot -> send_gc($this -> bot -> make_blob("List of notes", $res));
}
}
}
}
?>