BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.4.x Custom/Unofficial Modules => Topic started by: Glarawyn on July 27, 2007, 09:04:55 pm

Title: Quotes!
Post by: Glarawyn on July 27, 2007, 09:04:55 pm
Module Name:
Return of the Quotes module, by Sabkor and Glarawyn!

Current Module Version:
2.0.1

Module Type:
Custom Module (Not Core)

Module Description:
We all say stupid things, and everyone wants to immortalize them.



Download:
Quotes 2.0.1 (http://zibby.isa-geek.net/BeBot_0.4/Quotes/Quotes_2.0.1.zip)

Changes from v2.0.0 to v2.0.1:
Changes from v1.5.0 to v2.0.0:
Title: Re: Quotes!
Post by: Glarawyn on July 27, 2007, 09:15:38 pm
Importing your Quotes from BeBot 0.2 to BeBot 0.4


That's it, you're done.
Title: Re: Quotes!
Post by: Dracutza on July 28, 2007, 03:37:46 am
line 363...

         
Code: [Select]
$inside = "Quotes Matching ".$searchterm.": \n\n";);
should be
         
Code: [Select]
$inside = "Quotes Matching ".$searchterm.": \n\n";   ?

Title: Re: Quotes!
Post by: Newsworthy on July 29, 2007, 12:54:37 pm
[29-Jul-2007 20:48:58] PHP Parse error:  syntax error, unexpected ')' in C:\Bebot\custom\modules\Quotes.php on line 363

Makes me a sad panda :(

EDIT: Didn't read Dracutza's line properly. Good show old bean ;) Now works beautifully
Title: Re: Quotes!
Post by: Dracutza on July 30, 2007, 05:50:53 pm
While I don't know what the properly function mod is supposed to do, making my edit appears to break the search function if there are 2+ quotes with the same search phrase.

For example, !search Tziganca, when there is just one quote with Tziganca, works as intended.
/tell bot !search Tziganca
bot: Blah blah Tziganca

However, when there are two quotes with Tziganca, the bot give a blank reply
/tell bot !search Tziganca
bot:

So while that edit does enable the mof to run, I don't know if it's the proper edit to make it work.
Title: Re: Quotes!
Post by: Glarawyn on July 30, 2007, 06:06:32 pm
I haven't been able to reproduce the issue Dracutza is reporting. Updated version without the typo posted.
Title: Re: Quotes!
Post by: Dracutza on July 31, 2007, 03:59:11 am
works pretty nice, thanks
Title: Re: Quotes!
Post by: Newsworthy on September 02, 2007, 03:54:13 pm
Hey, just noticed an issue that surfaced... I've deleted a few quotes from my database because they were kinda lame... But I noticed that the hole where the quote was remains empty.

This seems to screw the counting process. We have over 40 quotes, yet, it seems only recognize numbers 1-4 when searching for a quote ID. (#5 was one of the ones deleted).

Also, I'll add a quote, and it says its #41. However, when I do !quotes 41, it shows a completely different quote.

Any thoughts? :)
Title: Re: Quotes!
Post by: Newsworthy on September 13, 2007, 02:14:35 am
Bump

Also, any new quotes that are added all appear as being #41.
Title: Re: Quotes!
Post by: Vhab on September 14, 2007, 09:25:13 am
This is because the quote numbering relies on mysql's "auto increment" feature and it simply works that way. Fixing your "issue" would require working around default features of mysql, which imo, would be somewhat of a waste.
Title: Re: Quotes!
Post by: Ebag333 on September 14, 2007, 02:21:15 pm
I think what he means is that since 41 is missing, all new quotes list themselves as 41.

So you have:

37
38
39

41
41
41
41

