collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: InfoNote archive  (Read 1787 times)

0 Members and 1 Guest are viewing this topic.

MatHack

  • Guest
InfoNote archive
« on: March 15, 2006, 10:17:06 pm »
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
Code: [Select]
<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
Code: [Select]
<font color=CCInfoHeader><pre>note &lt;note&gt; &gt; &lt;contents&gt;</font>
<font color=CCInfoText>Creates &lt;note&gt; with initial &lt;contents&gt;.

<font color=CCInfoHeader><pre>note add &lt;note&gt; &gt; &lt;contents&gt;</font>
Appends &lt;contents&gt; to &lt;note&gt;.

<font color=CCInfoHeader><pre>note del &lt;note&gt;</font>
Removes &lt;note&gt;.</font>

InfoNote.php
Code: [Select]
<?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 (.+) &gt; (.+)$/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('"'"&quot;"$info[2]);
$info[2] = str_replace('&lt;'"<"$info[2]);
$info[2] = str_replace('&gt;'">"$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 (.+) &gt; (.+)$/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('"'"&quot;"$info[2]);
$info[2] = str_replace('&lt;'"<"$info[2]);
$info[2] = str_replace('&gt;'">"$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));
}
}
}
}
?>

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: InfoNote archive
« Reply #1 on: March 15, 2006, 10:28:12 pm »
I've missed that command as well. Thanks for that.

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 690
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal