BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => BeBot 0.2 support => Topic started by: Xenixa on November 10, 2005, 11:34:35 am
-
I've been working on a function to display players listed on the Guests table with Name Date/Time they were added as a guest along with a Click Link to Remove them as a Guest.
However, since Relay_GUILD.php only records a player ID, I first decided to have it record 2 extra items in the Table(I hand altered the Table using the MySQL Administrator).
That worked great for recording new Guests added to the table and the original code for add and remove is pretty much untouched.
My problem is the g-damn get_uname() function in aochat.php If you look over the code below you can see were I'm testing if there was a value in the name column, then if not get it using the id column value and update that record.
Well all it returns is a big fat -1 when I use:
$this -> bot -> aoc -> get_uname($val[0])
/*
Makes a list of current Guests
*/
function guest_list($name)
{
$inside = "<font color=CCInfoHeadline>:::: <botname>'s Guest List ::::\n\n";
$result = $this -> bot -> db -> select("SELECT id, name, timeadd FROM guests ORDER BY id DESC");
if (!empty($result))
foreach ($result as $val)
{
if(empty($val[1]))
{
$gname = $this -> bot -> aoc -> get_uname($val[0]);
$this -> bot -> db -> query("UPDATE guests SET name = '".$gname."' WHERE id = '".$val[0]."'");
}
else
{
$inside .= "<font color=CCInfoHeader> " . $val[1] . "</font> <a href='chatcmd:///tell <botname> <pre>guest del " . $val[1] . "'>[Remove]</a>\n";
$inside .= "<font color=CCCCTextColor>Date added:</font> <font color=CCInfoHeader>" . gmdate("dS M, H:i", $val[2]) . " GMT\n\n";
}
}
return "Guests of <botname> :: " . $this -> bot -> make_blob("click to view", $inside);
}
Any one have any idea why it's returning -1? I rather not look up 40+ guest records by Player ID and update the table by hand. Every thing works with the Function except it doesn't show old entries names.
-
Here is the mostly finished Updated Relay_GUILD.php
Reason I am posting this here is I hope someone can figure out the problem I listed in the previous post.
- Added a guestlist command / function
- The first time guestlist is used on an exsisting bot it will update the guests table to include columns for Guest Name, Date/Time Added, and Who added them.
- After adding the columns it will update the guest records to include that info if it doesn't exsist.
- And finally it will return a clicky link to view the guest list.
Note: For some wierd reason on my Bot it returns the name as -1 so be warned. If it doesn't return a -1 for you that do try it out on a LIVE bot could you reply with what version of AOChat.php you are using? I myself use v1.17
If you use this on a new installation of a bot it will work just fine.
ftp://xen.afraid.org/bebot_files/Relay_GUILD.php
-
Hi Xenixa,
Bot comes up with:
(You have an error in your SQL syntax; check the manual that correspon
r MySQL server version for the right syntax to use near '' at line 5)
so changed lines to:-
$db -> query("CREATE TABLE IF NOT EXISTS guests
(id INT NOT NULL PRIMARY KEY,
name VARCHAR(25),
timeadd INT NOT NULL,
addby VARCHAR(25))");
And it works fine now.
I manually created the tables in the database and commented out the three lines as was written in the file. Guestlist function itself works fine, adding is recording in !guestlist and removing works and updates guestlist.
Perfect :-)
Cheers,
-jj-
-
Missed a ) in that copy did I? Ooops
Copy on my file server updated. :)
-
I'm currently in the process of updating and testing the Relay_GUILD module to auto-update exsisting guests tables using a different method to store their name.
Keep an eye on the Custom/Unofficial Modules forum for more info and the update later today. Then again it may already be there buy the time you read this. :D
-
Any ideas of why some people can be removed from the !guestlist and others can't?
Name1 *is* on the !guestlist.
To [botname]: !guest del Name1
[botname]: Name1 is not on the guestlist.
Same here, Name2 is on the !guestlist.
To [botname]: !guest del Name2
[botname]: Name2 has been removed from guestlist.
There's no errors on the terminal, nor in any logs. If there's no obvious solution, I'll just have to put in error checking, and make it print each variable as a member is added/removed :)
-
I've seen this happen also, and as far as I can tell when the bot with the current Relay_GUILD.php that I have posted checks the user ID using get_uid($guest) and it returns that they aren't on the list(when they clearly are) it seems to be chat server related. Meaning the get_uid call is timing out. Could probably add an extra layer with the UID check when removing and have it also check the $guest name variable against the Database as an OR condition.
BTW, In the past if that happens I just a wait a bit and try again. :)