(That's just what I'm guessing he means, since I haven't played with it myself.)
Title: Re: Quotes!
Post by: Wolfbiter on September 14, 2007, 03:27:13 pm
41 is missing because someone deleted it, and since it uses auto increment, there wont be a 41 again.
Title: Re: Quotes!
Post by: Newsworthy on September 14, 2007, 04:16:30 pm
So, what can I do? Do I need to go into the database and reorder them?
Title: Re: Quotes!
Post by: Blueeagle on September 14, 2007, 04:23:08 pm
How are you getting the numbers. The ID-field is set as auto-increment in the database table so it must be an error with the way you get the IDs.
Title: Re: Quotes!
Post by: Blueeagle on September 14, 2007, 04:27:06 pm
Having looked at the file linked in the first post I've got a suspicion that function add_quote() might be the cause of alement.

This _might_ be fixed by

Code: [Select]
function add_quote($strquote, $name)
{ // Start function add_quote()
$strquote = mysql_real_escape_string($strquote);
$name = mysql_real_escape_string($name);
$sql = "INSERT INTO #___quotes (quote, contributor, botname) ";
$sql .= "VALUES ('".$strquote."','".$name."','".$this -> bot -> botname."')";
$this -> bot -> db -> query($sql);
    /*
$sql = "SELECT id FROM #___quotes ORDER BY id DESC";
$num = $this -> bot -> db -> select($sql);
    */
    $num = mysql_insert_id($this -> bot -> CONN);
$strmsg = "Thank you, your quote has been added as id #" . $num;
return $strmsg;         
} // End function add_quote()

Do note that I don't use this module myself and with the limited debug information this is to be concidere guesswork.
Title: Re: Quotes!
Post by: Ebag333 on September 14, 2007, 04:41:10 pm
Hmm, that DOES seem to be a rather silly way of handling that. :)
Title: Re: Quotes!
Post by: Blueeagle on September 14, 2007, 04:42:27 pm
The send_quote way of getting a random quote is horrible. Try this for a function send_quote instead:

Code: [Select]
function send_quote($qnum)
{ // Start function send_quote()
$strquote = "";
if($qnum == -1)
{
// Get a random quote
$sql = "SELECT * FROM #___quotes ORDER BY RAND() LIMIT 1";
$result = $this -> bot -> db -> select($sql, MYSQL_ASSOC);
if(!empty($result))
{
$strquote = "#" . $result[0]['id'] . " - " . $result[0]['quote'] . " [Contributed by: " . $result[0]['contributor'] . "]";
}
else
{
$strquote = "No quotes exist. Add some!";
}
}
else
{
    //Get the quote with the given $qnum
$sql = "SELECT * FROM #___quotes WHERE id=".$qnum;
$result = $this -> bot -> db -> select($sql, MYSQL_ASSOC);
if (!empty($result))
{
$strquote = "#" . $result[0]['id'] . " - " . $result[0]['quote'] . " [Contributed by: " . $result[0]['contributor'] . "]";
}
else
{
$strquote = "Quote with id of " . $qnum . " not found.";
}         
}
return $strquote;
} // End function send_quote()

Again I don't use this module so this code hasn't been tested.
Title: Re: Quotes!
Post by: Dracutza on March 28, 2008, 03:48:43 am
using temar's 0.4 -> 0.5 support/conversion file, i can get quotes to load, and display but on !quote add test, a new quote is not submitted and an old one is displayed.

On dropping the table, and letting the mod create a new one... !quote add test gets me:

Fatal error: Cannot use string offset as an array in P:\bots\custom\modules\Quotes.php on line 274

last line is 274

      
Code: [Select]
// Get the ID of the highest quote.
$sql = "SELECT id FROM #___quotes ORDER BY id DESC LIMIT 1";
$result = $this -> bot -> db -> select($sql);
$num = intval($result[0][0]);
Title: Re: Quotes!
Post by: Temar on March 28, 2008, 04:25:23 am
the table is empty and there is no check
because its empty it isnt an array but the line is treating it as if it was
Title: Re: Quotes!
Post by: Dracutza on March 28, 2008, 05:48:39 am
ok but what about
bot: !quote add TEST TEST
bot: quote #33 blah blah

