| View previous topic :: View next topic |
| Author |
Message |
473X Voice

Joined: 11 May 2007 Posts: 3 Location: Indonesia
|
Posted: Sun May 20, 2007 12:15 pm Post subject: Need help with IDLE.tcl |
|
|
Anyone help me please.
This is an idle TCL, how to make it works into all channel automatically. When I command +idle the idle detection will set ON in channel, then -idle the idle will be set OFF.
| Code: | ## idle DetecteD ##
set timetocheckaway 10
set chanaway "#allchannels"
set idtimer 10
#######TEST#######
if {![info exists {ald}]} {
global botnick chanaway timetocheckaway
set ald 1
timer ${timetocheckaway} printing
}
proc printing {} {
global botnick chanaway timetocheckaway idtimer
putlog "Check away on $chanaway"
if {[botonchan $chanaway] == 1} {
if {[botisop $chanaway]==1} {
foreach user [chanlist $chanaway] {
if {[isbotnick $user] == 0} {
if {[isop $user $chanaway]==0} {
if {[isvoice $user $chanaway] == 1} {
set cekidle [getchanidle $user $chanaway]
if {$cekidle > $idtimer} {
set dodoldah "IdLe.DeteCteD"
pushmode $chanaway -k $dodoldah
pushmode $chanaway -v $user
}
putserv "WHOIS $user $user"
#putlog "testing idle"
}
}
}
}
}
}
timer ${timetocheckaway} printing
}
bind raw - 301 check_away
proc check_away { from keyword arg } {
global chanaway
set awaytext [string range [lrange $arg 2 end] 1 end]
set nickaway [lindex $arg 1]
if {[botonchan $chanaway] == 1} {
if { $awaytext != "" } {
if {[onchan $nickaway $chanaway] == 1} {
if {[matchattr $nickaway f] != 1} {
if {[isvoice $nickaway $chanaway] == 1} {
pushmode $chanaway -v $nickaway
#putlog "tesing idle"
#if {[string match *k* [lindex [split [getchanmode $chanaway]] 0]]} {
set dodoldah "IdLe.DeteCteD"
pushmode $chanaway -k $dodoldah
# }
}
}
}
}
}
}
## idle DetecteD ##
set timetocheckaway 5
set chanaway "#allchannels"
set idtimer 5
#######JANGAN EDIT DI BAWAH INI LINES#######
if {![info exists {ald}]} {
global botnick chanaway timetocheckaway
set ald 1
timer ${timetocheckaway} printing
}
proc printing {} {
global botnick chanaway timetocheckaway idtimer
putlog "Check away on $chanaway"
if {[botonchan $chanaway] == 1} {
if {[botisop $chanaway]==1} {
foreach user [chanlist $chanaway] {
if {[isbotnick $user] == 0} {
if {[isop $user $chanaway]==0} {
if {[isvoice $user $chanaway] == 1} {
set cekidle [getchanidle $user $chanaway]
if {$cekidle > $idtimer} {
set dodoldah "IdLe.DeteCteD"
pushmode $chanaway -k $dodoldah
pushmode $chanaway -v $user
}
putserv "WHOIS $user $user"
#putlog "testing idle"
}
}
}
}
}
}
timer ${timetocheckaway} printing
}
bind raw - 301 check_away
proc check_away { from keyword arg } {
global chanaway
set awaytext [string range [lrange $arg 2 end] 1 end]
set nickaway [lindex $arg 1]
if {[botonchan $chanaway] == 1} {
if { $awaytext != "" } {
if {[onchan $nickaway $chanaway] == 1} {
if {[matchattr $nickaway f] != 1} {
if {[isvoice $nickaway $chanaway] == 1} {
pushmode $chanaway -v $nickaway
#putlog "testing idle $nickaway is away and devoice on $chanaway"
#if {[string match *k* [lindex [split [getchanmode $chanaway]] 0]]} {
set dodoldah "IdLe.DeteCteD"
pushmode $chanaway -k $dodoldah
}
}
}
}
}
}
|
thx for help
 |
|
| Back to top |
|
 |
ZEXEL Halfop

Joined: 27 Jun 2006 Posts: 45
|
Posted: Sun May 20, 2007 11:20 pm Post subject: |
|
|
Please read : Help us to help you before you post! Thx... _________________ .:[ Knowledge Is The Power ]:. |
|
| Back to top |
|
 |
YooHoo Owner

Joined: 13 Feb 2003 Posts: 939 Location: Redwood Coast
|
Posted: Mon May 21, 2007 12:11 am Post subject: |
|
|
learn to properly indent your code, it is way to jumbled looking the way it is right now. You need to set special chanflags, using the setudef command, which, like all commands, can be found in the tcl-commands.doc _________________
Johoho's TCL for beginners
 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon May 21, 2007 12:38 pm Post subject: |
|
|
As I bothered to dig through the code, I noticed you improperly use lindex and lrange in multiple locations, such as this piece:
| Code: | proc check_away { from keyword arg } {
global chanaway
set awaytext [string range [lrange $arg 2 end] 1 end]
set nickaway [lindex $arg 1] |
Since arg is a string here, you can't use neither lindex or lrange without first converting it to a list (check the split-command for this).
Also, you really should considder concatenating your conditionals, ie use if {$a > 1 && $ < 2} { rather than nesting multiple conditionals, and you don't have to set a variable to a value such as this:
| Code: | set cekidle [getchanidle $user $chanaway]
if {$cekidle > $idtimer} { |
This works just aswell: | Code: |
if {[getchanidle $user $chanaway] > $idtimer} { |
As for the original query, do as YooHoo suggests, the implementation should be simple as long as you read through the docs. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
473X Voice

Joined: 11 May 2007 Posts: 3 Location: Indonesia
|
Posted: Wed May 23, 2007 5:09 pm Post subject: Thx |
|
|
thx for help me nml375
ZEXEL always comment but he never help. I think ZEXEL know nothing. ZEXEL cuma banyak tanya aja tapi gak banyak membantu orang (Tong kosong and tukang komen) hahahahaha
 |
|
| Back to top |
|
 |
ZEXEL Halfop

Joined: 27 Jun 2006 Posts: 45
|
Posted: Thu May 24, 2007 10:51 am Post subject: Re: Thx |
|
|
| 473X wrote: | thx for help me nml375
ZEXEL always comment but he never help. I think ZEXEL know nothing. ZEXEL cuma banyak tanya aja tapi gak banyak membantu orang (Tong kosong and tukang komen) hahahahaha
 |
yoyoyo... Think before u post some thread, use the indent so the other can help u!
Read this. Many example script in this forum use indent before they post. We have a rules for help each other. Help us to help u and don't be stupid like a ripper!
Don't comment my self, take a look mirror who you are!  _________________ .:[ Knowledge Is The Power ]:. |
|
| Back to top |
|
 |
|