Bot auto Message of the Day/Week

By eqrunner on May 20, 2009

Script I created to allow a bot to auto message a channel at specific times through out the week

the code is explained though out. but feel free to contact if you have a question.

Forum of it being built for other ways http://trout.snt.utwente.nl/ubbthreads/ubbthreads.php?ubb=showflat&Number=212226&page=1#Post212226

UPDATE EDITED: 2009-10-19
I rewrote it cause I found what I made didn't truly work across multiple networks. Now it does. along with multiple channels.

You can use this bot do execute various commands other than just msg channels.

;; start explanation

on *:Connect: = When connected to a specified network (Webchat) It will activate the alias assigned to that network (botd_Webchat)

alias botd_webchat
Line 1: sets the time in to a hhnn mode (instead of hh:nn by default) so the if can reference it correctly
Line 2: echos in the status window of said network that it is active and what date and time. This will occur daily.
Line 3: if you type /botd_webchat off This will disable the botd for webchat. To re-enable (with out reconnecting) simply type /botd_webchat in webchats status window
Line4: Is a refresher. every day at said time (05:00am) it will refresh/run botd_webchat again and will start all corresponding timers for that day.

Line 5-: these are the timers that will activate according to the rules you set.
If ( == <specified day(s)>) and (<the hhnn noted in line 1> is less than ) IF ALL IS TRUE THEN: { timerbotd<##> -o 1 1 botd_msg <$1network> <$2name> }

when a timer executes, it goes to alias botd_msg
This is where all the actions you want to execute will occur.
in the case of
if ($day != saturday.sunday) && (%botd_time < 1700 ) { .timer_botd_webchat01 -o 17:00 1 1 botd_msg webchat weekday02 }

It goes to botd_msg
$1 = webchat, and $2 = weekday02
then executes command line { msg #general Its Quittin time! }

;; end explanation

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Bot Auto Messages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2009-10-19 eqrunner;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

on *:CONNECT: {
  if ($network == EFnet) && (%botd_switch == on) {
    echo -s BOTD $network Enabled
    botd_efnet
  }
  if ($network == iPocalypse) && (%botd_switch == on) { 
    echo -s BOTD $network Enabled
    botd_iPocalypse
  }
  if ($network == Webchat) && (%botd_switch == on) { 
    echo -s BOTD $network Enabled
    botd_Webchat
  }
}

alias botd_efnet {  
  var %botd_time $time(HHnn)
  echo -s BOTD $network - $day - %botd_time
  if ($1 == off) { .timer_botd_efnet* off | echo -s BOTD $network STOPPED | halt } 
  if (!$1) { .timer_botd_efnet_refresh -o 05:00 1 60 botd_efnet }

  if ($day != friday.saturday.sunday) && (%botd_time < 2000 ) { .timer_botd_efnet01 -o 20:00 1 1 botd_msg efnet netradio01 }
  if ($day == Friday) && (%botd_time < 1400) { .timer_botd_efnet02 -o 14:00 1 1 botd_msg efnet ego01 }
  if ($day == Friday) && (%botd_time < 2000) { .timer_botd_efnet03 -o 20:00 1 1 botd_msg efnet ego02 }

}

alias botd_iPocalypse {
  var %botd_time $time(HHnn)
  echo -s BOTD $network - $day - %botd_time
  if ($1 == off) { .timer_botd_iPocalypse* off | echo -s BOTD $network STOPPED | halt } 
  if (!$1) { .timer_botd_iPocalypse_refresh -o 05:00 1 60 botd_iPocalypse }

  if ($day == Monday) && (%botd_time < 1300) { .timer_botd_iPocalypse01 -o 13:00 1 1 botd_msg iPocalypse monday01 }
  if ($day == Tuesday) && (%botd_time < 1300) { .timer_botd_iPocalypse02 -o 13:00 1 1 botd_msg iPocalypse tuesday01 }
  if ($day == Wednesday) && (%botd_time < 1300) { .timer_botd_iPocalypse03 -o 13:00 1 1 botd_msg iPocalypse wednesday01 }
  if ($day == Thursday) && (%botd_time < 1300) { .timer_botd_iPocalypse04 -o 13:00 1 1 botd_msg iPocalypse thursday01 }
  if ($day == Friday) && (%botd_time < 1300) { .timer_botd_iPocalypse05 -o 13:00 1 1 botd_msg iPocalypse friday01 }

}

alias botd_Webchat {
  var %botd_time $time(HHnn)
  echo -s BOTD $network - $day - %botd_time
  if ($1 == off) { .timer_botd_Webchat* off | echo -s BOTD $network STOPPED | halt } 
  if (!$1) { .timer_botd_Webchat_refresh -o 05:00 1 60 botd_Webchat }

  if ($day != saturday.sunday) && (%botd_time < 1200 ) { .timer_botd_webchat01 -o 12:00 1 1 botd_msg webchat weekday01 }
  if ($day != saturday.sunday) && (%botd_time < 1700 ) { .timer_botd_webchat01 -o 17:00 1 1 botd_msg webchat weekday02 }

}

alias botd_msg {
  if ($1 == efnet) {
    if ($2 == generalmsg01) && ($me ison #netradio) {
      msg #netradio ----- Michael Groff Show comin up next! -----
    }
    elseif ($2 == egomsg01) && ($me ison #egochan) {
      msg #egochan -------- $time(h:nntt) est -------
      msg #egochan The Friday afternoon rush starts now
      msg #egochan ---------------------
    }
    elseif ($2 == egomsg02) && ($me ison #egochan) {
      msg #netradio ----- Weekly reports no longer accepted -----
    }
  }

  if ($1 == iPocalypse) {
    if ($2 == monday01) && ($me ison #danceradio) { msg #danceradio --- ShoutDRIVE Sessions: JG Whiteside starts now! --- }
    if ($2 == tuesday01) && ($me ison #danceradio) { msg #danceradio --- ShoutDRIVE Sessions: Marcus McBride starts now! --- }
    if ($2 == wednesday01) && ($me ison #danceradio) { msg #danceradio --- ShoutDRIVE Sessions: Kill Tha DJ starts now! --- }
    if ($2 == thursday01) && ($me ison #danceradio) { msg #danceradio --- ShoutDRIVE Sessions: Andrius & Kristin starts now! --- }
    if ($2 == friday01) && ($me ison #danceradio) { msg #danceradio --- ShoutDRIVE Weekend Launch starts now! --- }
  }

  if ($1 == Webchat) {
    if ($2 == weekday01) $$ ($me ison #general) { msg #general Its Lunch time! }
    if ($2 == weekday02) $$ ($me ison #general) { msg #general Its Quittin time! }
  }
}

;;;;;;; Below is Menu ablity to enable or disable the daily messages

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
  }
  .$iif((%botd_switch != on),$style(1)) disable : { 
    set %botd_switch off
    .timer_botd_* off
    echo -s BOTD Disabled
  }
}

;;;;; Clean up if you were to unload the script, this will make sure it will kill any remaining timers

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

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.