egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help with IDLE.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
473X
Voice


Joined: 11 May 2007
Posts: 3
Location: Indonesia

PostPosted: Sun May 20, 2007 12:15 pm    Post subject: Need help with IDLE.tcl Reply with quote

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
Smile Smile Smile
Back to top
View user's profile Send private message
ZEXEL
Halfop


Joined: 27 Jun 2006
Posts: 45

PostPosted: Sun May 20, 2007 11:20 pm    Post subject: Reply with quote

Please read : Help us to help you Wink before you post! Thx...
_________________
.:[ Knowledge Is The Power ]:.
Back to top
View user's profile Send private message Visit poster's website
YooHoo
Owner


Joined: 13 Feb 2003
Posts: 939
Location: Redwood Coast

PostPosted: Mon May 21, 2007 12:11 am    Post subject: Reply with quote

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
_________________
Mr. Green
Johoho's TCL for beginners
Mr. Green
Back to top
View user's profile Send private message Send e-mail
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon May 21, 2007 12:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
473X
Voice


Joined: 11 May 2007
Posts: 3
Location: Indonesia

PostPosted: Wed May 23, 2007 5:09 pm    Post subject: Thx Reply with quote

thx for help me nml375 Smile
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 Laughing


Twisted Evil Twisted Evil Twisted Evil Twisted Evil
Back to top
View user's profile Send private message
ZEXEL
Halfop


Joined: 27 Jun 2006
Posts: 45

PostPosted: Thu May 24, 2007 10:51 am    Post subject: Re: Thx Reply with quote

473X wrote:
thx for help me nml375 Smile
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 Laughing


Twisted Evil Twisted Evil Twisted Evil Twisted Evil


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! Embarassed
_________________
.:[ Knowledge Is The Power ]:.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber