egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

smart bot reply

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Tue Aug 17, 2010 4:02 am    Post subject: smart bot reply Reply with quote

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 Smile
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Wed Aug 18, 2010 8:43 pm    Post subject: Reply with quote

I was bored, see if this works for ya. Smile

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
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Aug 19, 2010 10:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Fri Aug 20, 2010 10:28 am    Post subject: Reply with quote

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
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Sat Aug 21, 2010 10:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
game_over
Voice


Joined: 26 Apr 2007
Posts: 29

PostPosted: Sun Aug 22, 2010 2:27 am    Post subject: Reply with quote

try
Code:
set PokeText [string map "\$nick {$nick} \$dest {$dest} \$botnick {$::botnick}" $PokeText]
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Aug 22, 2010 9:12 am    Post subject: Reply with quote

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
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Sun Aug 22, 2010 10:59 am    Post subject: Reply with quote

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 Sad
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Aug 22, 2010 12:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Sun Aug 22, 2010 10:15 pm    Post subject: Reply with quote

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!! Smile

And also to Luminous and game_over thanks for all the input.. you are all awesome.. Wink
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber