Jump to content

Archived

This topic is now archived and is closed to further replies.

chain

mIRC Radio Bot v2

Recommended Posts

  • Administrators
The Originaly Script is not written by me, this is a Modification of "mIRC ShoutCast Bot v.1

http://www.hawkee.com/snippet/8647/

 

Originaly Written By: dsabecky

Rewritted and Rebuilded By: ProIcons

 

I wrote this Script after request from users to be compatible with the new version of Shoutcast...

 

 

This script allows for a simple Radio stream management bot to reside in your channel, while announcing current playing songs.

 

Configure:

Just set them from the Popping up Dialog...

 

It includes:

* Auto announce (for songs on the shoutcast stream)

* Manage topic (changes topic when DJ changes)

* Auto connect / identify (Anope/IRCServices.za; nickserv)

 

Commands (that require the user to have @op to use):

!kickdj - kicks active dj

!info - notices user stream information (eg: url, port, dj pass, etc)

!cycle - bot does a /hop

 

Commands (anyone can use):

!dj - notices user current DJ

!song - notices user current song

!tune/!url/!listen - notices user the link to the stream

!listeners - notices the user with current listener amount

!stats - notices user a quick summary of stream info (dj, genre, bitrate, listeners, etc)

 

Changelog:

2.0 - My Version

-Compatible with ShoutCast 1.*

-Compatible With ShoutCast 2.*

-Compatible With IceCast

-New XML Parser

-New Socket System

-New Text Management System

-Dialog Panel Added

 

1.1

Rewrote the XML parser which fixes the song announce loop.

 

1.0.1

Fixed issue with topic not updating properly.

 

1.0

Initial version.

 

 

 

