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.

Timed Message Help

Help for those learning Tcl or writing their own scripts.
Post Reply
I
Ima
Voice
Posts: 4
Joined: Tue May 01, 2007 6:28 pm

Timed Message Help

Post by Ima »

I currently have a bot running, but I can only set a timer to a default time and not a specific time, if the source is needed I can provide it.

Example -
At current it would be @set timedmsg Hello
And it would repeat Hello once every hour

I was wondering if it's possible to have a timer on that.

Like @Set timedmsg 45 Hello

45 would be minutes, seconds, whatever I was just wondering if it's possible to add a timer and if so how I would go about doing it.


Thank you very much, help would be appreciated.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Show us your code.
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Re: Timed Message Help

Post by YooHoo »

Ima wrote:I was wondering if it's possible to have a timer on that.

Like @Set timedmsg 45 Hello

45 would be minutes, seconds, whatever I was just wondering if it's possible to add a timer and if so how I would go about doing it.
Absolutely. You can also make your script execute something after a certain number of minutes or seconds.
This can be done with the timer and utimer commands.
The syntax of a timer command is timer <time> "<command> [parameters]".

The <time> is after how long your command should be executed.
If you are using timer this would be have to be in minutes and if you are using utimer this would have to be in seconds.
The <command> is the command you want to execute. This can be a TCL command, an Eggdrop command or anything else just as long as it's a valid command.
The [parameters] are the parameters you want to give to your command.
Hope that is helpful :mrgreen:
I
Ima
Voice
Posts: 4
Joined: Tue May 01, 2007 6:28 pm

Post by Ima »

}
if { [string tolower [lindex $arg 1]] == "timedmsg" } {
if {[lindex $arg 2 end] == ""} {
if {[file exists $datafolder/$chan/settings/timedmsg]} {
unotice $nick $oldchan "\002TimedMSG\002 [commands_filter [getsettings $chan timedmsg]]"
return
}
unotice $nick $oldchan "\002TimedMSG\002 None"
return
}
if { [string tolower [lindex $arg 2 end]] == "none" } {
file delete -force $datafolder/$chan/settings/timedmsg
unotice $nick $oldchan "\002TimeMSG\002 None (Your timedmsg has been disabled)"
return
}
if { [string tolower [lindex $arg 2 end]] == "off" } {
file delete -force $datafolder/$chan/settings/timedmsg
unotice $nick $oldchan "\002TimeMSG\002 Off (Your timedmsg has been disabled)"
return
}
set fp [open $datafolder/$chan/settings/timedmsg w+]
puts $fp "timedmsg [commands_filter [lrange $arg 2 end]]"
close $fp
unotice $nick $chan "\002TimedMSG\002 [commands_filter [lrange $arg 2 end]]"
unotice $nick $chan "(This msg will be displayed once every hour) To delete the timed msg use [channel get $chan trigger]set timedmsg none"
return
}


That is my current Timedmsg and I'm not quite sure how to add a timer to it, if anyone could help I would appreciate it.
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

where is your proc timedmsg? This isn't the complete code :roll:
I
Ima
Voice
Posts: 4
Joined: Tue May 01, 2007 6:28 pm

Post by Ima »

My fault I had thought I had two quotes
proc timedmsgcheck {n h handle ch te} {
global channel datafolder
foreach chan [channels] {
if {[file exists $datafolder/$chan/settings/timedmsg]} {
bindmsg BotServ $chan "[commands_filter [getsettings $chan timedmsg]]"
}
}
}
I
Ima
Voice
Posts: 4
Joined: Tue May 01, 2007 6:28 pm

Post by Ima »

Bump?
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

bump what??
you still have not provided proc timedmsg

if you want help with this, post the entire script
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

DragnLord wrote:bump what??
you still have not provided proc timedmsg

if you want help with this, post the entire script
And in

Code: Select all

 tags with proper spacing.
d
dq
Voice
Posts: 32
Joined: Mon Apr 03, 2006 12:28 am

Post by dq »

Perhaps this is what you're after?

Code: Select all

proc start:timer {nick host hand chan text} {
global channel msg interval id
 if {[matchattr $hand A] == 0} {noaccess2 $nick ; return}
 set name $nick
 set interval [lindex $text 0]
 set channel [lindex $text 1]
 set msg [lrange $text 2 end]
 utimer $interval timer
 putserv "NOTICE $nick :Starting timer Message: \"$msg\" Every $interval seconds"
}

proc timer {} {
global channel msg interval timerID
  putserv "PRIVMSG $channel :$msg"
  set timerID [utimer $interval timer]
}

proc stop:timer {nick host hand chan text} {
global timerID
  if {[matchattr $hand A] == 0} {noaccess2 $nick ; return}
  putserv "NOTICE $nick :Timer stopped"
  killutimer $timerID
  return 1
}
Don't forget to add your binds etc~

.timer interval #channel messagehere

Untested, Unthought-of and only supports one channel, anyone care to add/edit/abuse go for it =p

(Picked this up from another post somewhere here, again using the search function?)
Post Reply