mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
my channel is for a radio station and would like to have my mirc auto message the channel at specific times.
Every Friday at 2pm est, msg $chan "It's now time for the All Request hour"
Every weekday at 11am est msg $chan 80's hour!

how can I go about getting the script to accomplish this task?

Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
Code:
alias timed_radio {
if ($day == Friday) .timer_radio 14:00 1 1 if ($me ison #CHANNEL) msg #CHANNEL It's now time for the All Request hour
elseif ($istok(saturday.sunday,$day,46)) .timer_radio 11:00 1 1 if ($me ison #CHANNEL) msg #CHANNEL 80's hour!
}
on me:*:join:#CHANNEL:if ($network == YOUR_NETWORK) timed_radio
Add this in your remote, replace #CHANNEL and YOUR_NETWORK by your channel and network and it should work.If you don't want to restart mirc to use this, simply call the timed_radio alias (type /timed_radio)

Last edited by Wims; 15/05/09 06:09 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
This won't work if he keeps mIRC open and stays connect to the network. ;-)

Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
Why ? I've modified the code, added some error checking


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Because it starts a timer when her joins the room only if he happens to join the room in the proper day. And it only executes once. Also, he asked for a message on weekdays, yours sends it on the weekend,

I'd suggest an infinite timer that checks that day.

Code:
on *:start:radio_annc

alias radio_annc {
if (!$timer(radio_annc)) .timerradio_annc 10:00 0 1 /radio_annc chk
elseif ($1 = chk) {
if ($day !isin saturday.sunday) .timer80s 11:00 1 1 /msg #channel 80's hour!
if ($day = friday) .timerrequest 14:30 1 1 /msg #channel It's now time for the All Request hour
}
}

menu menubar {
$iif($timer(radio_annc),$style(1)) Radio Announce
.On:timerradio_annc 10:00 0 1 /radio_annc chk
.Off:timerradio_annc off
}


This is untested.

Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
it works great! thanks much. Now I would like to understand its workings. I got most of it, the parts that I don't fully understand are:


.timer_radio 14:00 1 1
what is this line doing?

($istok(saturday.sunday,$day,46))
can you explain what it is doing?

on me:*:join:#CHANNEL:if ($network == YOUR_NETWORK) timed_radio
I reside on efnet. would YOUR_NETWORK == efnet? or the server I am connected to?


Thanks again for your help.


UPDATE: True DJ_Sol, it is currently friday, Will add another line and see if it reacts tomorrow (saturday)

Last edited by eqrunner; 15/05/09 06:35 PM.
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
What I said about Wims code is how it goes. No testing is needed. Code I provided does exactly what you asked for.

/help /timer

/timer 14:00 1 1 /command

This will perform /command once at 14:00



($istok(saturday.sunday,$day,46))

This is a comparison that will be $true if the $day is Saturday or Sunday.


To find your $network, //echo -a $network.

Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
Ok, indeed.
As for the timer, the -o switch should be used for the infinite timer and something should be added for other timer since a disconnexion would stop them and this isn't expected


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
Code:
on *:start:radio_annc

alias radio_annc {
  if (!$timer(radio_annc)) .timerradio_annc 10:00 0 1 radio_annc chk
  elseif ($1 = chk) {
    if ($day !isin saturday.sunday) .timer80s 11:00 1 1 msg #thehome 80's hour!
    if ($day = friday) .timerrequest 15:07 1 1 msg #thehome It's now time for the All Request hours
  }
}

menu menubar {
  $iif($timer(radio_annc),$style(1)) Radio Announce
  .On:timerradio_annc 10:00 0 1 radio_annc chk
  .Off:timerradio_annc off
}



Ive been testing, and go this far, but it will only check if I run /radio_annc chk in the command line. It wont check itself.

Last edited by eqrunner; 15/05/09 07:10 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Quote:
(...) .timerradio_annc 10:00 0 1 radio_annc chk
...at 10:00, this will start an infinite timer with 1s delay, so it'll perform the chk every second (overwriting the "message-timers" every second) - I think this is unnecessarry overhead.

Here's a quick alternative; it should work as long as you don't want specific messages arround 00:00. Using the on connect event and without offline timers it automatically binds the timers to a specific network.
Code:
on *:connect: { radio_timer }

alias radio_timer {
  var %network = YOUR_NETWORK
  var %radiochan = #YOUR_RADIO_CHANNEL

  if ($network == %network) {
    if ($day == Friday) .timerRadioFriday 14:00 1 0 if ( $!me ison %radiochan ) msg $!v2    It's now time for the All Request hour!
    if (!$istok(saturday.sunday,$day,46)) .timerRadioWeekday 11:00 1 0 if ( $!me ison %radiochan ) msg $!v2    80's hour!
    
    ; refresh timers and restart the "refresh-timer" after midnight (the 60s delay timer prevents a loop at 00:00)
    if (!$1) { .timerRadioRefresh 00:00 1 60 radio_timer refresh $chr(124) .timerRadioRefresh 00:00 1 0 radio_timer }
  }
}

Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
Code:
alias botoftheday {
  if ($day == Friday) timer_botd 16:39 1 1 if ( $!me ison #thehome ) msg #thehome Timecheck | msg #thehome Request Hour
  if ($day == Friday) timer_botd2 16:29 1 1  msg #thehome Timecheck4
  if (!$1) { timer_botdRefresh 16:30 1 60 botoftheday refresh $chr(124) timer_botdRefresh 16:30 1 0 botoftheday }

}
 

Im picking everyone's suggestions and putting them slowly back together.(and much thanks!)
My current delema is how to get 2 messages to be sent at said time? If I try putting them in {} after the IF ($me ison) it returns with a /if: insufficient parameters, and will automatically msg Request Hour regardless of the time

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The 00:00 is in the refresh timer because at 00:00 starts a new $day, so it will set the "daily" timers according to the current day of the week. You don't have to change this time.

Because the command part of a timer will be evaluated, if you want to have a single timer execute multiple commands: Either put the commands in an alias, or "delay" the evaluation of the pipe char.
In the code above, the pre-evaluation of some identifiers had been prevented alike (the "!" in $!me and $!v2).

Example for alias call (cleaner, I'd use it for a lot of / long / complex commands)
Code:
alias test1 { .timer 1 1 my_commands }
alias my_commands {
  echo -a command1
  echo -a command2
}

Examples for escaped "pipe" char (I'd use it only for simple commands):
Code:
alias test2 { .timer 1 3 echo -a command1 $chr(124) echo -a command2 $chr(124) echo -a command3 }

alias test3 { .timer 1 1 msg #mychan text1 $(|,0) msg #mychan text2 }

Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
I now have a up and running script. The next question I do have, is how to create a menu bar to turn it on and off. I currently have 4 active timers with out having to use /timer* off
I am fine with killin all 4 timers at once
Code:
timer.mgs.live 
timer.kmgx.fri.request 
timer.mgs.live.crappy 
timer.botdRefresh


DJ_Sol has already done one, but I am not sure how to convert it to work with mine
Code:
menu menubar {
$iif($timer(radio_annc),$style(1)) Radio Announce
.On:timerradio_annc 10:00 0 1 /radio_annc chk
.Off:timerradio_annc off
}



my current code looks as follows:
Code:
on *:start:botd

alias botd {
  set %botd_network $network

  if (%botd_network == efnet) {
    set %botd_chan #netradio
    ; MGS daily
    if (!$istok(saturday.sunday.friday,$day,46)) .timer_mgs_live 20:00 1 1 if ( $!me ison %botd_chan ) set %botd_var botd_mgs_live $chr(124) botd_msg
    ; kmgx.com All request
    if ($day == Friday) .timer_kmgx_fri_request 14:00 1 1 if ( $!me ison %botd_chan ) set %botd_var botd_kmgx_fri_request $chr(124) botd_msg 
    ; MGS friday
    if ($day == Friday) .timer_mgs_live_crappy 20:00 1 1 if ( $!me ison %botd_chan ) set %botd_var botd_mgs_live_crappy $chr(124) botd_msg
    ; Daily Refresh of botd
    if (!$1) { .timer_botd_refresh 05:00 1 60 botd refresh $chr(124) .timer_botd_refresh 05:00 1 0 botd }
  }
}

alias botd_msg {
  if (%botd_var == botd_mgs_live) {
    msg %botd_chan <<<< Michael Groff Show starts Now! >>>>
  }
  if (%botd_var == botd_kmgx_fri_request) {
    msg %botd_chan -------- $time(h:nntt) --------
    msg %botd_chan The All Request Zone starts NOW
    msg %botd_chan request a song by typing !request + song
    msg %botd_chan ------------------------
  }
  if (%botd_var == botd_mgs_live_crappy) {
    msg %botd_chan <<<< Michael Groff Show starts Now! Ft Crappy Covers tonight >>>
  }
  unset %botd_var
}


I have used Horstl's alias reference idea along with variables to consolidated the code.

Follow up question. Is the following a good way to make sure the alias botd starts up when I start the program/sign on
Code:
 on *:start:botd 

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Code:
/*
You can use "on start" if you chat only on efnet, or never will be on another network's channel "#netradio".
"On connect" would be your choice if you chat at different networks (with similar channel names) simultaneously,
because you can run "online timers" (which start on connect, automatically end on disconnect, and
they trigger on their respective connection only)
*/

on *:start: { 
  ; if the variable %botd_switch is "on", run the botd alias on startup
  if (%botd_switch == on) { botd }
}


/*
Assuming that you chat on efnet only, there's no need for a $network check, and you can use "offline" timers (the -o switch).
Because you call an alias for the messages anyway, the "ison"-check can go to this alias.
Instead of setting a variable, you can pass the "type" of message as parameter to the alias.
You could pass the network, channel name etc as another parameters as well (to allow a setup for different channels / networks).
Atm you don't need this, for all messages go to #netradio
I named the timers to be more uniform, so you can kill them all at once in the menu
*/

alias botd {

  ; MGS daily (call the alias "botd_msg" with the parameter "live")
  if (!$istok(saturday.sunday.friday,$day,46)) { .timer_botd_live -o 20:00 1 1 botd_msg live }

  ; kmgx.com All request (call the alias "botd_msg" with the parameter "kmgx_fri_request")
  if ($day == Friday) { .timer_botd_kmgx_fri_request -o 14:00 1 1 botd_msg kmgx_fri_request }

  ; MGS friday (...)
  if ($day == Friday) { .timer_botd_live_crappy -o 20:00 1 1 botd_msg live_crappy }

  ; Daily Refresh
  ; you can use 05:00 too... just make sure the time you put here is before the time of the "most early" message
  if (!$1) { .timer_botd_refresh -o 05:00 1 60 botd refresh $chr(124) .timer_botd_refresh -o 05:00 1 0 botd }
}


alias botd_msg {
  var %botd_chan = #netradio

  if ($me ison %botd_chan) {

    ; $1 is the first parameter passed to the alias. $2 would be the second parameter and so on
    if ($1 == live) {
      msg %botd_chan <<<< Michael Groff Show starts Now! >>>>
    }
    elseif ($1 == kmgx_fri_request) {
      msg %botd_chan -------- $time(h:nntt) --------
      msg %botd_chan The All Request Zone starts NOW
      msg %botd_chan request a song by typing !request + song
      msg %botd_chan ------------------------
    }
    elseif ($1 == live_crappy) {
      msg %botd_chan <<<< Michael Groff Show starts Now! Ft Crappy Covers tonight >>>
    }
  }
}


/*
this menu definition will switch the variable "%botd_switch".
if you switch to "off", it will kill all timers called "_botd_*"
if you switch to "on", it will run the "botd" alias to start the timers
*/

menu status,menubar {
  -
  Botd Timer $+($chr(91),$iif((%botd_switch == on),enabled,disabled),$chr(93))
  .$iif((%botd_switch == on),$style(1)) enable : { 
    set %botd_switch on
    botd
  }
  .$iif((%botd_switch != on),$style(1)) disable : { 
    set %botd_switch off
    .timer_botd_* off
  }
}

; clean up :)
on *:unload: { 
  .timer_botd_* off
  unset %botd_switch
}
...untested - hope it works at all smile

Last edited by Horstl; 16/05/09 12:15 AM.
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Thank you Horstl, I had it backwards. smile

Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
Current Code. Some tweaking done, some tweaking in the future.

Only issue right now is the fact that I enable /botd on say Friday at 20:21. It enables mgs_live_crappy and kmgx_fri_requests, cause it is currently Friday. Thus these timers activate on their noted times on the following day.

How can I add into it a check $time action to make sure its not past its 'time' on its given 'day'

Code:
on *:connect: { 
  ; if the variable %botd_switch is "on", run the botd alias on startup
  if (%botd_switch == on) { 
    botd 
  }
}

alias botd {
  ; Checking the network cause I have plans to expand this script later for other servers
  set %botd_network $network
  ; track of the day of the week, hence why I make sure it updates then tells me what day of week it has.
  set %botd_day $day
  echo -s BOTD Day: %botd_day 

  if ($1 == status) {
    echo -s Status: %botd_switch $chr(124) Network: %botd_network $chr(124) Day: %botd_day
    timer_botd_*
  }
  if (%botd_network == efnet) {
    ; MGS daily (call the alias "botd_msg" with the parameter "mgs_live")
    if (!$istok(saturday.sunday.friday,%botd_day,46)) { .timer_botd_live -o 20:00 1 1 botd_msg mgs_live }

    ; kmgx.com All request (call the alias "botd_msg" with the parameter "kmgx_fri_request")
    if (%botd_day == Friday) { .timer_botd_kmgx_fri_request -o 14:00 1 1 botd_msg kmgx_fri_request }

    ; MGS friday (...)
    if (%botd_day == Friday) { .timer_botd_live_crappy -o 20:00 1 1 botd_msg mgs_live_crappy }

    ; Daily Refresh
    ; picked 05:00 cause there are plans of some midnight announcments.
    if (!$1) { .timer_botd_refresh -o 05:00 1 60 botd refresh $chr(124) .timer_botd_refresh -o 05:00 1 0 botd }
  }
}

alias botd_msg {
  var %botd_chan = #netradio

  if ($me ison %botd_chan) {
    ; $1 is the first parameter passed to the alias. $2 would be the second parameter and so on

    if ($1 == mgs_live) {
      msg %botd_chan <<<< Michael Groff Show starts Now! >>>>
    }
    elseif ($1 == kmgx_fri_request) {
      msg %botd_chan -------- $time(h:nntt) est -------
      msg %botd_chan The All Request Zone starts NOW
      msg %botd_chan request a song by typing !request + song
      msg %botd_chan ---------------------
    }
    elseif ($1 == mgs_live_crappy) {
      msg %botd_chan <<<< Michael Groff Show starts Now! Ft Crappy Covers tonight >>>
    }
  }
}

menu status,menubar {
  -
  Botd Timer $+($chr(91),$iif((%botd_switch == on),enabled,disabled),$chr(93))
  .$iif((%botd_switch == on),$style(1)) enable : { 
    set %botd_switch on
    echo -s BOTD Enabled
    botd
  }
  .$iif((%botd_switch != on),$style(1)) disable : { 
    set %botd_switch off
    .timer_botd_* off
    echo -s BOTD Disabled
  }
}

; clean up :)
on *:unload: { 
  .timer_botd_* off
  unset %botd_switch
}


Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Ah, - I completely forgot that one, sorry smile
The botd alias has to clean all current botdtimers if it wasn't called with the "refresh" parameter (that is: if it's not the run at 00:01 or 05:01 respectively - because the timer calling this run also starts the timer for 00:00 / 05:00 at the next day, and this one shall not be unset).

It should be sufficient to add to the botd alias, before the daily timers are set:
if (!$1) { .timer_botd_* off }

Regarding midnight announcement - if you do this with the current code, remember that the timers had been set for the next "24hrs", and new- and invalid timers are not taken into account before the "refresh run" (and I forgot about the "invalid" ones, but the code above should fix it).
So if you want to e.g. announce at 0:00 Saturday, you'd have to use Friday in the if-condition... may be confusing.

Bigger issue: timers to trigger between 0:00 and 5:00. With the current code you cannot set them in a reliable way at all: if you started mIRC the day before, you have the $day+1 (like the midnight thingie described above). But, if you started mIRC between 0:00 and 5:00, the day+1 won't work as expected. Therefore I'd rather set the "refresh time" back to 0:00.

In fact the current refreshing method was more or less a quick fix (only one extra timer, not a lot of extra code); due to your initial request, I barely thought about timers between 0:00 and <refresh finished>. And the downside of the current method is that the refresh will run the botd alias twice (at the "refresh time" and one minute after this time). If you set a message-timer for this span, e.g. to 0:00 or 0:01, the timer will fire twice I suppose. That's why I wrote: "as long as you don't want specific messages arround 00:00" smirk

Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
could I not simply add to the IF date statement like this:

Code:
CHANGE: 
if (%botd_day == Friday) { .timer_botd_kmgx_fri_request -o 14:00 1 1 botd_msg kmgx_fri_request }

TO:
set %botd_time $time(hhnn)
if (%botd_day == Friday && %botd_time < 1400) { .timer_botd_kmgx_fri_request -o 14:00 1 1 botd_msg kmgx_fri_request }



by creating the %botd_time into current time when the alias runs, of lets say 0501 (05:01 in the mornin) then in the first IF statement, comparing it to the posted time of 1400. It should beable to determin that if 'current time' is earlier than 'timer's action time' then it would enable it.

If I am correct, How could I add this to the weekly? like this?

Code:
CHANGE
if (!$istok(saturday.sunday.friday,%botd_day,46)) { .timer_botd_live -o 20:00 1 1 botd_msg mgs_live }

TO
if (!$istok(saturday.sunday.friday,%botd_day,46) && %botd_time < 2000) { .timer_botd_live -o 20:00 1 1 botd_msg mgs_live }

Last edited by eqrunner; 16/05/09 11:27 PM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Sorry for the late reply.

Of course you can add conditions to fix this, either to the alias starting the timer, or to the timer itself, or even to the message-alias called by the timer.
But I'd try to keep the part where timers/messages are set as clean as possible, adding some "routines" to the script instead. This means more code - but you don't have to touch these routines if you change or add timers/messages.

The version below has a different timer/message layout format. I think the approach is more appropriate because your script / it's requirements grew more complex too smile
This version allows to specify (per timer definition):
- multiple networks
- multiple days of the week
- multiple times-to-trigger at
- multiple channels-to-message

Code:
;     if timers are enabled for this network, call the set-alias one minute after connect
;     (1 minute delay if connecting at 00:00 to prevent "wrong" announcements)
on *:connect: {
  if ($($+(%,radiotimer.,$network),2) == on) { .timer  1 $iif(($time(HHnn) == 0),60,0) radiotimer.set }
}


; setup your timers
alias -l radiotimer.set {

  ;     ---------- SETUP 1: TIMERS ----------
  ;     Add commands in the format: "radiotimer.init <network(s)> <day(s)> <time(s)> <channel(s)> <message-keyword>".
  ;     - separate multiple networks/days/channels with commas (only commas, no spaces!)
  ;     - you may use the abbreviations "Mon/Tue/Wed/Thu/Fri/Sat/Sun" for the day(s)
  ;     To allow "midnight announcements" without conflict ("will the announcing timer or the refresh timer trigger first?"),
  ;     a "new day" starts at 00:01 for the script. 00:00 will count to the day that just passed.
  ;     Avoid setting timers to 00:01 - all other times should be fine.

  ; Examples:

  ; announce the message(s) for "request_hour" each friday/saturday/sunday at 20:00 in the channel "#netradio" on networks "efnet" and "anothernet" 
  radiotimer.init efnet,anothernet fri,sat,sun 20:00 #netradio request_hour

  ; announce the message(s) for "saturday's_cue" each friday at 22:00, 22:30 and 00:00 in the channels "#netradio" and "#radionet" on efnet
  radiotimer.init efnet friday 22:00,22:30,0:00 #netradio,#radionet saturday's_cue

  ;     ---------- SETUP 1 END ----------

  ; start the refresh timer (per network)
  .timer.radiotimer.refresh. $+ $network 00:00 1 0 radiotimer.refresh
}


; refresh routine - triggered at 0:00 (a new $day) and refreshing at 0:01 (this ensures no "midnight" timer is overwritten or triggered twice)
alias -l radiotimer.refresh { .timer.radiotimer.refresh. $+ $network 00:01 1 0 radiotimer.set }


; setup your message(s) per keyword
alias -l radiotimer.msg {
  var %chan = $gettok($ctimer,4,9), %key = $gettok($ctimer,5,9) 
  if ($me ison %chan) {

    ;     ---------- SETUP 2: MESSAGES ---------- 
    ;     create if-conditions: if (%key == <some_keyword>) { msg %chan <your message> }

    ; Examples:

    if (%key == request_hour) { msg %chan <<< Now starting the !request hour! >>> }

    elseif (%key == saturday's_cue) {
      msg %chan  ------------------------------------------
      msg %chan  Don't miss our big Saturday show
      msg %chan  ------------------------------------------
    }

    ;     ---------- SETUP 2 END ----------
  }
}


; routine to process the commands set at  "radiotimer.set"
alias -l radiotimer.init {
  ; all required parameters exist
  if ($5 != $null) {
    ; timer definition matches current network and current day
    if ($istok($1,$network,44)) && ($wildtok($2,$time(ddd) $+ *,1,44)) {
      ; loop the time(s) specified
      var %a = 1
      while ($gettok($3,%a,44)) {
        var %t = $v1
        ; time is valid (e.g. not "24:00") and time hasn't passed, except 00:00
        if ($ctime($date %t)) && (($istok(0:00 00:00,%t,32)) || ($ctime($date $time(HH:nn)) < $ctime($date %t))) {
          ; loop the channel(s) specified
          var %b = 1
          while ($gettok($4,%b,44)) {
            ; start a timer named ".radiotimer[TAB]<network>[TAB]<time>[TAB]<channel>[TAB]<keyword>"
            ; on execution the timer will call the alias "radiotimer.msg"
            ; (the alias in turn will get the required parameters <channel> and <keyword> out of the timer's name)
            $+(.timer,.radiotimer,$chr(9),$network,$chr(9),%t,$chr(9),$v1,$chr(9),$5) %t 1 0 radiotimer.msg
            inc %b
          }
        }
        inc %a
      }
    }
  }
}


; menu to enable/disable the timers (of the current network / of all connected networks)
menu status,menubar {
  $iif(($status != connected),$style(2)) Radiotimer
  .$network $+([,$iif(($($+(%,radiotimer.,$network),2) == on),enabled,disabled),]))
  ..$iif(($($+(%,radiotimer.,$network),2) == on),disable,enable) timer(s) : { radiotimer.switch }
  .-
  .enable timer(s) on all connected networks { scon -at1 radiotimer.switch on }
  .disable timer(s) on all connected networks { scon -at1 radiotimer.switch off }
}


; switching routine (menu)
alias -l radiotimer.switch {
  ; set switch
  var %v = $+(%,radiotimer.,$network)
  set  $(%v) $iif($1,$v1,$iif(($(%v,2) == on),off,on))
  ; start/stop timers acc. to state of switch
  if ($(%v,2) == on) { radiotimer.set }
  else {
    $+(.timer.radiotimer,$chr(9),$network,$chr(9),*) off
    .timer.radiotimer.refresh. $+ $network off
  }
  ECHO -s Radiotimer(s) for $network are now: $(%v,2)
}


; stop timers and delete variables on unload
on *:unload: { 
  .timer.radiotimer* off
  unset %radiotimer.*
}


Edit: typos eek

Joined: May 2009
Posts: 12
E
Pikka bird
OP Offline
Pikka bird
E
Joined: May 2009
Posts: 12
This is the final product. Figured I would post in case others want to accomplish the same goal. Thanks Horstl for that last post, but it just flew over my head in coding. But will be helpful for a second direction in the future.


FINAL CODE:

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Bot Auto Messages ;;;;;;;;;;;;;botd = bot of the day ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

on *:connect: { 
  ; if the variable %botd_switch is "on", run the botd alias on startup
  if (%botd_switch == on) { 
    botd 
  }
}

alias botd {
  ; Checking the network cause I have plans to expand this script later for other servers
  set %botd_network $network

  ; track of the day of the week, hence why I make sure it updates then tells me what day of week it has.
  set %botd_day $day
  set %botd_time $time(HHnn)

  echo -s BOTD Day: %botd_day 

  if ($1 == status) {
    echo -s Status: %botd_switch $chr(124) Network: %botd_network $chr(124) Day: %botd_day %botd_time
    timer_botd_*
    ; /botd status will report the current status of botd
  }

  if (%botd_network == efnet) {
    ; if checks if its not one of the listed days and compairs it to %botd_day. && checks to see if its before the scheduled time
    ; {} if the IF is true, then it will create a timer_botd_announce_1 via the -offline clock at ##:## time to repeate 1 time, Delay 1 sec, and then go to the alias botd_msg and look for announce_1 
    if (!$istok(saturday.sunday.friday,%botd_day,46) && %botd_time < 2005 ) { .timer_botd_announce_1 -o 20:05 1 1 botd_msg announce_1 }

    ; if %botd_day is Friday and before 14:00 will activate timer_botd_announce_2
    if (%botd_day == Friday && %botd_time < 1400) { .timer_botd_announce_2 -o 14:00 1 1 botd_msg announce_2 }

    ; same as above
    if (%botd_day == Friday && %botd_time < 2205) { .timer_botd_announce_3 -o 20:05 1 1 botd_msg announce_3 }

    ; Daily Refresh
    ; At midnight, it will refresh the list and reactiveate timer if the %botd_day is = to the day of the week.
    if (!$1) { .timer_botd_refresh -o 00:00 1 60 botd refresh $chr(124) .timer_botd_refresh -o 00:00 1 0 botd }
  }
}

alias botd_msg {
  var %botd_chan = #YOURCHANNEL

  if ($me ison %botd_chan) {
    ; $1 is the first parameter passed to the alias. $2 would be the second parameter and so on

    if ($1 == announce_1) {
      msg %botd_chan announcement to the world
    }
    elseif ($1 == annouce_2) {
      msg %botd_chan -------- $time(h:nntt) est -------
      msg %botd_chan Introducing a second annoucment
      msg %botd_chan this one includes more lines
      msg %botd_chan ---------------------
    }
    elseif ($1 == announce_3) {
      msg %botd_chan a third annoucement for good time sake.
    }
  }
}

;below is the menu option to allow it to be in your drop down to enable and disable the botd timer

menu status,menubar {
  -
  Botd Timer $+($chr(91),$iif((%botd_switch == on),enabled,disabled),$chr(93))
  .$iif((%botd_switch == on),$style(1)) enable : { 
    set %botd_switch on
    echo -s BOTD Enabled
    botd
  }
  .$iif((%botd_switch != on),$style(1)) disable : { 
    set %botd_switch off
    .timer_botd_* off
    echo -s BOTD Disabled
  }
}

; clean up :)
on *:unload: { 
  .timer_botd_* off
  unset %botd_switch
}



Link Copied to Clipboard