Currently have the basic on_chat in script for having the bot work in chats.
As it is the bot will attempt to answer everything said in the chat and get flooded or worse, caught in a loop with himself LOL. Any ideas on how to make him only answer certain ones? Perhaps at random? I have already tried a few things to no avail.
I originally tried making it so that you had to say his name first by grabbing the first word in the string and checking to see if it was his name...but this didnt quite work. _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Hmm, Im using Net::AIM actually ...but I see something in your example I can try. Thanks for the speedy reply. I was originally creating a variable with a substring and comparing it to another variable with the bots name _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Just so you don't hafta pick through all the code, here's what does it basicly:
Code:
if ($msg =~ /^$screenname/i || $msg =~ /$screenname$/i) {<br /> # The ^ in the first one means "starts with"<br /> # The $ in the second one means "ends with"<br /><br /> # If it STARTED WITH, cut it off the beginning.<br /> if ($msg =~ /^$screenname/i) {<br /> $msg =~ s/^$screenname //ig; # For spaces<br /> $msg =~ s/^$screenname//ig;<br /> }<br /> # If it ENDED WITH, cut it off the end.<br /> else {<br /> $msg =~ s/$screenname$ //ig; # For spaces<br /> $msg =~ s/$screenname$//ig;<br /> }<br /><br /> # Now you now they were talking to your bot...<br /> # and that the bot's screenname isn't in their<br /> # message any longer. So now you can do what<br /> # you want with their message!<br />}
That's assuming $screenname is your bot's screenname (in lower-case ) _________________ Current Site (2008) http://www.cuvou.com/
Ok..this partially works, but he seems to hold the last response in memory until the next line with this name on the end , IE:
I'll say : hi marznet then i'll say: something else then ill say: something else then i'll say: hello marznet
and he then gives the response to the first line.
when you try it with this name in front , it repeats the same response...continuing to work on it.... _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Well, he did do something similar to that ...so yeah, a small bug...somehow I dont think it would be that noticeable in a busy room though. Thanks for the help! _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Somewhere else perhaps? It doesnt seem to like being in the beginning of the whole thing. Ive fiddled with its placement.
And btw...having him in AOL chats doesnt seem to have the delay bug! Which is cool , go figure lol _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Not sure what Im doing wrong except maybe the order of the ifs and else. _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
You're ONLY getting a reply if the message ends with the screenname. Also, when filtering the end of the screenname, the space should come before it (on the first one).
Put that $reply = thought(); part AFTER the end of the else, i.e.
ARGH...I had it working without the commands and now Ive screwed it up lol _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
And I've discovered commands work too if you put his name on the end of it, but he got caught in a loop with himself...so I'm assuming its because of where the "check if its a command " code is placed. Heres what happened when a command was run with his name on the end:
/insult marznet Marznet: You deflower furniture, you nostril-digging, snot-sniffing, weasel-jumping, belligerent brat of bad days ahead for all of us.! Marznet: Are you sure? Marznet: I haven't heard anything like that before: said I deflower furniture you nostril digging snot sniffing weasel jumping belligerent brat of bad days ahead for all of us. Marznet: Absolutely positive.
He looped...which is weird LOL But again, I think its the placement of the command check. Any ideas? Ive tried it elsewhere with no result. _________________ Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
My bots weirdly enough did that too, even though they technically weren't triggering any code of eachother's.
Maybe try putting this near the top of the handler:
Code:
return 1 if lc($victim) eq "marznet";
That should break out of the handler if the user talking is the bot, and shouldn't process anything else. _________________ Current Site (2008) http://www.cuvou.com/