>; This code is released under the public domain.;:::::::::::::::::::::;:  Load variables  ::;:::::::::::::::::::::on *:start: {  dialog -md Panel panel  ;; connection command (DO NOT modify this)  if (!%bot.nick) server %irc.server %irc.port -i %bot.nick %bot.anick %bot.user %bot.name};:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;: %rd.status (0 for offline, 1 for online) | %rd.bitrate (bitrate)		 ::;: %rd.clisten (current listeners)		  | %rd.song (current song)	   ::;: %rd.dj (current DJ, pulled from AIM tag) | %cfg.site (website url)	   ::;: %rd.plisten (peak listeners)			 | %rd.genre (genre)			 ::;: %rd.mlisten (max listeners)			  | %rd.type (IceCast/ShoutCast)  ::;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::; Channel topic (bot needs @op to change)alias rd.title { topic %irc.chan 07,01 $+ %cfg.name $+ 15,01 Do you want fries with that? 14,01 $+ $chr(124) 07,01Current DJ14,01:15,01 $iif(%rd.status == 1, %rd.dj, None) 14,01 $+ $chr(124) 07,01Tune14,01:15,01 %cfg.site }; Message formatalias rd.msg { msg %irc.chan %rd.dj is streaming %rd.song ( $+ %rd.bitrate $+ kbps) };::::::::::::!!! DO NOT MODIFY BELOW UNLESS YOU KNOW WHAT YOU'RE DOING !!!::::::::::::; Connect to SHOUTcast serveralias rd.con {  if (!$sock(radio)) { sockopen radio %cfg.stream %cfg.port }  elseif ($sock(radio)) { sockclose radio | sockopen radio %cfg.stream %cfg.port }}; Kick DJ commandalias rd.kick { sockopen rdkick %cfg.stream %cfg.port }; Send error message to useralias errmsg {  if ($1 == op) { notice $2 You must have @ (operator) status to use this. }  elseif ($1 == offline) { notice $2 The stream is currently offline. }};:::::::::::::::::::::::::;:  Connect & Identify  ::;:::::::::::::::::::::::::on *:notice:*This nickname is registered and protected.*:*: { .msg NickServ IDENTIFY %irc.pass }on *:notice:*Password accepted - you are now recognized.*:*: { .join %irc.chan }on *:disconnect: { timers off }on *:join:%irc.chan: { $iif($nick == $me, .timercon 0 10 rd.con) }on *:kick:%irc.chan: { $iif($knick == $me, timers off) }on *:part:%irc.chan: { $iif($nick == $me, timers off) };::::::::::::::::::::::::;:  Trigger functions  ::;::::::::::::::::::::::::alias isop1 { if ($nick !isop %irc.chan) { errmsg op $nick | halt } }on *:text:*:%irc.chan:{  if ($1 == !cycle) {	isop1	hop %irc.chan  }  elseif ($1 == !info) {	isop1	notice $nick host: %cfg.stream port: %cfg.port pass: %cfg.djpass	notice $nick description: %cfg.name url: %cfg.site aim: your DJ name irc: %irc.chan  }  elseif ($1 == !kickdj) {	isop1	rd.kick	msg %irc.chan Kicking current DJ..  }  elseif ($1 == !dj) {	if (%rd.status == 1) { notice $nick Current DJ: %rd.dj }	else { notice $nick Nobody is currently DJing. }  }  elseif ($1 == !song) {	if (%rd.status == 1) { notice $nick Playing: %rd.song }	else { notice $nick Nobody is currently DJing. }  }  elseif ($1 == !stats) {	if (%rd.status == 1) {	  notice $nick General: dj= $+ %rd.dj $+ $chr(59) genre= $+ %rd.genre $+ $chr(59) bitrate= $+ %rd.bitrate $+ kbps $+ $chr(59)	  notice $nick Listeners: cur= $+ %rd.clisten $+ $chr(59) peak= $+ %rd.plisten $+ $chr(59) max= $+ %rd.mlisten $+ $chr(59)	}	else { notice $nick Stream: is currently offline }  }  elseif ($1 == !Tune) || ($1 == !url) || ($1 == !listen) { notice $nick Tune in at: http:// $+ %cfg.stream $+ : $+ %cfg.port $+ /listen.pls }  elseif ($1 == !listeners) {	if (%rd.status == 1) { notice $nick Listeners: %rd.clisten $+ / $+ %rd.mlisten ( $+ %rd.dj $+ ) }	else { errmsg offline $nick }  }};:::::::::::::::::::::::;:  Socket functions  ::;:::::::::::::::::::::::on *:sockopen:rdkick: {  var %x = $sockname  if (%rd.type == ShoutCast.1) { var %z = /admin.cgi?mode=kicksrc }  if (%rd.type == ShoutCast.2) { var %z = /admin.cgi?sid=1&mode=kicksrc }  if (%rd.type == IceCast) { var %z = /admin//killsource.xsl?mount= $+ %cfg.mount }  sockwrite -nt %x GET /admin.cgi?sid=1&mode=kicksrc HTTP/1.1  sockwrite -nt %x Accept: */*  sockwrite -nt %x User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.642.2 Safari/534.16  sockwrite -nt %x Authorization: Basic $encode(%cfg.user $+ : $+ %cfg.pass, m)  sockwrite -nt %x Host: $+(%cfg.stream,:,%cfg.port)  sockwrite -nt %x Connection: Keep-Alive  sockwrite -nt %x $crlf}on *:sockread:rdkick: {  sockread -fn %tmp  if (302 Found isin %tmp) { msg %irc.chan DJ kicked. Go go go! }}on *:sockopen:radio: {  var %x = $sockname  if (%rd.type == ShoutCast.1) { var %z = /admin.cgi?mode=viewxml }  if (%rd.type == ShoutCast.2) { var %z = /admin.cgi?sid=1&mode=viewxml }  if (%rd.type == IceCast) { var %z = /admin/stats.xml }  sockwrite -nt %x GET %z HTTP/1.1  sockwrite -nt %x Accept: */*  sockwrite -nt %x User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.642.2 Safari/534.16  sockwrite -nt %x Authorization: Basic $encode(%cfg.user $+ : $+ %cfg.pass, m)  sockwrite -nt %x Host: $+(%cfg.stream,:,%cfg.port)  sockwrite -nt %x Connection: Keep-Alive  sockwrite -nt %x $crlf  ;Counter For XML Parsing  set %rd.x 0  ;Protection For Crashes  set %rd.p 0}alias bdata {  if (%rd.type == ShoutCast.2) {	;Reading ShoutCast 2.* Data	var %tmp = $bvar(&tmp,1175,800).text	var %tmp = $replace(%tmp,><,> $+ $chr(32) $+ <)  }  if (%rd.type == ShoutCast.1) {	;Reading ShoutCast 1.* Data	var %tmp = $bvar(&tmp,2018,900).text	var %tmp = $replace(%tmp,><,> $+ $chr(32) $+ <)  }  if (%rd.type == IceCast) {	;Reading IceCast *.* Data	var %s = $bfind(&tmp , 1, mount=" $+ %cfg.mount $+ ">)	var %f = $bfind(&tmp , %s, </source>)	var %tmp = $bvar(&tmp,%s,$calc(%f - %s)).text	var %tmp = $replace(%tmp,><,> $+ $chr(32) $+ <,mount=" $+ %cfg.mount $+ ">,$null)  }  ;DJ  var %dj = $iif($xmltake(%tmp,AIM),$v1,Playlist)  if ($iif(%rd.dj,$v1,0) != %dj) { set %rd.dj $v2 | rd.title }  ; Bitrate  set %rd.bitrate $xmltake(%tmp,bitrate)  ; Stream status  var %status = $iif($xmltake(%tmp,STREAMSTATUS),$v1,$xmltake(%tmp,PUBLIC))  if (%rd.status != %status) { set %rd.status $v2 | rd.title }  ; Song title  var %song = $iif($xmltake(%tmp,title),$v1,$xmltake(%tmp,songtitle))  if (%rd.song != $iif(%song,$v1,No Title Present)) { set %rd.song $v2 | rd.msg }  ; Current listeners    var %clisteners = $iif($xmltake(%tmp,CURRENTLISTENERS) != $null,$v1,$xmltake(%tmp,listeners))  set %rd.clisten %clisteners  ; Peak listeners  var %plisteners = $iif($xmltake(%tmp,LISTENER_PEAK) != $null,$v1,$xmltake(%tmp,PEAKlisteners))  set %rd.plisten %plisteners  ; Max listeners  var %mlisteners = $iif($xmltake(%tmp,max_listeners) != $null,$v1,$xmltake(%tmp,maxlisteners))  set %rd.mlisten %mlisteners  ; Genre  var %genre = $iif($xmltake(%tmp,genre) != $null,$v1,$xmltake(%tmp,servergenre))  set %rd.genre %genre}alias xmltake {  if ($wildtok($1,*< $+ $2 $+ >*,1,32)) {	return $remove($gettok($1,$findtok($1,$wildtok($1,*< $+ $2 $+ >*,1,32),1,32) $+ - $+ $findtok($1,$wildtok($1,*</ $+ $2 $+ >*,1,32),1,32),32),< $+ $2 $+ >,</ $+ $2 $+ >)  }  else { return }}on *:sockread:radio: {  if (%rd.type = ShoutCast.2) {	:ShoutCast2	inc %rd.p	if (%rd.p > 10) { sockclose $sockname | halt }	if (%rd.x == 1) {	  sockread -f &tmp	  ;echo -a [Data] Data Saved [Bytes: $bvar(&tmp,0) $+ ]	  bdata	  var %p = 1	}	sockread -f %tmp	if (<?xml isin %tmp) { ;echo -a [XML] XML Header Passed | inc %rd.x }	if (!%p) goto ShoutCast2  }  elseif (%rd.Type == ShoutCast.1) {	:ShoutCast1	inc %rd.p	if (%rd.p > 5) { sockclose $sockname | halt }	if (%rd.x == 1) {	  sockread -f &tmp	  if (*<?xml* iswm $bvar(&tmp,1,8).text) {		;echo -a [XML] XML Header Passed		;echo -a [Data] Data Saved [Bytes: $bvar(&tmp,0) $+ ]		bdata		var %p = 1	  }	}	sockread -f %tmp	if (*Content-Type:text/xml* iswm %tmp) { set %rd.x 1 }	if (!%p) goto ShoutCast1  }  elseif (%rd.Type == IceCast) {	:IceCast	inc %rd.p	if (%rd.p > 8) { sockclose $sockname | halt }	if (%rd.x == 1) {	  sockread -f &tmp	  ;echo -a [Data] Data Saved [Bytes: $bvar(&tmp,0) $+ ]	  bdata	  var %p = 1	}	sockread -f %tmp	if (<?xml isin %tmp) { ;echo -a [XML] XML Header Passed | inc %rd.x }	if (!%p) goto IceCast  }};:::::::::::::::::::::::;:  Dialog functions  ::;:::::::::::::::::::::::dialog panel {  title "RadioBot v2 - Panel"  size -1 -1 180 154  option dbu  combo 1, 1 38 73 57, size drop  box "Server Info", 2, 76 0 102 60  text "Stream IP", 3, 80 9 35 8, right  text "Stream Port", 4, 80 19 35 8, right  text "Admin User", 5, 80 29 35 8, right  text "Admin Pass", 6, 80 39 35 8, right  text "Mount", 7, 80 49 35 8, hide right  edit "", 8, 116 8 59 10, autohs  edit "", 9, 116 18 59 10, autohs  edit "", 10, 116 28 59 10, autohs  edit "", 11, 116 38 59 10, pass autohs  edit "", 12, 116 48 59 10, hide autohs  box "Irc Info", 13, 76 61 102 89  text "IRC Nick", 14, 80 69 35 8, right  text "IRC Alt Nick", 15, 80 79 35 8, right  text "IRC User", 16, 80 89 35 8, right  text "IRC Name", 17, 80 99 35 8, right  text "IRC Server", 18, 80 109 35 8, right  text "IRC Port", 19, 80 119 35 8, right  text "IRC Nick Pass", 20, 80 129 35 8, right  box "Misc Info", 21, 1 0 73 37  edit "", 22, 24 8 47 10, autohs  text "Site", 23, 4 9 19 8, right  text "Radio Name", 24, 4 19 19 15, right  edit "", 25, 24 18 47 17, autovs multi  edit "", 26, 116 68 59 10, autohs  edit "", 27, 116 78 59 10, autohs  edit "", 28, 116 88 59 10, autohs  edit "", 29, 116 98 59 10, autohs  edit "", 30, 116 108 59 10, autohs  edit "", 31, 116 128 59 10, pass autohs  edit "", 32, 116 118 59 10, autohs  box "About", 33, 1 51 74 46  text "Radio Bot v2 ", 34, 4 59 68 9, center  text "Originaly Writed by dsabecky", 35, 2 71 71 8  text "Rewrited & Rebuilded by ProIcons", 36, 2 80 71 14, center  button "Apply Changes", 38, 1 99 74 12  edit "", 39, 116 138 59 10, autohs  text "IRC Chan", 40, 80 139 35 8, right}alias l {  if ($1 == 8) return cfg.stream  if ($1 == 9) return cfg.port  if ($1 == 10) return cfg.user  if ($1 == 11) return cfg.pass  if ($1 == 12) return cfg.mount  if ($1 == 22) return cfg.site  if ($1 == 25) return cfg.name  if ($1 == 26) return bot.nick  if ($1 == 27) return bot.anick  if ($1 == 28) return bot.user  if ($1 == 29) return bot.name  if ($1 == 30) return irc.server  if ($1 == 31) return irc.pass  if ($1 == 32) return irc.port  if ($1 == 39) return irc.chan}on *:dialog:panel:*:*:{  if ($devent == init) {	did -a $dname 1 ShoutCast 1.*	did -a $dname 1 ShoutCast 2.*	did -a $dname 1 IceCast *.*	did -a $dname 8 $iif(%cfg.stream,$v1,$null)	did -a $dname 9 $iif(%cfg.port,$v1,$null)	did -a $dname 10 $iif(%cfg.user,$v1,$null)	did -a $dname 11 $iif(%cfg.pass,$v1,$null)	did -a $dname 12 $iif(%cfg.mount,$v1,$null)	did -a $dname 22 $iif(%cfg.site,$v1,$null)	did -a $dname 25 $iif(%cfg.name,$v1,$null)	did -a $dname 26 $iif(%bot.nick,$v1,$null)	did -a $dname 29 $iif(%bot.name,$v1,$null)	did -a $dname 27 $iif(%bot.anick,$v1,$null)	did -a $dname 28 $iif(%bot.user,$v1,$null)	did -a $dname 30 $iif(%irc.server,$v1,$null)	did -a $dname 32 $iif(%irc.port,$v1,$null)	did -a $dname 31 $iif(%irc.pass,$v1,$null)	did -a $dname 39 $iif(%irc.chan,$v1,$null)	if (%rd.type == IceCast) { .timer -ms 1 0300 did -kc $dname 1 3 }	if (%rd.type == ShoutCast.2) { .timer -ms 1 0300 did -kc $dname 1 2 }	if (%rd.type == ShoutCast.1) { .timer -ms 1 0300 did -kc $dname 1 1 }  }  if ($devent == close) {	.timer 1 0 dialog -md panel panel  }  if ($devent == sclick) {	if ($did == 1) {	  if ($did($dname,1).seltext == IceCast *.*) { did -v $dname 7,12 | set %rd.type Icecast }	  elseif ($did($dname,1).seltext == ShoutCast 1.*) { did -h $dname 7,12 | set %rd.type ShoutCast.1 }	  elseif ($did($dname,1).seltext == ShoutCast 2.*) { did -h $dname 7,12 | set %rd.type ShoutCast.2 }	}	if ($did == 38) { server %irc.server %irc.port -i %bot.nick %bot.anick %bot.user %bot.name }  }  if ($devent == edit) {	if ($did == 9) {	  if ($did($dname,9).text !isnum 0-9) {		var %t = $did($dname,9).text		var %i = 1		while (%i <= $len(%t) ) {		  if ($mid(%t,%i,1) !isnum 0-9) { did -ra $dname 9 $remove(%t,$v1) }		  inc %i		}	  }	  set %cfg.port $did($dname,$did).text	}	if ($did == 8) || ($did isnum 10-12) || ($did isnum 25-32) || ($did == 22) || ($did == 39) { set % [ $+ [ $l($did) ] ] $did($dname,$did).text }	if ($did == 32) {	  if ($did($dname,32).text !isnum) {		var %t = $did($dname,32).text		if ($mid(%t,1,1) !isnum 0-9) && ($mid(%t,1,1) != +) { did -ra $dname 32 $remove(%t,$v1) }		var %i = 2		while (%i <= $len(%t) ) {		  if ($mid(%t,%i,1) !isnum 0-9) { did -ra $dname 32 $remove(%t,$v1) }		  inc %i		}	  }	  set %irc.port $did($dname,32).text	}  }}

Link to comment
Share on other sites



×
×
  • Create New...