Code: Select all
set modeD(channel) "#yourchannel"
bind TIME - "* * * * *" modeD:send:names
bind RAW - 355 modeD:receives:names
bind RAW - 352 modeD:receives:who
proc modeD:send:names { minutes hours days months years } {
global modeD sl_flooded
if {[validchan $modeD(channel)]} {
if {[regexp {D|d} [lindex [getchanmode $modeD(channel)] 0]] &&
$sl_flooded([string tolower $modeD(channel)]) != "1" } {
putquick "NAMES -d $modeD(channel)"
}
}
}
proc modeD:receives:names { from raw args } {
global modeD
set chan [lindex [split $args] 2]
set temp1 [lindex [split $args :] 1]
set temp2 [string range $temp1 0 end-1]
set nicklist "$temp2"
if {[string tolower $chan] == [string tolower $modeD(channel)] && [regexp -nocase {[a-z]|[0-9]} $nicklist]} {
foreach user [split $nicklist] {
puthelp "WHO $user"
}
}
}
proc modeD:receives:who { from raw args } {
global modeD
set identd [lindex [split $args] 2]
set host [lindex [split $args] 3]
set nick [lindex [split $args] 5]
set chan $modeD(channel)
if {![matchban $nick!$identd@$host] && ![matchban $nick!$identd@$host $chan]} {
utimer [rand 8] [list puthelp "PRIVMSG X :voice $chan $nick"]
}
# hidden user appear in ".channel #chan" command and
# stays there even when they parts or disconnect.
resetchan $chan
}
Code: Select all
set modeD(channel) "#yourchan"
bind TIME - "* * * * *" modeD:send:names
bind RAW - 355 modeD:receives:names
bind RAW - 352 modeD:receives:who
proc modeD:send:names { minutes hours days months years } {
global modeD sl_flooded
if {[validchan $modeD(channel)]} {
if {[regexp {D|d} [lindex [getchanmode $modeD(channel)] 0]] &&
$sl_flooded([string tolower $modeD(channel)]) != "1" } {
putquick "NAMES -d $modeD(channel)"
}
}
}
proc modeD:receives:names { from raw text } {
global modeD
set chan [lindex [split $text] 2]
set nicklist [lindex [split $text :] 1]
if {[string tolower $chan] == [string tolower $modeD(channel)] && $nicklist != "" } {
foreach user [split $nicklist] {
puthelp "WHO $user"
}
}
}
proc modeD:receives:who { from raw text } {
global modeD
set identd [lindex [split $text] 2]
set host [lindex [split $text] 3]
set nick [lindex [split $text] 5]
set chan $modeD(channel)
if {![matchban $nick!$identd@$host] && ![matchban $nick!$identd@$host $chan]} {
if {[onchan X $chan]} {
utimer [rand 8] [list puthelp "PRIVMSG X :voice $chan $nick"]
}
}
resetchan $chan
}
Args invokes the interpreter to 'swallow' all the arguments passed to it into a list. This involves encapsulating it all within curly braces {}, using double-quotes "" around the parameter if it contains spaces and escaping any potential tcl special characters. It creates a list by doing as I just explained so that you can have a variable number of arguments invoke your procedure. Your use of [split $args] suggested to me that you misunderstood this. $args is already a list, and splitting it in effect destroys this list and creates a 2nd list. The 2nd list will escape the present curly braces from the first list, and use these in the new list [split] creates (hence you seeing those { and } in odd places). It will also potentially escape escapes and destroy several other things. That is why it is best to avoid using $args ever unless you fully understand the consequences.DarkRaptor wrote:With args, the list end with "}" but not with text. Thanks nml375. I have learned something today
The code he posted using $text and not $args should. But you might want to change this part.samhain wrote:I want it to voice everyone hidden on the channel? will it do the same?
Code: Select all
bind TIME - "* * * * *" modeD:send:names
samhain wrote:I wish I was a coder, so then I would have changed that to something more appropriate, and as I am not a coder, that's why I asked you to change it for me sir. to something appropriate.
In effect, the best this can ever do is bind to time every minute. Polling a /names -d #chan userlist, then checking every single name against a ban, if it isn't banned, if X is on the channel, X will voice it, basically identical to the behavior of using timer, as the best it can do is every minute as well./eggdrop/doc/tcl-commands.doc wrote: (37) TIME (stackable)
bind time <flags> <mask> <proc>
proc-name <minute> <hour> <day> <month> <year>
Description: allows you to schedule procedure calls at certain
times. mask matches 5 space separated integers of the form:
"minute hour day month year". minute, hour, day, month have a
zero padding so they are exactly two characters long; year is
extended to four characters in the same way.
Module: core
Code: Select all
set modeD(channel) "#yourchan"
set modeD(timermin) "10"'
set modeD(timermax) "15"
bind RAW - 355 modeD:receives:names
bind RAW - 352 modeD:receives:who
proc modeD:send:names { } {
global modeD
if {[validchan $modeD(channel)]} {
if {[regexp {D|d} [lindex [getchanmode $modeD(channel)] 0]]} {
putquick "NAMES -d $modeD(channel)"
}
}
utimer [expr $modeD(timermin)+[rand [expr $modeD(timermax)-$modeD(timermin)]]] [list modeD:send:names]
}
proc modeD:receives:names { from raw text } {
global modeD
set chan [lindex [split $text] 2]
set nicklist [lindex [split $text :] 1]
if {[string tolower $chan] == [string tolower $modeD(channel)] && $nicklist != "" } {
foreach user [split $nicklist] {
puthelp "WHO $user"
}
}
}
proc modeD:receives:who { from raw text } {
global modeD
set identd [lindex [split $text] 2]
set host [lindex [split $text] 3]
set nick [lindex [split $text] 5]
set chan $modeD(channel)
if {![matchban $nick!$identd@$host] && ![matchban $nick!$identd@$host $chan]} {
utimer [rand 8] [list puthelp "PRIVMSG X :voice $chan $nick"]
}
# hidden user appear in ".channel #chan" command and
# stays there even when they parts or disconnect.
resetchan $chan
}
utimer [expr $modeD(timermin)+[rand [expr $modeD(timermax)-$modeD(timermin)]]] [list modeD:send:names]