This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Need help with IDLE.tcl

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
473X
Voice
Posts: 3
Joined: Fri May 11, 2007 7:07 pm
Location: Indonesia

Need help with IDLE.tcl

Post by 473X »

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: Select all

## 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
:) :) :)
User avatar
ZEXEL
Halfop
Posts: 45
Joined: Tue Jun 27, 2006 10:47 pm
Contact:

Post by ZEXEL »

Please read : Help us to help you :wink: before you post! Thx...
.:[ Knowledge Is The Power ]:.
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

As I bothered to dig through the code, I noticed you improperly use lindex and lrange in multiple locations, such as this piece:

Code: Select all

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: Select all

set cekidle [getchanidle $user $chanaway]
if {$cekidle > $idtimer} {
This works just aswell:

Code: Select all

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
User avatar
473X
Voice
Posts: 3
Joined: Fri May 11, 2007 7:07 pm
Location: Indonesia

Thx

Post by 473X »

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 :lol:


:twisted: :twisted: :twisted: :twisted:
User avatar
ZEXEL
Halfop
Posts: 45
Joined: Tue Jun 27, 2006 10:47 pm
Contact:

Re: Thx

Post by ZEXEL »

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 :lol:


:twisted: :twisted: :twisted: :twisted:
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! :wink:

Don't comment my self, take a look mirror who you are! :oops:
.:[ Knowledge Is The Power ]:.
Post Reply