User Control Panel
Advertisements

HELP US, HELP YOU!

Chats
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions
View unanswered posts
Author Message
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Mon Apr 26, 2004 8:16 pm    Post subject: Reply with quote

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
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Mon Apr 26, 2004 8:27 pm    Post subject: Reply with quote

Yeah... my bot looks for its own screenname to be said at the beginning, or end, but never in the middle.

My bot uses Net::OSCAR, so if your bot uses Net::OSCAR you can look off this code to see how it works:
Code:
#              ::.                   .:.<br />#               .;;:  ..:::::::.  .,;:<br />#                 ii;,,::.....::,;;i:<br />#               .,;ii:          :ii;;:<br />#             .;, ,iii.         iii: .;,<br />#            ,;  ;iii.         iii;   :;.<br /># .         ,,   ,iii,         ;iii;   ,;<br />#  ::       i  :;iii;    ;.    .;iii;.  ,,      .:;<br />#   .,;,,,,;iiiiii;:     ,ii:     :;iiii;;i:::,,;:<br />#     .:,;iii;;;,.     ;iiii:      :,;iiiiii;,:<br />#          :;        .:,,:..:,,.        .:;..<br />#           i.                  .        ,:<br />#           :;.         ..:...          ,;<br />#            ,;.    .,;iiiiiiii;:.     ,,<br />#             .;,  :iiiii;;;;iiiii,  :;:<br />#                ,iii,:        .,ii;;.<br />#                ,ii,,,,:::::::,,,;i;<br />#               ;;.   ...:.:..   ;i<br />#               ;:                :;<br />#                .:                ..<br />#                 ,                :<br /># AIM Handler: aim_chat_im_in<br /># Description: Handles incoming chat messages.<br /><br />sub aim_chat_im_in {<br />   # Get variables from the server.<br />   my ($aim,$client,$chat,$msg) = @_;<br /><br />   my $screenname = $aim->screenname();<br />   $screenname = lc($screenname);<br />   $screenname =~ s/ //g;<br />   my $time = localtime();<br /><br />   # Format the client's screenname.<br />   $client = lc($client);<br />   $client =~ s/ //g;<br /><br />   # Get the room name.<br />   my $room = $chat->name();<br />   my $lr = lc($room);<br />   $lr =~ s/ //g;<br /><br />   # Make sure we aren't them.<br />   my $sn = $screenname;<br />   $sn = lc($sn);<br />   $sn =~ s/ //g;<br /><br />   if ($client ne $sn) {<br />  # Format the message for HTML.<br />  $msg =~ s/<(.|\n)+?>//g;<br /><br />  # See if they're talking directly to the bot.<br />  if ($msg =~ /^$sn/i || $msg =~ /$sn$/i) {<br />     if ($msg =~ /^$sn/i) {<br />    $msg =~ s/$sn //ig;<br />    $msg =~ s/$sn//ig;<br />     }<br />     if ($msg =~ /^$sn/i) {<br />    $msg =~ s/ $sn//ig;<br />    $msg =~ s/$sn//ig;<br />     }<br /><br />     # Save an original copy.<br />     my $omsg = $msg;<br /><br />     # See if this is a "built-in" chat command.<br />     if ($msg eq "leave") {<br />    # If they have the power to...<br />    my $chatdepart;<br />    if ($chaos->{$screenname}->{_chats}->{$lr}->{leave} == 1) {<br />       if (isAdmin($client,"AIM")) {<br />      # Leave the chatroom.<br />      $chatdepart = "<body bgcolor=\"black\">"<br />         . "<font face=\"Verdana\" size=\"2\" color=\"\#FFFF00\">"<br />         . "Good-bye, room! :-(</font></body>";<br />      sleep(2);<br />      $aim->chat_send ($chat, $chatdepart);<br />      sleep(2);<br />      $chat->part();<br />      return 1;<br />       }<br />       else {<br />      $chatdepart = "<body bgcolor=\"black\">"<br />         . "<font face=\"Verdana\" size=\"2\" color=\"\#FFFF00\">"<br />         . "This room is reserved and only an Admin can "<br />         . "banish me from it.</font></body>";<br />      sleep(2);<br />      $aim->chat_send ($chat, $chatdepart);<br />      return 1;<br />       }<br />    }<br />    else {<br />       # Leave the chatroom.<br />       $chatdepart = "<body bgcolor=\"black\">"<br />      . "<font face=\"Verdana\" size=\"2\" color=\"\#FFFF00\">"<br />      . "Good-bye, room! :-(</font></body>";<br />       sleep(2);<br />       $aim->chat_send ($chat, $chatdepart);<br />       sleep(2);<br />       $chat->part();<br />       return 1;<br />    }<br />     }<br />     elsif ($msg =~ /^topic/i) {<br />    # Setting/Viewing the topic.<br />    my ($void,$nt) = split(/\s+/, $msg, 2);<br /><br />    my $topicr;<br /><br />    if (length $nt > 0) {<br />       if (isAdmin($client,"AIM")) {<br />      $chaos->{_data}->{aim}->{chats}->{$lr}->{topic} = $nt;<br /><br />      $topicr = "<body bgcolor=\"black\">"<br />         . "<font face=\"Verdana\" size=\"2\" color=\"\#00FF00\">"<br />         . "I have updated the chat topic.</font></body>";<br />      sleep(2);<br />      $aim->chat_send ($chat, $topicr);<br />       }<br />       else {<br />      $topicr = "<body bgcolor=\"black\">"<br />         . "<font face=\"Verdana\" size=\"2\" color=\"\#00FF00\">"<br />         . "Only an Admin can change the topic here.</font></body>";<br />      sleep(2);<br />      $aim->chat_send ($chat, $topicr);<br />       }<br />    }<br />    else {<br />       $topicr = "<body bgcolor=\"black\">"<br />      . "<font face=\"Verdana\" size=\"2\" color=\"\#00FF00\">"<br />      . "The current topic is: "<br />      . "$chaos->{_data}->{aim}->{chats}->{$lr}->{topic}</font></body>";<br />       sleep(2);<br />       $aim->chat_send ($chat, $topicr);<br />    }<br />    return 1;<br />     }<br /><br />     # Send this to the input handler.<br />     my $reply = on_im ($aim,$screenname,$client,$msg,$omsg,"AIM");<br /><br />     # See if they're muted.<br />     if ($chaos->{_users}->{$client}->{mute} == 0) {<br />    # Send this reply if the these conditions aren't met.<br />    if ($reply ne "<notcommand>" && $reply ne "<noreply>" && $reply ne "<blocked>") {<br />       # Sleep a bit and then send.<br />       sleep (3);<br />       $aim->chat_send ($chat, $reply, 1);<br />    }<br />     }<br />     else {<br />    $reply = "noreply (muted)";<br />     }<br />  }<br />  else {<br />     print "$time\n"<br />    . "<From Chat: $room>\n"<br />    . "[$client] $msg\n\n";<br />  }<br />   }<br />}<br />1;

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Mon Apr 26, 2004 8:32 pm    Post subject: Reply with quote

