I have been playing around with a "say and respond" script.. that is, when someone says somethig in the channel, the Bot will respond with a saying or response based on what someone has said...
example:
someone says "test" and the bot responds with a random line of 5 choices...
I have come across a strange issue with this piece of code.. I'll display the code then what I'm experiencing..
First, heres the "Setup" code:
This piece of code reads a file, then loads it into memory.. Code loads ONCE at bot-startup only; 10 seconds in...
Code: Select all
Proc SetVars {} {
if {(![catch {set VarA [open "$MyTPL/BotAI.txt" r]}])} {
set BotAI [read $VarA];
close $VarA;
} else {
set BotAI "";
putlog "\r\nWARNING! - AI Template file not found!\r\n";
};
return 0;
};
we now set a bind:
Code: Select all
bind pubm - * AI;
Code: Select all
proc AI {nick uhost hand chan arg} {
global MyChan botnick BotAI Show Song DJ;
if {(([lsearch -exact [string tolower "#$MyChan"] [string tolower $chan]] != "-1")||("#$MyChan" == "*"))&&(![matchattr $hand b])&&($nick != $botnick)} {
foreach VarA $BotAI {
if {[string match [string tolower [lindex $VarA 0]] [string tolower $arg]]} {
putquick "PRIVMSG #$MyChan :[subst [lindex [lindex $VarA 1] [rand [llength [lindex $VarA 1]]]]]";
};
};
};
return 0;
};
Code: Select all
{ "*test*" { (<-- this is now correctly posted as it appears in the code)
"it works!"
"yessss!"
"awesome!!"
"coool!"
"test successful!"
}}
to me that seems quite, um.. EXCESSIVE!
without it, the bot responds instantly (.2 seconds, if not sooner) but with it, its lagged to about 10 seconds.. and this includes EVERY command and response- even notices and admin commands.. and I mean 10 seconds PER command and/or response!
now, this isn't a high-priority issue.. if anything, I can pitch it altogether and forget it.. but I was wondering, if anything, what I did wrong here?
nml to the rescue??

-DjZ-

