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 

privmsg nickname on a timer

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
digitalbleh
Voice


Joined: 06 Jul 2011
Posts: 4
Location: Sydney

PostPosted: Mon Apr 26, 2021 5:49 am    Post subject: privmsg nickname on a timer Reply with quote

Hi,

Just want a simple script to send a msg to a person every 80 minutes.
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Mon Apr 26, 2021 9:48 am    Post subject: Reply with quote

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

Code:

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
.
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3733
Location: Mint Factory

PostPosted: Mon Apr 26, 2021 10:48 am    Post subject: Reply with quote

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:

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.
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Mon Apr 26, 2021 11:37 am    Post subject: Reply with quote

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
.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Mon Apr 26, 2021 12:25 pm    Post subject: Reply with quote

*/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
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
digitalbleh
Voice


Joined: 06 Jul 2011
Posts: 4
Location: Sydney

PostPosted: Mon Apr 26, 2021 3:28 pm    Post subject: Reply with quote

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 ?
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Mon Apr 26, 2021 5:59 pm    Post subject: Reply with quote

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
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3733
Location: Mint Factory

PostPosted: Tue Apr 27, 2021 2:22 am    Post subject: Reply with quote

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


Joined: 23 Jun 2011
Posts: 99
Location: somewhere out there

PostPosted: Tue Apr 27, 2021 6:46 am    Post subject: Reply with quote

tcllib also has >> https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/cron/cron.md


if .tcl commands enabled @ partyline .
Code:
.tcl package require cron; cron::every Msg2User [expr {60*80}] {putserv "privmsg Nickname :Hey!"}

_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Tue Apr 27, 2021 11:52 am    Post subject: Reply with quote

Thanks, I didn't know this package exists.
Might solve a lot of problematics Smile
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 646

PostPosted: Sat May 08, 2021 3:50 pm    Post subject: Reply with quote

anyway to have this as pub command ?

also anyway to display all running crons ? with the method heartbroken used
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1138

PostPosted: Sat May 08, 2021 7:49 pm    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 646

PostPosted: Sat May 08, 2021 7:56 pm    Post subject: Reply with quote

i tried that as well willyw but the method heartbroken is using doesnt show in the list on PL when using: .tcl binds cron
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3733
Location: Mint Factory

PostPosted: Sun May 09, 2021 3:34 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Fri May 28, 2021 5:53 am    Post subject: Reply with quote

heartbroken wrote:
tcllib also has >> https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/cron/cron.md


if .tcl commands enabled @ partyline .
Code:
.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/blob/develop/doc/sphinx_source/mainDocs/tcl-commands.rst#timer-minutes-tcl-command-count)
if count equals 0, it will never end
Code:
.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.
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
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 -> Script Requests 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