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.

smart bot reply

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

smart bot reply

Post by gasak »

can anyone help me creating a script with a smart reply if some one type or action (/me) with specific word and also mention bot name on channel?

Example 1:
<me>/me pokes $botnick
<bot> hey $nick dont ever try to poke me!!

Example 2:
<me>what are you doing $botnick?
<bot>am sleeping dont disturb me

So it has a trigger and response.. But not notice where the $botnick places. As long as the $botnick mention (even in the first word, middle, or last) with specific "word" thats already set on the script, it will reply.

and also if possible i want to include on the response par that the bot will say random nick on channel:

Example 3:
<me>$botnick who is your owner?
<bot>\action point to $random_nick_on_chan

Thanks before for the help :)
Learning Knows No Boundaries!!
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Post by Luminous »

I was bored, see if this works for ya. :)

Code: Select all

bind ctcp * ACTION responses
proc responses {nick host hand chan kw arg} {
    if {[string match -nocase "*pokes ${::botnick}*" $arg]} {
      putserv "PRIVMSG $chan :Don't ever try to poke me! D:"
    }
 return
}

bind pubm * * bot_is_doing
proc bot_is_doing {nick host hand chan text} {
    if {[regexp -nocase -- ".*doing.*${::botnick}.*" [join [lrange [split $text] 0 end]]] || [regexp -nocase -- ".*${::botnick}.*doing.*" [join [lrange [split $text] 0 end]]]} {
      putserv "PRIVMSG $chan :It's am, I am sleeping, please don't disturb me."
    } elseif {[regexp -nocase -- ".*owner.*${::botnick}.*" [join [lrange [split $text] 0 end]]] || [regexp -nocase -- ".*:${::botnick}.*owner.*" [join [lrange [split $text] 0 end]]]
} {
 set nicks [chanlist $chan]
        putserv "PRIVMSG $chan :\001Action points to [lindex $nicks [rand [llength $nicks]]]\001"
    }
}
Note that those regexes are supposed to be on one line :\
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

Thanks Luminous. I made a random text of reply such,

Code: Select all

set PokeText {
  "\001ACTION poke $nick back"
  "\001ACTION punch $nick *bletaakkss*"
  "Dont try to poke $botnick"
  "i'll ask $dest user to poke you back"
}
And to make that work i put set on the proc such,

Code: Select all

set PokeText [string map [list "\$nick" "$nick" "\$dest" "$dest" "\$botnick" "$::botnick"] $PokeText]
It works for a while. I try to poke on the channel and it replace the $nick with my nick. But here comes the eror, when someone else poke the bot again the bot replies with still using my nick instead of the other one nick's that pokes it.

Am i using the wrong set of map list? Please help.

Thanks.
Learning Knows No Boundaries!!
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Post by Luminous »

Well.. whenever I do things like that, I like to use a file to hold the content and then use the "subst -nocommands" command to substitute that stuff automagically. However, this should still work, I've seen people do this before with string map. I think your line is failing because you are trying to apply a list value to string command:

Code: Select all

set PokeText [string map [list "\$nick" "$nick" "\$dest" "$dest" "\$botnick" "$::botnick"] $PokeText]
Bascially, you are passing a list to something that effects a string with this method. Removing that "list" should get better results.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

Hi,

I did remove the list but it doesn't work. Can you give me any example of this substitution?

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

Post by game_over »

try

Code: Select all

set PokeText [string map "\$nick {$nick} \$dest {$dest} \$botnick {$::botnick}" $PokeText]
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

A few remarks,
string map actually expects the first argument (the string mapping definition) to be a valid tcl-list, and the secod argument to be a string. Thus there is nothing wrong with using the list-command as posted.

I do notice that you save the result of the string map operation back to the very same variable, which rather obviously explains why only the first trigger 'sets' the nickname to be used for all further invocations..

Also, this is a no-brainer:

Code: Select all

join [lrange [split $text] 0 end]
It will simply return the same as just using $text.
NML_375
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

game_over wrote:try

Code: Select all

set PokeText [string map "\$nick {$nick} \$dest {$dest} \$botnick {$::botnick}" $PokeText]
hi game_over, i try using it but still not work :(
Learning Knows No Boundaries!!
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Gasak, since I don't have the code you are currently using, here's a proper example on how you would implement the "string map" approach. Implement accordingly in your script..

Code: Select all

set PokeText [list \
  "\001ACTION pokes %nick% back\001" \
  "\001ACTION punches %nick%\001" \
  "Don't try to poke %botnick%"]

bind ctcp - ACTION pokeme
proc pokeme {nick host hand dest key text} {
  if {[string match -nocase "*poke? ${::botnick}*" $text]} {
    set response [lindex $::PokeText [rand [llength $::PokeText]]]
    puthelp "PRIVMSG $chan :[string map [list "%nick%" $nick "%botnick%" $::botnick] $response]"
  }
}
Edit: Forgot the rand-command to pick a random entity from the list..
Last edited by nml375 on Mon Aug 23, 2010 7:52 am, edited 1 time in total.
NML_375
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

Resolved!! Awesome.. It Works nml375.. thanks a lot.. The key point is just put the string map on the puthelp..

Thanks again nml375. You're the man!! :)

And also to Luminous and game_over thanks for all the input.. you are all awesome.. ;)
Learning Knows No Boundaries!!
Post Reply