This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Bot Auto Reesponse

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Bot Auto Reesponse

Post by gasak »

I have this code for auto bot response,

Code: Select all

set crazybib {
"$nick are the real crazy"
}

bind pubm - *v1rus?crazy* pub_crazy

proc pub_crazy {nick uhost handle chan args} {
   global crazybib oldreplytime botnick 
   
   set replytime [unixtime]

   if { $replytime - $oldreplytime  > 7} {
      set crazyline [lindex $crazybib [rand [llength $crazybib]]]
      puthelp "PRIVMSG $chan :$crazyline"
      set oldreplytime $replytime
   }
}

set oldreplytime 0
Theres an error on the $nick coding. when it comes on the channel it should replace the $nick as the nick that talk, but it wasnt. it just keep showing the $nick instead of the real nick.

The next question, how to put coding so that the bot will reply to someone if it mention its name with identical word. Tt is to replace this code:

Code: Select all

bind pubm - *v1rus?crazy* pub_crazy
v1rus is the bot nickname. So i dont have to put the botnick and keep changing the tcl when i change the bot name.


please advice.[/code]
Learning Knows No Boundaries!!
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Re: Bot Auto Reesponse

Post by Luminous »

You can certainly have $nick mean the real $nick and not the literal one. What happens is that set crazybib { creates a list of lines that you can then select from using rand or indexes, etc. However, variables are not valid in them unless you use subst -nocommands. However, I have not had good luck using this command with replies hard coded into the script. Seems to work best from a file for me. But, you could try this and see if it does what you want:

Code: Select all

  set crazyline [subst -nocomands [lindex $crazybib [rand [llength $crazybib]]]


As to the second part.. try creating a var like the following:

Code: Select all

set botn "$::botnick"
bind pubm - "*${botn}?crazy*" pub_crazy
and see if that works.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# you may use $nick or $chan here safely.
set crazybib [list "$nick are the real crazy" "$chan is crazy!!" "more"]
set oldreplytime 0

# check that "craz" begins a word somewhere in the input.
bind pubm - {* craz*} pub_crazy

proc pub_crazy {nick uhost handle chan arg} {
   # if botnick isn't the 1st word, return and do nothing
   if {![string equal -nocase [lindex "[split $arg]" [expr {[lsearch -glob [split $arg] "craz*"] -1}]]] $::botnick]} { return }
   # else, call globals and lets start...
   global crazybib oldreplytime
   set replytime [unixtime]
   if { $replytime - $oldreplytime  > 7} {
      set crazyline [lindex $crazybib [rand [llength $crazybib]]]
      # change $nick or $chan to their variable contents safely and easily.
      set crazyline [string map [list "\$nick" "$nick" "\$chan" "$chan" ] $crazyline]
      puthelp "PRIVMSG $chan :$crazyline"
      set oldreplytime $replytime
   }
}
Last edited by speechles on Tue Aug 10, 2010 5:45 pm, edited 6 times in total.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: Bot Auto Reesponse

Post by speechles »

Luminous wrote:As to the second part.. try creating a var like the following:

Code: Select all

set botn "$::botnick"
bind pubm - "*${botn}?crazy*" pub_crazy
and see if that works.
It would, but it wouldn't. The logic for a bot is to run each script globally at start/restart/rehash. Leaving the bind in global space would cause the bots nickname to then become "stuck" to whatever nickname the bot was using during start/rehash/restart when it first ran that script. To get around this I split up the logic, the bind merely checks for "* craz*" and the procedure makes sure the word before "craz" is the bots nickname or returns.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

speechles wrote:

Code: Select all

# you may use $nick or $chan here safely.
set crazybib [list "$nick are the real crazy" "$chan is crazy!!" "more"]
set oldreplytime 0

# check that "craz" begins a word somewhere in the input.
bind pubm - {* craz*} pub_crazy

proc pub_crazy {nick uhost handle chan arg} {
   # if botnick isn't the 1st word, return and do nothing
   if {![string equal -nocase [lindex "[split $arg]" [expr {[lsearch -glob [split $arg] "craz*"] -1}]]] $::botnick]} { return }
   # else, call globals and lets start...
   global crazybib oldreplytime
   set replytime [unixtime]
   if { $replytime - $oldreplytime  > 7} {
      set crazyline [lindex $crazybib [rand [llength $crazybib]]]
      # change $nick or $chan to their variable contents safely and easily.
      set crazyline [string map [list "\$nick" "$nick" "\$chan" "$chan" ] $crazyline]
      puthelp "PRIVMSG $chan :$crazyline"
      set oldreplytime $replytime
   }
}
Thanks for the response.. i tried those script but its not work. It doesnt event replies any. I try write on channel "v1rus crazy" but nothing happen.

