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.

privmsg nickname on a timer

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
d
digitalbleh
Voice
Posts: 4
Joined: Wed Jul 06, 2011 4:02 am
Location: Sydney

privmsg nickname on a timer

Post by digitalbleh »

Hi,

Just want a simple script to send a msg to a person every 80 minutes.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Seems kind of rude to spam the same message to aPerson every 80 minutes, but here it is:)

Code: Select all

proc timedMsgProc {} {
  puthelp "PRIVMSG aPerson :send this msg to aPerson every 80 minutes"
  timer 80 [list timedMsgProc]
}

if {![info exists timedMsgRunning]} {
  set timedMsgRunning 1
  timer 10 [list timedMsgProc]
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If anyone is willing to test a cron job like 20 */1 * * * (meaning at 20 minutes past the hour) let me know if works.

Code: Select all

bind cron - {20 */1 * * *} send:message

proc send:message {min hour day month week} {
	puthelp "PRIVMSG user :This is the once every 80 minutes message"
}
Once the game is over, the king and the pawn go back in the same box.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Caesar: That seems a lot more like a 60 minute timer, at 20 after every hour.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

*/1 or * are the same.
When using */x, it means it will run when * % x (modulo) equals 0.

Examples:
*/5 * * * * will act every time the minutes are 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55
13 */7 * * * will act at 7h13, 14h13 and 21h13
d
digitalbleh
Voice
Posts: 4
Joined: Wed Jul 06, 2011 4:02 am
Location: Sydney

Post by digitalbleh »

Thanks SpiKe^^

Thank you caesar

I will test both scripts, im worried tho if i need to change the time to + or - 80mins i wont know how to change 20 */1. Id assume if its 90mins it would be 30 */1 ?
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

digitalbleh wrote:I will test both scripts, im worried tho if i need to change the time to + or - 80mins i wont know how to change 20 */1. Id assume if its 90mins it would be 30 */1 ?
No.
20 */1 will send the message every hour, when minutes are 0, 20 and 40.

The code from SpiKe^^ seems more relevant
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ah, right, i had a feeling a single cron job wouldn't do the job and it actually makes sense.
Once the game is over, the king and the pawn go back in the same box.
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

tcllib also has >> https://core.tcl-lang.org/tcllib/doc/tr ... on/cron.md


if .tcl commands enabled @ partyline .

Code: Select all

.tcl package require cron; cron::every Msg2User [expr {60*80}] {putserv "privmsg Nickname :Hey!"}
Life iS Just a dReaM oN tHE wAy to DeaTh
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Thanks, I didn't know this package exists.
Might solve a lot of problematics :)
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

anyway to have this as pub command ?

also anyway to display all running crons ? with the method heartbroken used
w
willyw
Revered One
Posts: 1204
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

simo wrote:...
also anyway to display all running crons ?
...
From within the partyline, this is what I do:

.tcl binds cron
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried that as well willyw but the method heartbroken is using doesnt show in the list on PL when using: .tcl binds cron
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

That's because it doesn't come from eggdrop's commands, but from tcllib, meaning it doesn't have an implementation to see them.
Once the game is over, the king and the pawn go back in the same box.
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

heartbroken wrote:tcllib also has >> https://core.tcl-lang.org/tcllib/doc/tr ... on/cron.md


if .tcl commands enabled @ partyline .

Code: Select all

.tcl package require cron; cron::every Msg2User [expr {60*80}] {putserv "privmsg Nickname :Hey!"}
A friend of mine remembers me that the (u)timer can have a count parameter (https://github.com/eggheads/eggdrop/blo ... mand-count)
if count equals 0, it will never end

Code: Select all

.tcl timer 80 {putserv "PRIVMSG nick :hey!"} 0
Btw, I think I prefer using the cron package which allows to name the process and adds more flexibility.
Post Reply