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 to add a timer into this code..

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

need to add a timer into this code..

Post by heartbroken »

hi

i have a code .this code post trigger in channel with a trigger.reads subject in a .txt file which i've edited. but i want that bot post trigger line by line with timing .

i type !trigger bot will begin to post line-1 and two minutes later bot'll post line-2 -2 minutes later post line-3 ...

so how i can add timing into this code ? thnx.

Code: Select all

if { [llength $arg] < 2 } {
if { [isop $nick $chan] || [ishalfop $nick $chan] ||[isvoice $nick $chan] } {
set way "PRIVMSG $chan :\001ACTION"
set notice 0
} else {
set way "NOTICE $nick :$nick:"
set notice 1
}
} else {
if { [onchan [lindex $arg 1] $chan] && ( [isop $nick $chan] || [ishalfop $nick $chan] || [isvoice $nick $chan] ) } {
if { [lindex $arg 2]=="c" } {
set way "PRIVMSG $chan :\001ACTION [lindex $arg 1]"
set notice 3
} elseif { [lindex $arg 2]=="p" } {
set way "PRIVMSG [lindex $arg 1] :"
set notice 2
} else {
set way "NOTICE [lindex $arg 1] :$nick:"
set notice 1
}
} else {
return 0
}
}
Life iS Just a dReaM oN tHE wAy to DeaTh
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

The code you posted doesn't include the output statements, so it is difficult to reply with specifics. However, I can offer an example of how you could output timed statements.

Before I do, I am doubtful about your attempt to assign the output method to the variable 'way'.

Code: Select all

set way "PRIVMSG $chan :\001ACTION [lindex $arg 1]"
Evaluation of the above code (as the text is assigned to the variable), will cause substitution of the backslash. Essentially it will be lost. To retain a backslash you will need to double it as follows :-

Code: Select all

set way "PRIVMSG $chan :\\001ACTION [lindex $arg 1]"
As an example of timed output, say if the text lines are in the form of a list 'textlist', you could use something akin to the following :-

Code: Select all

set count 1
foreach line $textlist {
    timer $count [list putserv "PRIVMSG $chan :$line"]
    incr count 2
}
The first output occurs after 1 minute.
I must have had nothing to do
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The single escape is most likely intentional to create the "Ctrl+A" character used for CTCP commands, in this case the Action (or /me) command. I don't see any cause for changing that piece of the code.
NML_375
Post Reply