| View previous topic :: View next topic |
| Author |
Message |
neoclust Halfop
Joined: 14 Aug 2009 Posts: 55
|
Posted: Sun Aug 16, 2009 2:09 pm Post subject: Avoid dupplication of timer |
|
|
I want to apply a method to avoid duplication of timers, thanks
| Code: | proc Channel:check {from kw text} {
global botnick
set chan [lindex $text 1]
set host [lindex $text 2]@[lindex $text 3]
set nick [lindex $text 5]
set flag [lindex $text 6]
if {[string index $flag 1] == ""} {
if {![channel get $chan autovoice]} { return 0 }
if {![botisop $chan]} { return 0 }
if {$nick != $botnick} {
if {[string length [set t [utimerexists procname]]]} { killutimer $t }
if {![string match ~* $host ]} {
puthelp "NOTICE $nick :Welcome."
utimer 10 "pushmode $chan +v $nick"
}
switch -glob -- $host {*.dynamic.jazztel.es
{puthelp "NOTICE $nick :Welcome."; utimer 10 "pushmode $chan +v $nick" }
~*@* { puthelp "NOTICE $nick :Welcome."; utimer 30 "pushmode $chan +v $nick" }
}
return 0 }
}
}
|
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Aug 16, 2009 2:20 pm Post subject: |
|
|
| Code: | proc Channel:check {from kw text} {
global botnick vtimers
set chan [lindex $text 1]
set host [lindex $text 2]@[lindex $text 3]
set nick [lindex $text 5]
set flag [lindex $text 6]
if {[string index $flag 1] == ""} {
if {![channel get $chan autovoice]} { return 0 }
if {![botisop $chan]} { return 0 }
if {$nick != $botnick} {
if {[string length [set t [utimerexists procname]]]} { killutimer $t }
if {![string match ~* $host ] && ![info exists vtimers($nick:$chan)} {
puthelp "NOTICE $nick :Welcome."
set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]]
}
switch -glob -- $host {*.dynamic.jazztel.es
{puthelp "NOTICE $nick :Welcome."; utimer 10 "pushmode $chan +v $nick" }
~*@* { puthelp "NOTICE $nick :Welcome."; utimer 30 "pushmode $chan +v $nick" }
}
return 0 }
}
}
proc voice:nick {chan nick} {
global vtimers
pushmode $chan +v $nick
unset vtimers($nick:$chan)
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
neoclust Halfop
Joined: 14 Aug 2009 Posts: 55
|
Posted: Sun Aug 16, 2009 2:38 pm Post subject: |
|
|
There is an ']' missing in this line: | Quote: | | if {![string match ~* $host ] && ![info exists vtimers($nick:$chan)]} { |
and it must also apply this line | Quote: | | set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]] | in switch
| Code: | proc Channel:check {from kw text} {
global botnick vtimers
set chan [lindex $text 1]
set host [lindex $text 2]@[lindex $text 3]
set nick [lindex $text 5]
set flag [lindex $text 6]
if {[string index $flag 1] == ""} {
if {![channel get $chan autovoice]} { return 0 }
if {![botisop $chan]} { return 0 }
if {$nick != $botnick} {
if {[string length [set t [utimerexists Channel:check]]]} { killutimer $t }
if {![string match ~* $host ] && ![info exists vtimers($nick:$chan)]} {
puthelp "NOTICE $nick :Welcome."
set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]]
}
switch -glob -- $host {*.dynamic.jazztel.es
{puthelp "NOTICE $nick :Welcome."; set vtimers($nick:$chan) [utimer 10 [list voice:nick $chan $nick]] }
~*@* { puthelp "NOTICE $nick :Welcome."; set vtimers($nick:$chan) [utimer 30 [list voice:nick $chan $nick]] }
}
return 0 }
}
}
proc voice:nick {chan nick} {
global vtimers
pushmode $chan +v $nick
unset vtimers($nick:$chan)
}
|
Last edited by neoclust on Sun Aug 16, 2009 2:57 pm; edited 1 time in total |
|
| Back to top |
|
 |
neoclust Halfop
Joined: 14 Aug 2009 Posts: 55
|
Posted: Sun Aug 16, 2009 2:45 pm Post subject: |
|
|
the bot sends several notice before voice, there is a way to limit this set, for example at the beginning if the nick is already handled by the timer it must pass a return 0
and i have this error : | Quote: | | can't unset "vtimers(neoclust:#chan)": no such variable |
| Quote: | [19:40:00] -Egg- Welcome.
[19:40:12] -Egg- Welcome.
[19:40:26] *** Egg sets mode: +v neoclust
[19:40:29] -Egg- Welcome.
| [/quote] |
|
| Back to top |
|
 |
TCL_no_TK Owner

Joined: 25 Aug 2006 Posts: 509 Location: England, Yorkshire
|
Posted: Mon Aug 17, 2009 4:56 am Post subject: |
|
|
sud only allow the bot to send out the "Welcome" message to a nickname once a day.
it looks like this is a raw event, in which case i doubt you'd be wanting to return 1
| Code: | proc Channel:check {from kw text} {
global botnick
set chan [lindex $text 1]
set host [lindex $text 2]@[lindex $text 3]
set nick [lindex $text 5]
set flag [lindex $text 6]
if {[string index $flag 1] == ""} {
if {![channel get $chan autovoice]} {
return
}
if {![botisop $chan]} {
return
}
if {$nick != $botnick} {
if {[string length [set t [utimerexists procname]]]} { killutimer $t }
switch -glob -- $host {
*.dynamic.jazztel.es {
Channel:check:welcome $nick
utimer 10 [list pushmode $chan +v $nick]
}
~*@* {
Channel:check:welcome $nick
utimer 30 [list pushmode $chan +v $nick]
}
default {
Channel:check:welcome $nick
utimer 10 [list pushmode $chan +v $nick]
}
}
return }
}
}
proc Channel:check:welcome {nick} {
global cc_tmp
if {![info exists cc_tmp($nick)]} {
set cc_tmp($nick) [clock seconds]
puthelp "NOTICE $nick :Welcome"
return
} elseif {[string equal [clock scan "yesterday"] $cc_tmp($nick)]} {
set cc_tmp($nick) [clock seconds]
puthelp "NOTICE $nick :Welcome"
return
} else {
return
}
} |
_________________ TCL the misunderstood |
|
| Back to top |
|
 |
neoclust Halfop
Joined: 14 Aug 2009 Posts: 55
|
Posted: Mon Aug 17, 2009 8:54 am Post subject: |
|
|
| Thank TCL_no_TK & Sir_Fz it work |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Aug 17, 2009 2:21 pm Post subject: |
|
|
You might want to [split $text] before applying [lindex] on it. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|