Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias check_stream { ; by westor
- if (!$1-) { return }
- var %ch = $chr(35) $+ $1
- var %u = https://api.twitch.tv/kraken/streams/ $+ $1
- var %v = twc_ $+ $ticks
- JSONOpen -ud %v %u
- if (%JSONError) { unset %stream_ [ $+ [ %ch ] $+ ] _status | JSONClose %v | return }
- var %crdate = $json(%v,stream,created_at)
- if (%crdate) {
- var %crdate = $gettok(%crdate,1,84) $remove($gettok(%crdate,2,84),Z)
- var %crdate = $ctime(%crdate)
- }
- if (!%crdate) { unset %stream_ [ $+ [ %ch ] $+ ] _status }
- elseif (%crdate) { set -e %stream_ [ $+ [ %ch ] $+ ] _status %crdate }
- JSONClose %v
- }
- alias get_all_stream { ; by westor
- if (!$chan(0)) { return }
- var %t = $chan(0)
- var %i = 1
- while (%i <= %t) {
- var %c = $chan(%i)
- if ($me ison %c) && ($me isop %c) {
- var %c = $mid(%c,2-)
- if (%c) { check_stream %c }
- }
- inc %i
- }
- }
- ON *:CONNECT: { ; by westor
- .timer[CHECK_ALL_STREAMS] 0 600 get_all_stream
- }
- ON !*:TEXT:!downtime:#: { ; by westor
- var %s = %stream_ [ $+ [ $chan ] $+ ] _status
- var %timeago = $timeago($calc($ctime - %s)).all
- if (!%s) { .msg $chan ( $+ $nick $+ ): The stream status is now offline! }
- elseif (%s) { .msg $chan ( $+ $nick $+ ): The stream is now ONLINE -> Created on: $date(%s,dddd ddoo mmmm yyyy HH:nn:ss) ( $+ %timeago $+ ) }
- }
Add Comment
Please, Sign In to add comment