Please advice.
Learning Knows No Boundaries!!
g
game_over
Voice
Posts: 29
Joined: Thu Apr 26, 2007 7:22 am

Post by game_over »

long way

Code: Select all

proc reply {nick} {
set crazybib "
{$nick are the real crazy}
{lol $nick}
"
return [lindex $crazybib [rand [llength $crazybib]]]
}

bind pubm - *$botnick?crazy* pub_crazy

proc pub_crazy {nick uhost handle chan args} {
   global oldreplytime botnick
   set replytime [unixtime]
   if { $replytime - $oldreplytime  > 7} {   
      puthelp "PRIVMSG $chan :[reply $nick]"
      set oldreplytime $replytime
   }
}

set oldreplytime 0
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

gasak wrote:
speechles wrote:

Code: Select all

# you may use $nick or $chan here safely.
set crazybib [list "$nick are the real crazy" "$chan is crazy!!" "more"]
set oldreplytime 0

# check that "craz" begins a word somewhere in the input.
bind pubm - {* craz*} pub_crazy

proc pub_crazy {nick uhost handle chan arg} {
   # if botnick isn't the 1st word, return and do nothing
   if {![string equal -nocase [lindex "[split $arg]" [expr {[lsearch -glob [split $arg] "craz*"] -1}]]] $::botnick]} { return }
   # else, call globals and lets start...
   global crazybib oldreplytime
   set replytime [unixtime]
   if { $replytime - $oldreplytime  > 7} {
      set crazyline [lindex $crazybib [rand [llength $crazybib]]]
      # change $nick or $chan to their variable contents safely and easily.
      set crazyline [string map [list "\$nick" "$nick" "\$chan" "$chan" ] $crazyline]
      puthelp "PRIVMSG $chan :$crazyline"
      set oldreplytime $replytime
   }
}
Thanks for the response.. i tried those script but its not work. It doesnt event replies any. I try write on channel "v1rus crazy" but nothing happen.

Please advice.
Does it load for you?

I tried it, and to get it to load, I had to change:

Code: Select all

set crazybib [list "$nick are the real crazy" "$chan is crazy!!" "more"] 
to

Code: Select all

set crazybib [list "\$nick are the real crazy" "\$chan is crazy!!" "more"]

Also, ... I'm not sure what is meant here:

Code: Select all

if {![string equal -nocase [lindex "[split $arg]" [expr {[lsearch -glob [split $arg] "craz*"] -1}]]] $::botnick]} { return } 
as that line produces errors for me.

To do:
# if botnick isn't the 1st word, return and do nothing
I changed that line to:

Code: Select all

if {![string equal -nocase [lindex [split $arg] 0] $::botnick]} { return}
If you want to experiment with yours, try the above changes.

Also, check back to see what speechles has to say.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Luminous wrote:Also, ... I'm not sure what is meant here:

Code: Select all

if {![string equal -nocase [lindex "[split $arg]" [expr {[lsearch -glob [split $arg] "craz*"] -1}]] $::botnick]} { return }
Let me simplify it.

we start with [split $arg] and apply an lsearch using glob matching for any word (since we split $arg) matching "craz*" .. this will give us the exact position of it within the entire list (of the split $arg, remember). Since this gives us the location of where "craz*" is (and will never error, it was bound on the same thing, it can never be -1...) you need to subtract one from it's place to get the word used in front of it. There you see the -1. This is then applied as the lindex position, of again, splitting $arg. This gives us the _exact_ word used prior. This is then run through a string equal with nocase option compared against the bots present nick ($::botnick). If it doesn't match, we return.

You are correct I didn't do the obvious:

Code: Select all

set crazybib [list {$nick etc} {stuff $chan etc etc} {etc etc}]
Using escapes is needed within the double-quotes I demonstrated that with. But with braces this works without them.

Does that explain it?
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

speechles wrote: ...
This gives us the _exact_ word used prior. This is then run through a string equal with nocase option compared against the bots present nick ($::botnick). If it doesn't match, we return.
...
Does that explain it?
Yes, but I had all that. ... I must be missing something, as I dont' know why we need that.
I thought we just needed to check to see if botnick is the first word, not the first word prior to craz* .
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

