Advertisement
westor

ShoutCast Radio Bot v1.0 for Wikked

Jun 14th, 2015
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 11.19 KB | None | 0 0
  1. ON *:JOIN:%radio_chan: { if ($nick == $me) { set %radio 1 | radio_start } }
  2. ON *:PART:%radio_chan: { if ($nick == $me) { radio_stop } }
  3. ON *:KICK:%radio_chan: { if ($knick == $me) { radio_stop } }
  4.  
  5. ON *:TEXT:!*:#: {
  6.   tokenize 32 $strip($1-)
  7.   if ($1 == !radiohost) || ($1 == !radioip) {
  8.     if ($nick !isop $chan) { .msg $chan ( $+ $nick $+ ): You are NOT an channel moderator! | return }
  9.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a host/ip! | return }
  10.     if (*:* iswm $2) { .msg $chan ( $+ $nick $+ ): Error, Please specify only an host/ip address without the port! | return }
  11.     if ($2 == %radio_ip) { .msg $chan ( $+ $nick $+ ): Error, Already the same, Please specify an other value! | return }
  12.     set %radio_chan $chan
  13.     set %radio_ip $2
  14.     .msg $chan ( $+ $nick $+ ): The ShoutCast Radio host/ip has been set successfully.
  15.     radio_start
  16.   }
  17.   if ($1 == !radioport) {
  18.     if ($nick !isop $chan) { .msg $chan ( $+ $nick $+ ): You are NOT an channel moderator! | return }
  19.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify an port! | return }
  20.     if ($2 !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please specify valid port! | return }
  21.     if ($2 == %radio_port) { .msg $chan ( $+ $nick $+ ): Error, Already the same, Please specify an other value! | return }
  22.     set %radio_chan $chan
  23.     set %radio_port $2
  24.     .msg $chan ( $+ $nick $+ ): The ShoutCast Radio port has been set successfully.
  25.     radio_start
  26.   }
  27.   if ($1 == !radiostart) {
  28.     if ($nick !isop $chan) { .msg $chan ( $+ $nick $+ ): You are NOT an channel moderator! | return }
  29.     if (%radio) { .msg $chan ( $+ $nick $+ ): Error, Already running! | return }
  30.     set %radio 1
  31.     set %radio_chan $chan
  32.     .msg $chan ( $+ $nick $+ ): The ShoutCast Radio auto announce has been started.
  33.     radio_start
  34.   }
  35.   if ($1 == !radiostop) {
  36.     if ($nick !isop $chan) { .msg $chan ( $+ $nick $+ ): You are NOT an channel moderator! | return }
  37.     if (!%radio) { .msg $chan ( $+ $nick $+ ): Error, Not running! | return }
  38.     set %radio_chan $chan
  39.     unset %radio
  40.     .msg $chan ( $+ $nick $+ ): The ShoutCast Radio auto announce has been stopped.
  41.     radio_stop
  42.   }
  43.   if ($1 == !song) {
  44.     var %err = $get_radio
  45.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  46.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  47.     var %st = $hget(RADIO,STATUS)
  48.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  49.     var %song = $hget(RADIO,SONG)
  50.     .msg $chan ( $+ $nick $+ ): Now Playing -  $+ $iif(%song,$v1,N/A) $+ 
  51.   }
  52.   if ($1 == !radiostatus) {
  53.     var %err = $get_radio
  54.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  55.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  56.     var %st = $hget(RADIO,STATUS)
  57.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! - (Radio IP:  $+ $iif(%radio_ip,$v1,N/A) $+ ) - (Radio Port:  $+ $iif(%radio_port,$v1,N/A) $+ ) }
  58.     elseif (%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently online. - (Radio IP:  $+ $iif(%radio_ip,$v1,N/A) $+ ) - (Radio Port:  $+ $iif(%radio_port,$v1,N/A) $+ ) }
  59.   }
  60.   if ($1 == !listeners) {
  61.     var %err = $get_radio
  62.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  63.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  64.     var %st = $hget(RADIO,STATUS)
  65.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  66.     var %max_l = $iif($hget(RADIO,MAXLISTENERS),$v1,0)
  67.     var %listeners = $iif($hget(RADIO,LISTENERS),$v1,0)
  68.     .msg $chan ( $+ $nick $+ ): Listener(s) -  $+ %listeners $+ / $+ %max_l $+ 
  69.   }
  70.   if ($1 == !peak) {
  71.     var %err = $get_radio
  72.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  73.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  74.     var %peak = $hget(RADIO,PEAK)
  75.     if (!%peak) { .msg $chan ( $+ $nick $+ ): There is NOT any peak made yet! }
  76.     elseif (%peak) { .msg $chan ( $+ $nick $+ ): Peak Listener(s) -  $+ %peak $+  }
  77.   }
  78.   if ($1 == !dj) {
  79.     var %err = $get_radio
  80.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  81.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  82.     var %st = $hget(RADIO,STATUS)
  83.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  84.     var %dj = $hget(RADIO,DJ)
  85.     if (!%dj) { .msg $chan ( $+ $nick $+ ): There is NOT any DJ yet on the descs! }
  86.     elseif (%dj) { .msg $chan ( $+ $nick $+ ): Currently DJ -  $+ %dj $+  }
  87.   }
  88.   if ($1 == !radiouptime) {
  89.     var %err = $get_radio
  90.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  91.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  92.     var %st = $hget(RADIO,STATUS)
  93.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  94.     var %uptime = $hget(RADIO,UPTIME)
  95.     if (!%uptime) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is NOT online! }
  96.     elseif (%uptime) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio uptime is:  $+ $duration(%uptime) $+  }
  97.   }
  98.   if ($1 == !bitrate) || ($1 == !bits) || ($1 == !bitrates) {
  99.     var %err = $get_radio
  100.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  101.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  102.     var %st = $hget(RADIO,STATUS)
  103.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  104.     var %bits = $hget(RADIO,BITRATE)
  105.     if (!%bits) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is NOT online! }
  106.     elseif (%bits) { .msg $chan ( $+ $nick $+ ): Radio Bitrate -  $+ %bits $+ kbps $+  }
  107.   }
  108.   if ($1 == !listen) {
  109.     if (!%radio_ip) { .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio does not has an IP/Host set! | return }
  110.     if (!%radio_port) { .msg $chan ( $+ $Nick $+ ): Error, The ShoutCast Radio does NOT has an Port set! | return }
  111.     .msg $chan ( $+ $nick $+ ): Listen us now from -  $+ http:// $+ %radio_ip $+ : $+ %radio_port $+ /listen.pls $+ 
  112.   }
  113.   if ($1 == !info) || ($1 == !np) || ($1 == !stats) {
  114.     var %err = $get_radio
  115.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  116.     if (%err == 2) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  117.     var %st = $hget(RADIO,STATUS)
  118.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  119.     var %dj = $iif($hget(RADIO,DJ),$v1,N/A)
  120.     var %song = $iif($hget(RADIO,SONG),$v1,N/A)
  121.     var %bits = $iif($hget(RADIO,BITRATE),$v1,0)
  122.     var %max_l = $iif($hget(RADIO,MAXLISTENERS),$v1,0)
  123.     var %listeners = $iif($hget(RADIO,LISTENERS),$v1,0)
  124.     var %genre = $iif($hget(RADIO,GENRE),$v1,N/A)
  125.     var %uptime = $iif($hget(RADIO,UPTIME),$duration($v1),N/A)
  126.     .msg $chan ( $+ $nick $+ ): Now Playing -  $+ %song $+  - DJ:  $+ %dj $+  - Listener(s):  $+ %listeners $+ / $+ %max_l $+  - Genre:  $+ %genre $+  - Bitrate:  $+ %bits $+ kbps $+  - Stream Uptime:  $+ %uptime $+  - Listen us now from:  $+ http:// $+ %radio_ip $+ : $+ %radio_port $+ /listen.pls $+ 
  127.   }
  128.   if ($1 == !radiohelp) { .msg $chan ( $+ $Nick $+ : Radio Commands are: !song - !dj - !peak - !listeners - !bits - !info - !listen - !radiostatus - !radiouptime - !radiostart - !radiostop - !radioip - !radioport }
  129. }
  130.  
  131. alias radio_say {
  132.   if ($status !== connected) { return }
  133.   if (!$1) { return }
  134.   if ($me !ison $1) { return }
  135.   var %old = $hget(RADIO,SONG)
  136.   var %err = $get_radio
  137.   if (%err == 1) { radio_stop | .msg $1 Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  138.   if (%err == 2) { radio_stop | .msg $1 Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred! | return }
  139.   var %st = $hget(RADIO,STATUS)
  140.   if (!%st) { radio_stop | .msg $1 The ShoutCast Radio is currently offline, the auto announce will be now disable! | return }
  141.   var %new = $hget(RADIO,SONG)
  142.   var %dj = $iif($hget(RADIO,DJ),$v1,N/A)
  143.   var %song = $iif($hget(RADIO,SONG),$v1,N/A)
  144.   var %bits = $iif($hget(RADIO,BITRATE),$v1,N/A)
  145.   var %max_l = $iif($hget(RADIO,MAXLISTENERS),$v1,N/A)
  146.   var %listeners = $iif($hget(RADIO,LISTENERS),$v1,N/A)
  147.   var %genre = $iif($hget(RADIO,GENRE),$v1,N/A)
  148.   var %uptime = $iif($hget(RADIO,UPTIME),$duration($v1),N/A)
  149.   if (%old !== %new) { .msg $1 Now Playing -  $+ %song $+  - DJ:  $+ %dj $+  - Listener(s):  $+ %listeners $+ / $+ %max_l $+  - Genre:  $+ %genre $+  - Bitrate:  $+ %bits $+ kbps $+  - Stream Uptime:  $+ %uptime $+  - Listen us now from:  $+ http:// $+ %radio_ip $+ : $+ %radio_port $+ /listen.pls $+  }
  150. }
  151.  
  152. alias radio_stop { unset %radio | .timer[RADIO_AUTO] off }
  153. alias radio_start {
  154.   if ($status !== connected) { return }
  155.   if (!%radio) { return }
  156.   if (!%radio_chan) { return }
  157.   if ($hget(RADIO)) { hfree $v1 }
  158.   .timer[RADIO_AUTO] 0 10 radio_say %radio_chan
  159. }
  160.  
  161. alias get_radio {
  162.   if ($status !== connected) { return }
  163.   if (!%radio_ip) && (!%radio_port) {
  164.     if ($isid) { return 1 }
  165.     return
  166.   }
  167.   var %v = radio_ $+ $ticks $+ $ctime
  168.   var %u = http:// $+ %radio_ip $+ : $+ %radio_port $+ /statistics?json=1&nocache= $+ $ticks
  169.   JSONOpen -du %v %u
  170.   if ($JSONError) {
  171.     if ($isid) { return 2 }
  172.     return
  173.   }
  174.   hadd -m RADIO STATUS $json(%v,streams,0,streamstatus)
  175.   hadd -m RADIO PEAK $json(%v,streams,0,peaklisteners)
  176.   hadd -m RADIO SONG $json(%v,streams,0,songtitle)
  177.   hadd -m RADIO DJ $json(%v,streams,0,dj)
  178.   hadd -m RADIO GENRE $json(%v,streams,0,servergenre)
  179.   hadd -m RADIO UPTIME $json(%v,streams,0,streamuptime)
  180.   hadd -m RADIO BITRATE $json(%v,streams,0,bitrate)
  181.   hadd -m RADIO LISTENERS $json(%v,streams,0,currentlisteners)
  182.   hadd -m RADIO MAXLISTENERS $json(%v,streams,0,maxlisteners)
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement