i have a small script that i'd like to fix up so the trigger command accepts an argument and process the argument as a user in the channel. so far it looks like this:
set ranhng {
"Let me bow down to thee, Oh magnificent $nick! Dom me, use me with your leet skillz, "
"Yay...another HNG...sigh...you bore me already, "
"You know, if you shut up and listen very very carefully...we can hear your mother calling, "
}
bind pub - !hng dork
proc dork {nick uhost hand chan $rand} {
global ranhng
putchan $chan "[lindex $ranhng [rand [llength $ranhng]]]$hand"; return 0
}
when the script is called (!hng blahblah), i only get myself returned as the victim. what would i do to make the insult against a victim instead of who calls the trigger?
proc dork {nick uhost hand chan text} {
global ranhng
set idx [rand [llength $ranhng]]
set line [subst [lindex $ranhng $idx]]
putchan $chan "$line, $nick"
return 0
}
Btw, if you want to write a good script, you should choose meaningful names for commands and variables. "Ranhng" and "dork" just aren't cutting it, I'm afraid
thanks
took me a while of headscratching to figure out that the new line goes inside the proc
what if i was to go a step further and have the script check the current channel people and only react if the target's there? tried reading other people's scripts for ideas/working examples, seems to be a lack of uniformity
proc dork {nick uhost hand chan text} {
global ranhng
if {[lsearch [chanlist $chan $text]] == -1} {return 0}
set nick $text
set idx [rand [llength $ranhng]]
set line [subst [lindex $ranhng $idx]]
putchan $chan "$line, $nick"
return 0
}