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 command

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

timed command

Post by blake »

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
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

With the new 'cron' bind in 1.6.20 it's quite easy:

Code: Select all

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.
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Hi caesar getting an error when i try load this up

Code: Select all

[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)
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

In the partyline, send this command:

Code: Select all

.status
and copy-n-paste the first line returned.

It will look like this:
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.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If possible you should upgrade to 1.6.20, if not, something this should do the trick:

Code: Select all

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.
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

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
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Checking if 'WScrabble' is on the #channel channel is easy achieved with:

Code: Select all

if {![onchan "WScrabble" #channel]} return
as for idle part, for instance:

Code: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

set hour [string trimleft $hour 0]
if {$hour < 9 && $hour > 17} return
and the code would be changed to:

Code: Select all

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: Select all

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: Select all

bind time - "59 17 1 * *" time:week
bind time - "00 17 1 * *" time:week
and this just for day 1. :roll:

Bottom line is that you should upgrade to 1.6.20 and use the 'cron' instead. :D

Edit: Fixed.
Last edited by caesar on Thu Feb 10, 2011 2:15 am, edited 2 times in total.
Once the game is over, the king and the pawn go back in the same box.
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

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: Select all

[20:54] <CWUKCountdown> [15:54:00] Tcl error [cron:week]: illegal channel: '#CWUKCountdown'
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ah, i knew I should stick to " :oops: I fixed the above codes.
Once the game is over, the king and the pawn go back in the same box.
Post Reply