langel / botb_irc_bot

battle of the bits instant relay chat magic
BSD 3-Clause "New" or "Revised" License
11 stars 7 forks source link

add xhb alerts #89

Closed argarak closed 2 years ago

argarak commented 2 years ago

closes #2 adds xhb alerts 15 minutes before xhb start (should ping the XHBr role but i haven't tested it so it might not work) adds an alert when xhb starts adds an alert 30, 10 and 2 minutes before xhb end adds an alert when xhb ends

new module in irc_alerts.js, exposes function setXHBTimeouts which pulls battle data from the BotB API, clears all running timeouts, gets all XHBs that are not in voting phase and sets all appropriate timeouts which are calculated from period_end_seconds. it's kinda hard coded but i doubt we're going to be changing the periods when xhb alerts happen anyway so it's probably good enough.

setXHBTimeouts is called when the bot server initialises, when the bot receives a POST request to run the say command and every 5 minutes set by an interval.

PS: i hate tabs

langel commented 2 years ago

very beautiful code easy to read would recommend 10/10++