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 

Killtimers timerID...

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


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue May 26, 2015 5:34 am    Post subject: Killtimers timerID... Reply with quote

How to find the timerID from these examples?
1)
Code:
utimer 120 [list putquick [encoding convertfrom utf-8 "PRIVMSG $chan :This is a quick message converted to UTF-8"]]

2)
Code:
timer 3 [list putmsg $chan "Hello world"]

_________________
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks Smile
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Tue May 26, 2015 9:41 am    Post subject: Re: Killtimers timerID... Reply with quote

Play with this.
It is not meant for any actual use. It is just meant to illustrate.

Code:

# May 26, 2015

# http://forum.egghelp.org/viewtopic.php?p=104159&sid=f40235b3e21a35b95678280c8ef33c3f#104159

### this finds only the first instance
bind pub - "!timers" search_timers

proc search_timers {nick uhost handle chan text} {

        putserv "privmsg $chan :timers are: [timers]"
        putserv "privmsg $chan :text is: $text"

        putserv "privmsg $chan :position in list of timers is: [lsearch -index 1 [timers] "*$text*" ] "

        set pos [lsearch -index 1 [timers] "*$text*" ]
        putserv "privmsg $chan :selected timer is: [lindex [timers] $pos]"
        set selected [lindex [timers] $pos]
        putserv "privmsg $chan :timer id is: [lindex $selected 2]"
}


###############
####  this will list all timers that match
bind pub - "!timersagain" find_all_timer_matches

proc find_all_timer_matches {nick uhost handle chan text} {

        putserv "privmsg $chan :timers are: [timers]"
        putserv "privmsg $chan :text is: $text"

        set pos "[lsearch -index 1 -all [timers] "*$text*" ]"
        putserv "privmsg $chan :selected timers are in these positions : $pos "

        foreach num $pos {
                putserv "privmsg $chan :timer is: [lindex [timers] $num]"
        }

        foreach num $pos {
                putserv "privmsg $chan :timerid is: [lindex [timers] $num 2]"
        }
}



Reference:
http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
and
http://www.tcl.tk/man/tcl8.6/TclCmd/lindex.htm
and
http://www.tcl.tk/man/tcl8.6/TclCmd/lsearch.htm
You may wish to experiment with the -nocase switch.

I hope this helps.
_________________
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Tue May 26, 2015 10:32 am    Post subject: Reply with quote

Also, if you expect to need the timer id often, store it in a variable when you set the timer...
Code:
set utimerid [utimer 120 [list putquick [encoding convertfrom utf-8 "PRIVMSG $chan :This is a quick message converted to UTF-8"]]]

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue May 26, 2015 4:15 pm    Post subject: Reply with quote

SpiKe^^ wrote:
Also, if you expect to need the timer id often, store it in a variable when you set the timer...
Code:
set utimerid [utimer 120 [list putquick [encoding convertfrom utf-8 "PRIVMSG $chan :This is a quick message converted to UTF-8"]]]


Thanks to the contribution willyw.
I liked the idea of SpiKe^^ to keep the timerID in a variable, I tried it and it works perfect.
Thank you both. Very Happy
_________________
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks Smile
Back to top
View user's profile Send private message
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