Hmm, Im using Net::AIM actually ...but I see something in your example I can try. Thanks for the speedy reply. Wink 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
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Mon Apr 26, 2004 8:37 pm    Post subject: Reply with quote

Yeah . . .

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 Razz)

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Mon Apr 26, 2004 10:16 pm    Post subject: Reply with quote

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
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Mon Apr 26, 2004 10:26 pm    Post subject: Reply with quote

That was a glitch that's always been in Net::AIM. I don't know if Net::OSCAR has it, never really tested it. But here would be an example...

Quote:
Kirsle: brb
AiChaos: Hey AzulianBot
AzulianBot: Hello there Kirsle!

(it would think of the last person who talked as the one sending the message, not the actual one who sent the message).

ChaosKeeperZero: hey
Kirsle: azulianbot leave
AzulianBot: You cannot make me leave, ChaosKeeperZero![
Kirsle: azulianbot leave
AzulianBot: Alright Kirsle, I'm outta here!


Anyway... just a small bug. Razz

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Mon Apr 26, 2004 11:40 pm    Post subject: Reply with quote

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! Wink
_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Apr 27, 2004 2:21 am    Post subject: Reply with quote

Alrighty, got it working. He will now answer any messages with his name on the beginning or end...but cant seem to get commands to work?

Ive currently got it like this in the block after the else

Code:
 }<br /><br /> if ($user !~ /^$sn$/i) {<br />   ($isacommand,$reply) = commands($victim,$msg);<br /><br />           if ($isacommand != 1) {<br />         $reply = thought();<br />}<br />


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
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Apr 27, 2004 1:08 pm    Post subject: Reply with quote

Here's an idea: make it reply to commands like normal, but if it's not a command it would look for its own name.

Code:
# Undef the reply (WiredBots always uses global variables, bad practice)<br />$reply = "";<br /><br />($isacommand,$reply) = commands ($victim,$msg);<br /><br />if ($isacommand != 1) {<br />   # see if msg starts or ends w/ name<br />   if ($msg =~ /^$sn$/i) {<br />      # do stuff here...<br />   }<br />}<br /><br />if (length $reply > 0) {<br />   $self->chat_send ($id,$reply); # or whatever the command is<br />}

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Apr 27, 2004 8:08 pm    Post subject: Reply with quote

Ok...as this script is below, he doesnt say anything at all.

Code:
sub on_chat_in {<br />  my ($self, $evt) = @_;<br />  my ($id, $user, $whisper, $msg) = @{$evt->args()};<br />  $msg =~ s/<(.|\n)+>//g;<br />  $sn = $screenname;<br />  $sn =~ s/\s//g;<br />  $user =~ s/\s//g;<br /><br />  $reply = "";<br /><br />($isacommand,$reply) = commands ($victim,$msg);<br /><br />if ($isacommand != 1) {<br />  <br /><br />     if ($msg =~ /^$sn/i || $msg =~ /$sn$/i) {<br /><br /><br />  if ($msg =~ /^$sn/i) {<br />     $msg =~ s/^$sn //ig;<br />     $msg =~ s/^$sn//ig;<br />  }<br /><br />  else {<br />     $msg =~ s/$sn$ //ig;<br />     $msg =~ s/$sn$//ig;<br />     $reply = thought();<br />  }<br /><br />}<br /><br />log_im($user,$msg,$sn,$reply,1);<br />sleep(dosleep(1,3));<br /><br /> if (length $reply > 0) {<br />  $self->chat_send ($id,$reply);<br />}<br /> print  " done.\n\n";<br /> }<br /> }<br />1;


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
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Apr 27, 2004 8:11 pm    Post subject: Reply with quote

As it is this way, he works, but no commands:

Code:
sub on_chat_in {<br />  my ($self, $evt) = @_;<br />  my ($id, $user, $whisper, $msg) = @{$evt->args()};<br />  $msg =~ s/<(.|\n)+>//g;<br />  $sn = $screenname;<br />  $sn =~ s/\s//g;<br />  $user =~ s/\s//g;<br />if ($msg =~ /^$sn/i || $msg =~ /$sn$/i) {<br /><br />  if ($msg =~ /^$sn/i) {<br />     $msg =~ s/^$sn //ig;  <br />     $msg =~ s/^$sn//ig;<br />  }<br /><br />  else {<br />     $msg =~ s/$sn$ //ig;  <br />     $msg =~ s/$sn$//ig;<br />  }<br /><br /> if ($user !~ /^$sn$/i) {<br />   ($isacommand,$reply) = commands($victim,$msg);<br /><br />           if ($isacommand != 1) {<br />         $reply = thought();<br />}<br />log_im($user,$msg,$sn,$reply,1);<br />sleep(dosleep(1,3));<br /><br /> $self->chat_send($id, $reply);<br /> print  " done.\n\n";<br /> }<br />}<br />}<br />1;

_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Apr 27, 2004 8:30 pm    Post subject: Reply with quote

I know why the first one don't work:

Quote:
if ($msg =~ /^$sn/i) {
    $msg =~ s/^$sn //ig;
    $msg =~ s/^$sn//ig;
}

else {
    $msg =~ s/$sn$ //ig;
    $msg =~ s/$sn$//ig;
    $reply = thought();
}


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.
Code:
 if ($msg =~ /^$sn/i) {<br />    $msg =~ s/^$sn //ig;<br />    $msg =~ s/^$sn//ig;<br /> }<br /><br /> else {<br />    $msg =~ s/$sn$ //ig;<br />    $msg =~ s/$sn$//ig;<br /> }<br /> $reply = thought();

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Apr 27, 2004 8:31 pm    Post subject: Reply with quote

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
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Tue Apr 27, 2004 9:16 pm    Post subject: Reply with quote

Ok....this works for chat :



Code:
sub on_chat_in {<br />  my ($self, $evt) = @_;<br />  my ($id, $user, $whisper, $msg) = @{$evt->args()};<br />  $msg =~ s/<(.|\n)+?>//g;<br />  $sn = $screenname;<br />  $sn =~ s/\s//g;<br />  $user =~ s/\s//g;<br />  if ($msg =~ /^$sn/i || $msg =~ /$sn$/i) {<br />  <br />  if ($msg =~ /^$sn/i) {<br />     $msg =~ s/^$sn //ig; # For spaces<br />     $msg =~ s/^$sn//ig;<br />  }<br />  <br />  else {<br />     $msg =~ s/$sn$ //ig;  <br />     $msg =~ s/$sn$//ig;<br />  }<br /><br /> if ($user !~ /^$sn$/i) {<br />   ($isacommand,$reply) = commands($victim,$msg);<br /><br />           if ($isacommand != 1) {<br />#custom code<br />$reply = thought();<br />#end custom code<br />}<br /><br />log_im($user,$msg,$sn,$reply,1);<br />sleep(dosleep(1,3));<br /><br /> $self->chat_send($id, $reply);<br /> print  " done.\n\n";<br /> }<br />}<br />}<br />1;


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
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Apr 27, 2004 10:35 pm    Post subject: Reply with quote

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/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group