| View previous topic :: View next topic |
| Author |
Message |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Tue Aug 17, 2010 4:02 am Post subject: smart bot reply |
|
|
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!! |
|
| Back to top |
|
 |
Luminous Op
Joined: 12 Feb 2010 Posts: 146
|
Posted: Wed Aug 18, 2010 8:43 pm Post subject: |
|
|
I was bored, see if this works for ya.
| Code: | 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 :\ |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Thu Aug 19, 2010 10:28 pm Post subject: |
|
|
Thanks Luminous. I made a random text of reply such,
| Code: | 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: | | 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!! |
|
| Back to top |
|
 |
Luminous Op
Joined: 12 Feb 2010 Posts: 146
|
Posted: Fri Aug 20, 2010 10:28 am Post subject: |
|
|
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: | | 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. |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Sat Aug 21, 2010 10:58 pm Post subject: |
|
|
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!! |
|
| Back to top |
|
 |
game_over Voice
Joined: 26 Apr 2007 Posts: 29
|
Posted: Sun Aug 22, 2010 2:27 am Post subject: |
|
|
try
| Code: | | set PokeText [string map "\$nick {$nick} \$dest {$dest} \$botnick {$::botnick}" $PokeText] |
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Aug 22, 2010 9:12 am Post subject: |
|
|
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: | | join [lrange [split $text] 0 end] |
It will simply return the same as just using $text. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Sun Aug 22, 2010 10:59 am Post subject: |
|
|
| game_over wrote: | try
| Code: | | 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!! |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Aug 22, 2010 12:23 pm Post subject: |
|
|
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: | 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.. _________________ NML_375, idling at #eggdrop@IrcNET
Last edited by nml375 on Mon Aug 23, 2010 7:52 am; edited 1 time in total |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Sun Aug 22, 2010 10:15 pm Post subject: |
|
|
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!! |
|
| Back to top |
|
 |
|