BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: Glarawyn on July 24, 2006, 09:44:04 pm
-
I took Sabkor's Quotes module (http://bebot.link/index.php/topic,247.0.html), and implemeted most (if not all, I don't remember) of the fixes mentioned, plus added some extra functionality.
Download: Quotes_1.5.1.zip (http://zibby.isa-geek.net/bebot/Quotes/Quotes_1.5.1.zip)
Also I made some other changes and added some functionality. :)
- Added Automatic Quote "spam" feature. Will output a random quote to gc|pgroup|both on a set interval if enabled.
- Changed VARCHAR to TEXT to facilitate searching of quotes
- Added process_command() to remove redundant code.
- Added load_settings, change_setting, show_settings to deal with settings related to quote spam.
- Added cron(), and connect() functions to enable quote spam feature.
- Modified add_quote() function to use addslashes() instead of str_replace() when inserting into database.
- Added a FULLTEXT MySQL index to assist with searching the Quotes table.
- Added upgrade_table() to automatically add the FULLTEXT index to users of previous module versions.
- Added search_quotes() function that searches the quotes table.
To configure the quote spammer, /tell yourbot !quotes set. Everything can be configured through the settings window.
To search the quotes, just do !quotes <search string>. If there is only one result, the quote will just be displayed. If there are multiple results, you will get a text window with the results and a 72 character preview of the quote.
-
http://zibby.isa-geek.net/bebot/Quotes/Quotes_1.0.1.zip
-jj-
-
Whoops, thanks :D
-
good job :D
-
Updated to add searching of the quotes table.
-
Have following error:-
ERROR 1214 (HY000): The used table type doesn't support FULLTEXT indexes
id(int,11,not null)
quote(text,null)
contributor(varchar(15),null)
Cheers,
-jj-
-
Have following error:-
ERROR 1214 (HY000): The used table type doesn't support FULLTEXT indexes
Do you have MySQL configured to use a storage engine besides MyISAM by default? That's the only cause I can come up with unless you're running a version of earlier than 3.23.23. :)
You could try:
mysqldump -u user -p dbname --tables quotes > quotes-backup.sql
(Always backup your data when you're about to do something that could destroy your data.)
ALTER TABLE quotes ENGINE = MYISAM;
ALTER TABLE quotes ADD FULLTEXT(quote,contributor);
Otherwise around L253 you can find where I'm switching between doing a LIKE query (for a search term of 1 to 3 characters.) and a FULLTEXT search. If you remove the FULLTEXT search SQL you can stick to just a LIKE query, but you'll loose the flexibility and reverence sorting that comes with a FULLTEXT index search.
-
Fixed, thanks for support (DB engine type was wrong)!
Cheers,
-jj-
-
Updated again. Found and fixed a typo, also changed full text searching to bolean mode. You can now (optionally) use the boolean operators from http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html in your searches.
-
Forgot to mention that you can also show only the quotes submitted by a character by doing !quotes by <character> (!quotes by Glarawyn.)
-
Even with the table set correctly to MyISAM I still got the same error as JJ. To fix this issue in a default installation of MySQL 5 on the MS Windows OS you need to go to:
c:\program files\mysql\mysql server 5.0\ and edit the my.ini file and change the line:
"default-storage-engine=innodb"
to
"default-storage-engine=myisam"
Then restart the mysql service.
Cheers :D
-
Nice tip, thank you :-)
-jj-
-
Converted module to use Glara's new module settings plugin (http://bebot.link/index.php/topic,607.0.html) for all settings options.
No other changes.
http://www.jjones.co.uk/files/quotes.php
-jj-
-
Getting
Fatal error: Cannot use string offset as an array in F:\Tvbot\Bebot_v0.2.11\modules\quotes.php on line 210
Any ideas?
-
You might get that in php5 if you don't have any quotes in your db. If you don't, add one then try.
-
You might get that in php5 if you don't have any quotes in your db. If you don't, add one then try.
Looking at the code, the only way you could get this message is if you tried to delete a quote when you had no quotes in the database.
Possible Fix: Replace Lines 206-210 with the following code:
} else {
$res = $this -> bot -> db -> select("SELECT id FROM quotes ORDER BY id DESC");
if (empty($res))
{
$out = " No quotes exisit in the database.";
}
else
{
$out = " (Highest quote ID is " . $res[0][0] . ".)";
}
$reply = "Quote with id of " . $qnum . " not found. (Highest quote ID is " . $out . ".)";
}
-
If he was using your original quotes module yes. But I assumed he was referring to JJ's updated version posted just before, which 210 refers to this section:
function send_quote($qnum)
{
$strquote = "";
if($qnum == -1)
{
$num = $this -> bot -> db -> select("SELECT id FROM quotes ORDER BY id DESC");
$result = $this -> bot -> db -> select("SELECT * FROM quotes");
if($num[0][0] > 0) <--- line 210
-
Yah, i'd suspect its due to auto spam being turned on by default and no quotes in db with php5.
-jj-
-
I'll try it again but i thought I'd turned autospam off (it was the first thing i thought might be a problem).
and yes it was the updated one from JJ
EDIT: Ok tested it seems to be that it is the no quotes in the DB problem. But tried useing !settings quotes auto off (using the page from !settings quotes) to turn off the spam... and it continued to spam.
-
Try changing line 210 from:
if($num[0][0] > 0)
To:
if (!empty($num))
This SHOULD fix the string offset crash (PHP5 h8).
I tried the !settings and it works perfectly fine here - please make sure you are using the last Module Settings plugin (2.03) at the following link:
http://bebot.link/index.php/topic,607.0.html
Please let me know outcome and I'll update the plugin after work. I'll also set it to default to spam off for new users.
Cheers,
-jj-
-
Sorry for the late reply.
Also I'm using the lates Settings module. When I put the quotes module back in (took out the _) the spam is set to off(probably left over from last time it was in) and is still spamming..
With the changes to the php file you suggested... I get "[Terminal Velocity] Tvbot: No quotes exist. Add some!" in org chat for the spam. and !quotes works ok (in both tells and gc).
So looks like the only problem atm is the spamming when its set to not spam.