attempting to add a quote results in just another quote being displayed and nothing is submitted.  as if the bot and the mod don't get past the whitespace after !quote.
Title: Re: Quotes!
Post by: Dracutza on March 29, 2008, 06:12:29 pm
applied blueeagle's suggestions

bot [2008-03-29 16:08:56]    [TELL]  [INC]   Dracutza: !quote add test!
bot [2008-03-29 16:08:56]    [TELL]  [OUT]   -> Dracutza: No quotes exist. Add some!


Title: Re: Quotes!
Post by: Blueeagle on March 29, 2008, 11:18:09 pm
This module is currently quite broken.

I have got a module for 0.5.x but it's not backwards compatible and unfortunately I do not see myself having time to backport it anytime soon. :(
Title: Re: Quotes!
Post by: Dracutza on March 30, 2008, 08:18:22 am
This module is currently quite broken.

I have got a module for 0.5.x but it's not backwards compatible and unfortunately I do not see myself having time to backport it anytime soon. :(

the one i have works just fine in 4... it's a 0.5 version I am looking for.
Title: Re: Quotes!
Post by: Blueeagle on March 30, 2008, 08:42:42 am
the one i have works just fine in 4... it's a 0.5 version I am looking for.

Oh. I juste assumed you wanted a 0.4-module since you're in the 0.4 module section of the forum..

The following does run on my bot, however I haven't tested it on a non-svn setup so it might not work out of the box.

Title: Re: Quotes!
Post by: Temar on March 30, 2008, 09:13:14 am
did u try running the 0.4 version on your 0.5 bot useing this module too

http://bebot.link/0-5-x-customunofficial-modules/0-4_support-for-latest-0-5/
Title: Re: Quotes!
Post by: Dracutza on March 30, 2008, 05:48:40 pm
did u try running the 0.4 version on your 0.5 bot useing this module too

http://bebot.link/0-5-x-customunofficial-modules/0-4_support-for-latest-0-5/

yes.  it displays old ones, but will not accept additions
Title: Re: Quotes!
Post by: Dracutza on March 30, 2008, 05:57:44 pm

The following does run on my bot, however I haven't tested it on a non-svn setup so it might not work out of the box.



doesn't for me.

it kills aorc when clicking the quote management interface

Quote
bot [2008-03-30 15:55:57]    [TELL]  [INC]   Dracutza: quote add TEST TEST

bot [2008-03-30 15:55:57]    [TELL]  [OUT]   -> Dracutza:  Your quote has been added to the database
bot [2008-03-30 15:55:57]    [TELL]  [OUT]   -> Dracutza: [link]Quote management interface[/link]
bot [2008-03-30 15:56:11]    [PGRP]  [MSG]   [bot] Dracutza: !quote
bot [2008-03-30 15:56:11]    [PGRP]  [MSG]   [bot] bot:  Where were you
 when Dracutza told me: ''?

funny... one version displays but does not accept, the other version accepts but does not display  :P
Title: Re: Quotes!
Post by: Dracutza on March 30, 2008, 07:00:18 pm
funny... one version displays but does not accept, the other version accepts but does not display  :P

actually blueeagles 0.5 version does not really accept new ones either.  In viewing the DB, it creates a record, and records the owner, but the quote is left blank.
Title: Re: Quotes!
Post by: Dracutza on April 03, 2008, 05:38:04 pm
any chance of getting Glara's Quote 100% 0.5 compatible?
Title: Re: Quotes!
Post by: Glarawyn on April 03, 2008, 06:19:29 pm
As a rule, I don't update my custom modules until we hit the release candidate stage of development.

If you want to pay me off in Supple bots or Combined Sharpshooter's armor or other in game loot that would be of interest I would be willing to shift game time to coding time. :)
SimplePortal 2.3.7 © 2008-2024, SimplePortal