Advertisement
westor

ShoutCast Radio Bot v2.0 for Wikked

Jun 15th, 2015
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 13.47 KB | None | 0 0
  1. ON *:JOIN:#test_chan: {
  2.   if ($nick != $me) { mode $chan +v $nick }
  3.   elseif ($nick == $me) { set %radio 1 | radio_start }
  4. }
  5. ON *:PART:#test_chan: { if ($nick == $me) { radio_stop } }
  6. ON *:KICK:#test_chan: { if ($knick == $me) { radio_stop } }
  7.  
  8. ON *:TEXT:!*:#test_chan: {
  9.   tokenize 32 $strip($1-)
  10.   if ($1 == !radiohost) || ($1 == !radioip) {
  11.     if ($nick !isop $chan) { .msg $chan ( $+ $nick $+ ): You are NOT an channel moderator! | return }
  12.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a host/ip! | return }
  13.     if (*:* iswm $2) { .msg $chan ( $+ $nick $+ ): Error, Please specify only an host/ip address without the port! | return }
  14.     if ($2 == %radio_ip) { .msg $chan ( $+ $nick $+ ): Error, Already the same, Please specify an other value! | return }
  15.     radio_stop
  16.     set %radio_ip $2
  17.     .msg $chan ( $+ $nick $+ ): The ShoutCast Radio host/ip has been set successfully.
  18.   }
  19.   if ($1 == !radioport) {
  20.     if ($nick !isop $chan) { .msg $chan ( $+ $nick $+ ): You are NOT an channel moderator! | return }
  21.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify an port! | return }
  22.     if ($2 !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please specify valid port! | return }
  23.     if ($2 == %radio_port) { .msg $chan ( $+ $nick $+ ): Error, Already the same, Please specify an other value! | return }
  24.     radio_stop
  25.     set %radio_port $2
  26.     .msg $chan ( $+ $nick $+ ): The ShoutCast Radio port has been set successfully.
  27.   }
  28.   if ($1 == !radiostart) {
  29.     if ($nick !isop $chan) { .msg $chan ( $+ $nick $+ ): You are NOT an channel moderator! | return }
  30.     if (%radio) { .msg $chan ( $+ $nick $+ ): Error, Already running! | return }
  31.     set %radio 1
  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.     radio_stop
  39.     .msg $chan ( $+ $nick $+ ): The ShoutCast Radio auto announce has been stopped.
  40.   }
  41.   if ($1 == !lastsong) {
  42.     var %lsong = $hget(RADIO,LASTSONG)
  43.     if (!%lsong) { .msg $chan ( $+ $nick $+ ): There is NOT any last song yet played! | return }
  44.     .msg $chan ( $+ $nick $+ ): Last Played Song -  $+ %lsong $+ 
  45.   }
  46.   if ($1 == !song) {
  47.     var %err = $get_radio
  48.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  49.     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 }
  50.     var %st = $hget(RADIO,STATUS)
  51.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  52.     var %song = $hget(RADIO,SONG)
  53.     .msg $chan ( $+ $nick $+ ): Now Playing -  $+ $iif(%song,$v1,N/A) $+ 
  54.   }
  55.   if ($1 == !radiotopic) {
  56.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a text! | return }
  57.     radio_topic $2-
  58.     .msg $chan ( $+ $nick $+ ): The topic has been successfully set.
  59.   }
  60.   if ($1 == !radiostatus) {
  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! - (Radio IP:  $+ $iif(%radio_ip,$v1,N/A) $+ ) - (Radio Port:  $+ $iif(%radio_port,$v1,N/A) $+ ) }
  66.     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) $+ ) }
  67.   }
  68.   if ($1 == !listeners) {
  69.     var %err = $get_radio
  70.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  71.     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 }
  72.     var %st = $hget(RADIO,STATUS)
  73.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  74.     var %max_l = $iif($hget(RADIO,MAXLISTENERS),$v1,0)
  75.     var %listeners = $iif($hget(RADIO,LISTENERS),$v1,0)
  76.     .msg $chan ( $+ $nick $+ ): Listener(s) -  $+ %listeners $+ / $+ %max_l $+ 
  77.   }
  78.   if ($1 == !peak) {
  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 %peak = $hget(RADIO,PEAK)
  83.     if (!%peak) { .msg $chan ( $+ $nick $+ ): There is NOT any peak made yet! }
  84.     elseif (%peak) { .msg $chan ( $+ $nick $+ ): Peak Listener(s) -  $+ %peak $+  }
  85.   }
  86.   if ($1 == !dj) {
  87.     var %err = $get_radio
  88.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  89.     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 }
  90.     var %st = $hget(RADIO,STATUS)
  91.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  92.     var %dj = $hget(RADIO,DJ)
  93.     if (!%dj) { .msg $chan ( $+ $nick $+ ): There is NOT any DJ yet on the descs! }
  94.     elseif (%dj) { .msg $chan ( $+ $nick $+ ): Currently DJ -  $+ %dj $+  }
  95.   }
  96.   if ($1 == !genre) {
  97.     var %err = $get_radio
  98.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  99.     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 }
  100.     var %st = $hget(RADIO,STATUS)
  101.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  102.     var %genre = $hget(RADIO,GENRE)
  103.     if (!%genre) { .msg $chan ( $+ $nick $+ ): There is NOT any GENRE yet has been set on the radio! }
  104.     elseif (%genre) { .msg $chan ( $+ $nick $+ ): Currently Genre -  $+ %genre $+  }
  105.   }
  106.   if ($1 == !radiouptime) {
  107.     var %err = $get_radio
  108.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  109.     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 }
  110.     var %st = $hget(RADIO,STATUS)
  111.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  112.     var %uptime = $hget(RADIO,UPTIME)
  113.     if (!%uptime) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is NOT online! }
  114.     elseif (%uptime) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio uptime is:  $+ $duration(%uptime) $+  }
  115.   }
  116.   if ($1 == !bitrate) || ($1 == !bits) || ($1 == !bitrates) {
  117.     var %err = $get_radio
  118.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  119.     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 }
  120.     var %st = $hget(RADIO,STATUS)
  121.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  122.     var %bits = $hget(RADIO,BITRATE)
  123.     if (!%bits) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is NOT online! }
  124.     elseif (%bits) { .msg $chan ( $+ $nick $+ ): Radio Bitrate -  $+ %bits $+ kbps $+  }
  125.   }
  126.   if ($1 == !listen) || ($1 == !tune) {
  127.     if (!%radio_ip) { .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio does not has an IP/Host set! | return }
  128.     if (!%radio_port) { .msg $chan ( $+ $Nick $+ ): Error, The ShoutCast Radio does NOT has an Port set! | return }
  129.     .msg $chan ( $+ $nick $+ ): Listen us now from -  $+ http:// $+ %radio_ip $+ : $+ %radio_port $+ /listen.pls $+ 
  130.   }
  131.   if ($1 == !info) || ($1 == !np) || ($1 == !stats) {
  132.     var %err = $get_radio
  133.     if (%err == 1) { radio_stop | .msg $chan ( $+ $nick $+ ): Error, The ShoutCast Radio IP or Port are incorrect or not set! | return }
  134.     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 }
  135.     var %st = $hget(RADIO,STATUS)
  136.     if (!%st) { .msg $chan ( $+ $nick $+ ): The ShoutCast Radio is currently offline! | return }
  137.     var %dj = $iif($hget(RADIO,DJ),$v1,N/A)
  138.     var %song = $iif($hget(RADIO,SONG),$v1,N/A)
  139.     var %bits = $iif($hget(RADIO,BITRATE),$v1,0)
  140.     var %max_l = $iif($hget(RADIO,MAXLISTENERS),$v1,0)
  141.     var %listeners = $iif($hget(RADIO,LISTENERS),$v1,0)
  142.     var %genre = $iif($hget(RADIO,GENRE),$v1,N/A)
  143.     var %uptime = $iif($hget(RADIO,UPTIME),$duration($v1),N/A)
  144.     .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 $+ 
  145.   }
  146.   if ($1 == !radiohelp) { .msg $chan ( $+ $Nick $+ : Radio Commands are: !song - !dj - !genre - !lastsong - !peak - !listeners - !bits - !info - !listen - !radiostatus - !radiotopic - !radiouptime - !radiostart - !radiostop - !radioip - !radioport }
  147. }
  148.  
  149. alias radio_topic {
  150.   if (!$1-) { return }
  151.   var %chan = #test_chan
  152.   var %t = $scon(0)
  153.   var %i = 1
  154.   while (%i <= %t) {
  155.     var %s = $scon(%i).cid
  156.     if ($scid(%s).status == connected) {
  157.       var %chans = $mchans(%s)
  158.       if (%chans) && ($istok(%chans,%chan,44)) { scid %s .topic %chan $1- }
  159.     }
  160.     inc %i
  161.   }
  162. }
  163.  
  164. alias radio_msg {
  165.   if (!$1-) { return }
  166.   var %chan = #test_chan
  167.   var %t = $scon(0)
  168.   var %i = 1
  169.   while (%i <= %t) {
  170.     var %s = $scon(%i).cid
  171.     if ($scid(%s).status == connected) {
  172.       var %chans = $mchans(%s)
  173.       if (%chans) && ($istok(%chans,%chan,44)) { scid %s .msg %chan $1- }
  174.     }
  175.     inc %i
  176.   }
  177. }
  178.  
  179. alias mchans {
  180.   if (!$1) { return }
  181.   scid $1
  182.   var %t = $chan(0)
  183.   var %i = 1
  184.   while (%i <= %t) {
  185.     var %c = $chan(%i)
  186.     if ($me isop %c) { var %tot = $addtok(%tot,%c,44) }
  187.     inc %i
  188.   }
  189.   if (%tot) { return %tot }
  190.   elseif (!%tot) { return 0 }
  191. }
  192.  
  193. alias radio_say {
  194.   if ($status !== connected) { return }
  195.   var %old = $hget(RADIO,SONG)
  196.   var %err = $get_radio
  197.   if (%err == 1) {
  198.     radio_stop
  199.     radio_msg Error, The ShoutCast Radio IP or Port are incorrect or not set!
  200.     return
  201.   }
  202.   if (%err == 2) {
  203.     radio_stop
  204.     radio_msg Error, The ShoutCast Radio IP or Port are incorrect, or an connection problem has been occurred!
  205.     return
  206.   }
  207.   var %st = $hget(RADIO,STATUS)
  208.   if (!%st) {
  209.     radio_stop
  210.     radio_msg The ShoutCast Radio is currently offline, the auto announce will be now disable!
  211.     radio_topic 11,1[10Chaotic-Radio is 4Offline11]
  212.     return
  213.   }
  214.   var %new = $hget(RADIO,SONG)
  215.   var %dj = $iif($hget(RADIO,DJ),$v1,N/A)
  216.   var %song = $iif($hget(RADIO,SONG),$v1,N/A)
  217.   var %bits = $iif($hget(RADIO,BITRATE),$v1,0)
  218.   var %max_l = $iif($hget(RADIO,MAXLISTENERS),$v1,0)
  219.   var %listeners = $iif($hget(RADIO,LISTENERS),$v1,0)
  220.   var %genre = $iif($hget(RADIO,GENRE),$v1,N/A)
  221.   var %uptime = $iif($hget(RADIO,UPTIME),$duration($v1),N/A)
  222.   if (!$hget(RADIO,TOPIC)) { hadd -m RADIO TOPIC 1 | radio_topic 11,1[10Chaotic-Radio is 3Online11] }
  223.   if (%old) && (%old !== %new) { hadd -m RADIO LASTSONG %old }
  224.   if (%old !== %new) { radio_msg 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 $+  }
  225. }
  226.  
  227. alias radio_stop {
  228.   unset %radio
  229.   .timer[RADIO_AUTO] off
  230.   if ($hget(RADIO)) { hfree $v1 }
  231. }
  232.  
  233. alias radio_start {
  234.   if ($status !== connected) { return }
  235.   if (!%radio) { return }
  236.   if ($hget(RADIO)) { hfree $v1 }
  237.   .timer[RADIO_AUTO] 0 10 radio_say
  238. }
  239.  
  240. alias get_radio {
  241.   if ($status !== connected) { return }
  242.   if (!%radio_ip) && (!%radio_port) {
  243.     if ($isid) { return 1 }
  244.     return
  245.   }
  246.   var %v = radio_ $+ $ticks $+ $ctime
  247.   var %u = http:// $+ %radio_ip $+ : $+ %radio_port $+ /statistics?json=1&nocache= $+ $ticks
  248.   JSONOpen -du %v %u
  249.   if ($JSONError) {
  250.     if ($isid) { return 2 }
  251.     return
  252.   }
  253.   hadd -m RADIO STATUS $json(%v,streams,0,streamstatus)
  254.   hadd -m RADIO PEAK $json(%v,streams,0,peaklisteners)
  255.   hadd -m RADIO SONG $json(%v,streams,0,songtitle)
  256.   hadd -m RADIO DJ $json(%v,streams,0,dj)
  257.   hadd -m RADIO GENRE $json(%v,streams,0,servergenre)
  258.   hadd -m RADIO UPTIME $json(%v,streams,0,streamuptime)
  259.   hadd -m RADIO BITRATE $json(%v,streams,0,bitrate)
  260.   hadd -m RADIO LISTENERS $json(%v,streams,0,currentlisteners)
  261.   hadd -m RADIO MAXLISTENERS $json(%v,streams,0,maxlisteners)
  262. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement