caesar wrote:The variables 'from keyword text' are correct. The $chan variable needs to declared before is used, thus why it complains about it can't be read.
Anyway, what you want to accomplish?
I need to use $chan instead of #opers, so it will reply in any channel that me and the bot is in.
bind pub * .whois whois:pub
bind raw - 379 whois:stoner
proc whois:pub {nick uhost hand chan text} {
# we make sure we can access the variable globally
global whoised
# grab the person to whois from the user's input
set user [lindex [split $text] 0]
# store the name of the user and the channel in an array for later use
set whoised($user) $chan
# issue the whois command on the user
putserv "WHOIS $user"
}
proc whois:stoner {from keyword text} {
# globally call the whoised array
global whoised
# if the whoised array doesn't exists we return. better safe than sorry :)
if {![info exists whoised]} return
#grab the user from $text
set nick [lindex [split $text] 0]
# grab the nicks that are stored in whoised array
set names [array names whoised]
# return if $nick doesn't exists in that $names list
if {[lsearch -exact -- $names $nick] == -1} return
# $nick exists in the list, now let's grab the channel where the command to whois him has been issued
set channel $whoised($nick)
# we no longer need $nick in that array so we purge it
array unset whoised $nick
# do whatever you wish with $channel
putserv "PRIVMSG $channel :My Modes are \00310[lrange $text 5 end]\003"
}
I tried to explain all the lines of the code and hope you will understand them all. Anyway, don't be shy and leave a message if you haven't understood something.
Edit: fixed.
Last edited by caesar on Mon Mar 07, 2011 3:51 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
# grab the nicks that are stored in whoised array
set names [array names whoised]
# return if $nick doesn't exists in that $names list
if {![string equal -nocase $nick $names]} return
This can actually cause problems if the nicknames contain special characters. Things might not match since this uses the array names "list" within a "string" command.
# return if $nick doesn't exists in that $names list
if {[lsearch -exact -- $names $nick] == -1} return
Using a "list" command on this "list" will avoid the problems that come with nicknames containing special characters...
Just trying to help avoid scenarios where people mingle string commands on lists and vice versa, as this is what creates exploits. This doesn't create an exploit in this example, but can cause things not to match when they should.
bind raw - 379 whois:stoner
proc whois:stoner {from keyword text} {
# does a channel to send whois info exist?
if {[info exists ::whereWhois]} {
#grab the user from $text
set nick [lindex [split $text] 0]
# is it the bots nick?
if {[isbotnick $nick]} {
# message the whois channel
putserv "PRIVMSG $::whereWhois :My Modes are \00310[join [lrange [split $text] 5 end]]\003"
# no longer need whois channel, discard it
unset ::whereWhois
}
}
bind pub m ".whome" whome
proc whome {nick host handle chan arg} {
# create a global variable, to hold the whois channel
set ::whereWhois $chan
# send the whois
putserv "whois $::botnick"
}
@speechles : was working on another script and guess I mixed stuff around. Thanks for pointing that out.
@Gemster : I've already answered you to that question in the first post, guess you missed that out.
Anyway, raw proc expects 3 arguments: from keyword text. No matter how you name them and as long there are just 3, you would have the same information in each of them.
Like I've said before, you can't get a channel name out of the raw, or at least not like how you want. The whois command on the bot is triggered by a pub command, dcc chat or from where? Be more specific on what you want to do.
# does a channel to send whois info exist?
if {[info exists ::whereWhois]} {
as the chan does exist as i type .whome in that channel.
You do need that, otherwise your procedure will swallow things it shouldn't. You are trapping raws. You will over-ride eggdrops own mechanism to detect things without that check.
The bot is called Stoner and the command is "whois Stoner"
Your bot isn't always called that. It uses alternative nicknames. Also, anytime the bot runs whois on anyone your procedure will take-over. You sound like you don't want help. I should stop.
Im sorry if it seems that i cant read or need help.
Im new to tcl scripting so i like to try to keep things simple.
Id rather have a command or whatever added to my first code so that i can learn from it and understand how it works.
Yes you guys make scripts that work how i need them but they are rather hard for me to understand them, so its a case of useing it but not learning to write it as i dont understand it.
That's almost the same thing we said, meaning you need to store the channel in a global variable in the proc you trigger the whois then use it in the raw proc to do whatever you need.
Even with explaining each line of the code, you still didn't understood much?
Once the game is over, the king and the pawn go back in the same box.
All i was saying it that there were things added that i didnt need and things i didnt understand and yes you both explained them. I guess i learn a different way as i make simple script and get them working then i grow on the scripts making them better when i learn more.