willyw wrote:Yes, but I had all that. ... I must be missing something, as I dont' know why we need that.
I thought we just needed to check to see if botnick is the first word, not the first word prior to craz* .

Code: Select all

bind pubm - *v1rus?crazy* pub_crazy
The OP's (original posters) bind, it illustrates this ;)
I went that "extra mile" making it also pick up variants; crazier, craziest, crazyass, crazyfool, crazymotherforker, crazolicious, crazetc...
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

speechles wrote:
willyw wrote: ...

Code: Select all

bind pubm - *v1rus?crazy* pub_crazy
The OP's (original posters) bind, it illustrates this ;)
...
I wasn't sure that was he really intended, even then.

Lately, I was going with the comment in your script:
# if botnick isn't the 1st word, return and do nothing


Hopefully, the OP will be able to get whatever it is that he wants, out of our posts. :)


Thanks
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

Wow.. it works now.. thanks a lot to willyw, game_over, speechles.

May i ask another question?

With the same script, how to make the bot response when someone on channels mention the bot name with an action. For example: /me $botnick crazy or /me punch $botnick then the bot will reply it.

Thanks before
Learning Knows No Boundaries!!
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

Dear All,

i try using game_over script.. it works for this one..

Code: Select all

#---------------------------------------------------------------------
# dodol
#---------------------------------------------------------------------

proc reply {nick} {
set dodolbib "
{lu kata makanan yang dari garut}
{tau deh yang tukang dodol}
{\001ACTION males ladenin orang yg lebih dodol :p}
{yang bilang $::botnick dodol matanya juling}
"
return [lindex $dodolbib [rand [llength $dodolbib]]]
}

bind pubm - *$botnick?dodol* pub_dodol
bind pubm - *dodol*?$botnick* pub_dodol

proc pub_dodol {nick uhost handle chan args} {
   global oldreplytime botnick

   set replytime [unixtime]

   if { $replytime - $oldreplytime  > 7} {   
      puthelp "PRIVMSG $chan :[reply $nick]"
      set oldreplytime $replytime
   }
}

set oldreplytime 0
but when i try to add another different response below it becomes conflict,

Code: Select all

#---------------------------------------------------------------------
# dodol
#---------------------------------------------------------------------

proc reply {nick} {
set dodolbib "
{lu kata makanan yang dari garut}
{tau deh yang tukang dodol}
{\001ACTION males ladenin orang yg lebih dodol :p}
{yang bilang $::botnick dodol matanya juling}
"
return [lindex $dodolbib [rand [llength $dodolbib]]]
}

bind pubm - *$botnick?dodol* pub_dodol
bind pubm - *dodol*?$botnick* pub_dodol

proc pub_dodol {nick uhost handle chan args} {
   global oldreplytime botnick

   set replytime [unixtime]

   if { $replytime - $oldreplytime  > 7} {   
      puthelp "PRIVMSG $chan :[reply $nick]"
      set oldreplytime $replytime
   }
}

set oldreplytime 0

#---------------------------------------------------------------------
# owner
#---------------------------------------------------------------------

proc reply {nick} {
set ownerbib "
{ada deeeehhhhhhhh}
{ganteng deh pokoknya :)}
{\001ACTION tunjuk tunjuk....}
{aduh.. bilang gk yaahh.. hmm.. $::botnick malu akh -_-!!}
"
return [lindex $ownerbib [rand [llength $ownerbib]]]
}

bind pubm - *$botnick?owner* pub_owner
bind pubm - *owner*?$botnick* pub_owner

proc pub_owner {nick uhost handle chan args} {
   global oldreplytime botnick

   set replytime [unixtime]

   if { $replytime - $oldreplytime  > 7} {   
      puthelp "PRIVMSG $chan :[reply $nick]"
      set oldreplytime $replytime
   }
}

set oldreplytime 0
whatever i say on the first response (dodol) it just give me answer for the second response (owner). Even though i say dodol in channel, it just keep answering using "ownerbib" instead of "dodolbib".

Why it is so? Please advice.

For speechles/willyw scripts it just allow the bot response if only the botnick mention at the 1rst word. But with game_over script i can make 2 possibilites weather the botnick mention at the first, middle or even at the last word.

Another advice please :)
Learning Knows No Boundaries!!
Post Reply