westor

Check all channels streams crdate for Aotik v1.0

Feb 19th, 2015
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.31 KB | None | 0 0
  1. alias check_stream { ; by westor
  2.   if (!$1-) { return }
  3.   var %ch = $chr(35) $+ $1
  4.   var %u = https://api.twitch.tv/kraken/streams/ $+ $1
  5.   var %v = twc_ $+ $ticks
  6.   JSONOpen -ud %v %u
  7.   if (%JSONError) { unset %stream_ [ $+ [ %ch ] $+ ] _status | JSONClose %v | return }
  8.   var %crdate = $json(%v,stream,created_at)
  9.   if (%crdate) {
  10.     var %crdate = $gettok(%crdate,1,84) $remove($gettok(%crdate,2,84),Z)
  11.     var %crdate = $ctime(%crdate)
  12.   }
  13.   if (!%crdate) { unset %stream_ [ $+ [ %ch ] $+ ] _status }
  14.   elseif (%crdate) { set -e %stream_ [ $+ [ %ch ] $+ ] _status %crdate }
  15.   JSONClose %v
  16. }
  17.  
  18. alias get_all_stream { ; by westor
  19.   if (!$chan(0)) { return }
  20.   var %t = $chan(0)
  21.   var %i = 1
  22.   while (%i <= %t) {
  23.     var %c = $chan(%i)
  24.     if ($me ison %c) && ($me isop %c) {
  25.       var %c = $mid(%c,2-)
  26.       if (%c) { check_stream %c }
  27.     }
  28.     inc %i
  29.   }
  30. }
  31.  
  32. ON *:CONNECT: { ; by westor
  33.   .timer[CHECK_ALL_STREAMS] 0 600 get_all_stream
  34. }
  35.  
  36. ON !*:TEXT:!downtime:#: { ; by westor
  37.   var %s = %stream_ [ $+ [ $chan ] $+ ] _status
  38.   var %timeago = $timeago($calc($ctime - %s)).all
  39.   if (!%s) { .msg $chan ( $+ $nick $+ ): The stream status is now offline! }
  40.   elseif (%s) { .msg $chan ( $+ $nick $+ ): The stream is now ONLINE -> Created on: $date(%s,dddd ddoo mmmm yyyy HH:nn:ss) ( $+ %timeago $+ ) }
  41. }
Add Comment
Please, Sign In to add comment