| View previous topic :: View next topic |
| Author |
Message |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Mon Feb 07, 2011 9:17 pm Post subject: timed command |
|
|
Hey
Im looking for a small script that will send a command to a channel every 60 minutes the command being !newweek but about a minute before it sends the command it needs to noyify the channel that a new round will be starting in 1 minute
many thanks _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Feb 08, 2011 7:05 am Post subject: |
|
|
With the new 'cron' bind in 1.6.20 it's quite easy:
| Code: |
bind cron - {*/59 * * * *} cron:warn
bind cron - {* */1 * * *} cron:week
proc cron:warn {minute hour day month weekday} {
putserv "PRIVMSG #some_channel :week will start in 1 minute"
}
proc cron:week {minute hour day month weekday} {
putserv "PRIVMSG #some_channel :!newweek"
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Tue Feb 08, 2011 8:09 am Post subject: |
|
|
Hi caesar getting an error when i try load this up | Code: | [07:07] Tcl error in file 'eggdrop.conf':
[07:07] bad type, should be one of: act, away, bcst, bot, chat, chjn, chof, chon, chpt, ctcp, ctcr, dcc, disc, evnt, filt, flud, join, kick, link, load, lost, mode, msg, msgm, need, nick, nkch, notc, note, part, pub, pubm, raw, rcvd, rejn, sent, sign, splt, time, topc, tout, unld, wall
while executing
"bind cron - {*/59 * * * *} cron:warn "
(file "scripts/random.tcl" line 1)
invoked from within
"source scripts/random.tcl"
(file "eggdrop.conf" line 1340)
[07:07] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR) |
_________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue Feb 08, 2011 10:20 am Post subject: |
|
|
In the partyline, send this command:
and copy-n-paste the first line returned.
It will look like this:
| Quote: |
I am <botnick>, running eggdrop v1.6.20: xx users (mem: xxxk).
|
The purpose is to identify and tell us the version of Eggdrop that you are currently using. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Feb 08, 2011 10:43 am Post subject: |
|
|
If possible you should upgrade to 1.6.20, if not, something this should do the trick:
| Code: |
bind time - "59 * * * *" time:warn
bind time - "00 * * * *" time:week
proc time:warn {min hour day month year} {
putserv "PRIVMSG #some_channel :week will start in 1 minute"
}
proc time:week {min hour day month year} {
putserv "PRIVMSG #some_channel :!newweek"
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Wed Feb 09, 2011 12:33 pm Post subject: |
|
|
Cool the above script worked
is it possible to extend on it id like it to check if WScrabble is in the room if it is then it will execute those commands if the nickname wscrabble is not in the room or idle it will do nothing till the wscrabble re-enters the room or is no longer idle _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Feb 09, 2011 1:58 pm Post subject: |
|
|
Checking if 'WScrabble' is on the #channel channel is easy achieved with:
| Code: |
if {![onchan "WScrabble" #channel]} return
|
as for idle part, for instance:
| Code: |
if {[getchanidle "WScrabble" "#channel"] > 10} return
|
would mean if the idle time is above 10 minutes then nothing else would happen.
Anyway, here is what you want:
| Code: |
bind time - "59 * * * *" time:week
bind time - "00 * * * *" time:week
proc time:week {min hour day month year} {
if {![onchan "WScrabble" "#channel"]} return
if {[getchanidle "WScrabble" "#channel"] > 10} return
if {[string trimleft $min 0] == 59} {
putserv "PRIVMSG #some_channel :week will start in 1 minute"
}
putserv "PRIVMSG #some_channel :!newweek"
}
}
|
You should replace '10' with the time in minutes that would define the maximum idle time 'WScrabble' should have, anything above that would make the bot be quiet.
Honestly I would upgrade to 1.6.20 and use the 'cron' instead.
| Code: |
bind cron - {*/59 * * * *} cron:week
bind cron - {* */1 * * *} cron:week
proc cron:week {minute hour day month weekday} {
if {![onchan "WScrabble" "#channel"]} return
if {[getchanidle "WScrabble" "#channel"] > 10} return
if {[string trimleft $minute 0] == 59} {
putserv "PRIVMSG #some_channel :week will start in 1 minute"
} else {
putserv "PRIVMSG #some_channel :!newweek"
}
}
|
At this point you wouldn't notice any difference, but later on if you would like to make this script work only on specific days and/or between or at specific hours for instance, for example run from Monday to Friday, then with 'cron' would be just making a change on the binds:
| Code: |
bind cron - {*/59 * * * 1-5} cron:week
bind cron - {* */1 * * 1-5} cron:week
|
while for 'time' things would be different, as it expects 5 space separated integers and flags are ignored, thus having to change the code to:
| Code: |
bind time - "59 * * * *" time:week
bind time - "00 * * * *" time:week
proc time:week {min hour day month year} {
switch [string trimleft $day 0] {
"6" { return }
"7" { return }
default {
if {![onchan "WScrabble" "#channel"]} return
if {[getchanidle "WScrabble" "#channel"] > 10} return
if {[string trimleft $min 0] == 59} {
putserv "PRIVMSG #some_channel :week will start in 1 minute"
} else {
putserv "PRIVMSG #some_channel :!newweek"
}
}
}
}
|
just to achieve the same result.
The difference is even more noticeable if we where to complicate things like making this run between specific hours, for instance 09:00 - 17:00.
If with 'cron' we just add '9-17' in the binds:
| Code: |
bind cron - {*/59 * 9-17 * 1-5} cron:week
bind cron - {* */1 9-17 * 1-5} cron:week
|
the 'time' would require at least two extra lines of code:
| Code: |
set hour [string trimleft $hour 0]
if {$hour < 9 && $hour > 17} return
|
and the code would be changed to:
| Code: |
bind time - "59 * * * *" time:week
bind time - "00 * * * *" time:week
proc time:week {min hour day month year} {
switch [string trimleft $day 0] {
"6" { return }
"7" { return }
default {
set hour [string trimleft $hour 0]
if {$hour < 9 && $hour > 17} return
if {![onchan "WScrabble" "#channel"]} return
if {[getchanidle "WScrabble" "#channel"] > 10} return
if {[string trimleft $min 0] == 59} {
putserv "PRIVMSG #some_channel :week will start in 1 minute"
} else {
putserv "PRIVMSG #some_channel :!newweek"
}
}
}
}
|
While 'cron-ed' procs are executed only at the time interval we specified at 'bind' line, the same thing can't be said about 'time' as it would run every 59 minutes, respectively 60 minutes every hour, every day. Sure, we can make it run only at specified hours too, but would require even more lines of code:
| Code: |
bind time - "59 9 1 * *" time:week
bind time - "00 9 1 * *" time:week
bind time - "59 10 1 * *" time:week
bind time - "00 10 1 * *" time:week
|
and so on for day one up to:
| Code: |
bind time - "59 17 1 * *" time:week
bind time - "00 17 1 * *" time:week
|
and this just for day 1.
Bottom line is that you should upgrade to 1.6.20 and use the 'cron' instead.
Edit: Fixed. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Thu Feb 10, 2011 2:15 am; edited 2 times in total |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Wed Feb 09, 2011 3:41 pm Post subject: |
|
|
Thanks caesar works exactly how i need it to
Would it be possible to extend on it a bit further im looking for some thing that will count the amount of times users have been set +v in #CWUKCountdown it should then display the top person thats been voice the most with The top player of this game was NICK with a total of amountvoiced(Top answers) this round needs to be done directly after it sends the command !newweek once it sends it to the channel it needs to delete the info and count all ova again
Edited now using updated eggy
GETTING THE FOLLOWING ERROR
| Code: | | [20:54] <CWUKCountdown> [15:54:00] Tcl error [cron:week]: illegal channel: '#CWUKCountdown' |
_________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Feb 10, 2011 1:53 am Post subject: |
|
|
Ah, i knew I should stick to " I fixed the above codes. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|
|
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
|
|