Eggdrop chat script

PHP, HTML, Joomla, WordPress, etc..
Plaats reactie
Gebruikersavatar
FCR
*
Berichten: 16
Lid geworden op: 30 apr 2011, 10:20
SAM-versie: 4.2.2.*
Database: MySQL 5.0
Windows: XP

Eggdrop chat script

Ongelezen bericht door FCR » 30 apr 2011, 21:39

Verzoek, zoek en announce script(s) voor een Eggdrop bot waarbij het mogelijk is om tussen 2 DJ's te wisselen. ook niet helemaal van mijn hand.. maar handig om te hebben :) demo @ : irc.fcradio.eu:8067 #fc_radio.r

req*.php

Code: Selecteer alles

<html>
<head>
</head>
<body>
<?
// Set the IP for your bot, ou can use * as wildcard
// Remember to set this correctly, or requesting wont work
// Using * will allow exploiting this script, so I suggest you setting the IP of your bot

$ip = "*";

$sam["host"] = "ip.naar.je.sam.doos"; //The IP address of the machine SAM is running on (DO NOT use a local IP address like 127.0.0.1 or 192.x.x.x)
$sam["port"] = "1221";      //The port SAM handles HTTP requests on. Usually 1221.


DEFINE('USER_IP', $_SERVER['REMOTE_ADDR']);
// DEFINE('USER_HOSTNAME', gethostbyaddr($_SERVER['REMOTE_ADDR']));

function Def(&$val, $def = '')
{
 if(empty($val))
   $val = $def;
   
 return $val;
}

function DoError($code)  
{
 global $samhost, $samport, $errno, $errstr;
 
 switch ($code)
 {
  case 800 : $message = "SAM host must be specified"; break;
  case 801 : $message = "SAM host can not be 127.0.0.1 or localhost"; break;
  case 802 : $message = "Song ID must be valid";  break;
  case 803 : $message = "Unable to connect to $samhost:$samport. Station might be offline.<br>The error returned was $errstr ($errno).";  break;
  case 804 : $message = "Invalid data returned!";  break;
 }
 echo "<i>$message</i></body></html>";
 exit;
}

$can_load = FALSE;

$ip = str_replace(".", "\\.", $ip);
$ip = str_replace("*", "[0-9]*", $ip);
$ip = str_replace("?", "[0-9]?", $ip);
if (ereg($ip, USER_IP)) $can_load = TRUE;

if (empty($_GET['host'])) $can_load = FALSE;
if ($can_load) {
		require_once("xml.php");
 
		if (!empty($_GET['songid'])) $songid = $_GET['songid'];
		if (!empty($_POST['songid'])) $songid = $_POST['songid'];

		Def($samhost,$sam["host"]);
		Def($samport,$sam["port"]);
		Def($dedicated,false);
 
		if(empty($samhost)) DoError(800);
		$host = $_SERVER['REMOTE_ADDR'];

		if($songid == -1) DoError(802);

		$request = "GET /req/?songid=".$songid."&host=".$_GET['host']." HTTP\1.0\r\n\r\n";
		$xmldata = "";
		$fd = @fsockopen($samhost,$samport, $errno, $errstr, 30);

		if(!empty($fd))
			{
			fputs ($fd, $request);
			$line="";
			while(!($line=="\r\n"))
			{ $line=fgets($fd,128); }	// strip out the header
			while ($buffer = fgets($fd, 4096))
			{  $xmldata  .= $buffer; }
			fclose($fd);
		}
		else DoError(803);

		if(empty($xmldata)) DoError(804);
  
		//#################################
		//      Initialize data
		//#################################
		$tree = XML2Array($xmldata);
		$request = Keys2Lower($tree["REQUEST"]);
 
		$code    = $request["status"]["code"];
		$message = $request["status"]["message"];
		$requestid = $request["status"]["requestid"];
		if(empty($code)) DoError(804);
 
		if($code==200)
		echo "<b>The request was succesfully sent to the DJ program</b>"; else
		echo "<i>$message</i>";
} else echo "<i>Check the configured IP address</i>";
?>
</body>
</html>
xml.php:

Code: Selecteer alles

<?
//XML handling routines
function GetChildren($vals, &$i)
{
  while($i < count($vals))
  {

    switch ($vals[$i]['type'])
      {
        //case 'cdata':
		case 'complete' :
		if(isset($vals[$i]['attributes']))
		{
			$value = array("attributes" => $vals[$i]['attributes'],
			      "value" => $vals[$i]['value']);
		}
		else
		{
			$value = array("value" => $vals[$i]['value']);
		}
		 $name = $vals[$i]['tag'];
         $children["$name"][] = $value; 
		 
		break;
		
		case 'open'     : 
		 $siblings = GetChildren($vals, ++$i);
		if(isset($vals[$i]['attributes']))
		  {
			$siblings['attributes'] = $vals[$i]['attributes'];
		  }
		 
		 $name = $vals[$i]['tag'];
         $children["$name"][] = $siblings;
		 
		 /*
		 array_push($children,
		  array("attributes" => $vals[$i]['attributes'],
		  "children" => GetChildren($vals, ++$i))
		  );
		  */
		break;
		
		case 'close'    :
		 return $children;
		break;
		
		default : 	 
		 echo "XML error, Unsupported tag type: " . $vals[$i]['type'] . "<br>";
	 }
	
	$i++;
  }
  
 return $children; 
}
  
  function GetXMLTree($data, $uppercase = 1)
  {
    $p = xml_parser_create();
    xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1);
	xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, $uppercase);
	
    xml_parse_into_struct($p, $data, $vals, $index);
    xml_parser_free($p);

    $tree = array();
    $i = 0;

    $tree = GetChildren($vals, $i);
	
    return $tree;
  }
  
//######################################################  
//######################################################
  
function CompackTree($data)
{

 reset($data);
 while(list($key, $value) = each($data))
 {
 
  if(is_array($value))
  {
  
   //SPECIAL HANDLING
   //Make Attributes the Values if value empty
  if(isset($value['attributes']))
   if(is_array($value['attributes']))
    if(!isset($value['value']))
	 {
	   $leaf["$key"] = $value['attributes'];
	   continue;
	 }
   
   $c = count($value);
   
   if($c>1)
   {
    //REMOVE empty Attributes if Value is valid
    if(!((isset($value['attributes'])) && (is_array($value['attributes']))) && (isset($value['value'])))
	  $leaf["$key"] = $value['value'];
	 else
      $leaf["$key"] = CompackTree($value);
   }
   else
   {
     $temp = $value[0];
	 //REMOVE empty Attributes if Value is valid
	if(isset($temp['attributes']))
	{
	 if(!is_array($temp['attributes']) && (isset($temp['value'])))
	  $leaf["$key"] = $temp['value'];
	 else $leaf["$key"] = CompackTree($temp);
	} else if(isset($temp['value']))
		$leaf["$key"] = $temp['value'];
		else $leaf["$key"] = CompackTree($temp);
   }
   
  } 
  else
   $leaf["$key"] = $value;
	 
 }	// while loop
 
 return $leaf;
}
  
  
function XMLToArray($data, $uppercase = 1)
{
 $tree = GetXMLTree($data, $uppercase);
 return CompackTree($tree);
}

function XML2Array($data, $uppercase = 1)
{
 return XMLToArray($data, $uppercase);
}

function XML2Arr($data, $uppercase = 1)
{
 return XMLToArray($data, $uppercase);
}

//######################################################
//######################################################
function ChildKeyIsNum($data)
{
  if(!is_array($data))
   return false;
   
  reset($data);
  list($key, $value) = each($data);
  if(is_numeric($key))
   return true;
  else
   return false;
}

function MakeAttr($data)
{
 if(!is_array($data))
  return "";

 $attr = " ";
 reset($data);
 while(list($key, $value) = each($data)){
   $attr .= " $key=\"$value\"";	 
 }	// while loop

 return $attr;
}

function ArrayToXML($data, $parent = "")
{
 if(empty($parent))
  $xml = '<?xml version="1.0"?>';
 else 
  $xml = "";
  
  reset($data);
  while(list($key, $value) = each($data))
  {
   $attr = "";
   
   if(is_numeric($key))
   {
     $key = $parent;
	 
	 if(!empty($value['attributes']))
   	  $attr = MakeAttr($value['attributes']);
     unset($value['attributes']);
   };
    
	
   if(ChildKeyIsNum($value))
 	$xml .= ArrayToXML($value,$key);
   else if(is_array($value))
    {
      $xml .= "<$key$attr>";
       $xml .= ArrayToXML($value,$key);
	  $xml .= "</$key$attr>";
    }
     else
       $xml .= "<$key$attr>$value</$key>";
  }//while
  
 return $xml;  
}

function Array2XML($data, $parent = "")
{
 return ArrayToXML($data, $parent);
}

function Arr2XML($data, $parent = "")
{
 return ArrayToXML($data, $parent);
}
//######################################################
//######################################################
  

function Keys2Lower($a)
{
 if(!is_array($a))
  return $a;
 
 unset($res);
 
 reset($a);
 while(list($key, $value) = each($a)){

  if(is_array($value))
   $res[strtolower($key)] = Keys2Lower($value);
  else
   $res[strtolower($key)] = $value;
	 
 }	// while loop
 
 return $res;
}

function XMLheader()
{
 header("Content-type: text/xml");
}

function EmptyNodeCleanUp(&$data)
{
 while(list($key, $val) = each($data)){
  if(is_array($val))
   $data[$key] = "";
 }	// while loop
}

function echoXML($xml)
{
  XMLheader();
  
  if(is_array($xml))
   echo Array2XML($xml);
  else
   echo $xml;
}

?>
Requests.tcl:

Code: Selecteer alles

array set userit {};

# Edit the following lines

set serveri ip.naar.sam.doos.1;
set serveri2 ip.naar.sam.doos.2;
set useri samdbuser;
set salasana samdbpass;
set tietokanta samdbdatabeest;

set DJ1 0
set dachan "#kanaal";

# this is the difference of time between windrop/eggdrop computer and mySQL server computer
# for example if the mySQL server time is 4 hours behind your windrop/eggdrop computer, set this to 4
set erotus 7;

# if there is some difference in minutes, set it here
set minutes_d 0;

#set this to 0 if you don't want it to announce any songs playing
#set this to 1 if you want it to announce every dedicated song
#set this to 2 if you want it to announce every played song
set announce_song 2;


# If you have uploaded req2.php to your radio website, and want this bot to use
# it to request songs, set this to 1, and fix the url
set enable_requests 1;
set request_url "url.naar/req1.php";
set request_url2 "url.naar/req2.php";

# if you want the script to announce listener peaks, set this to 1
set announce_listener_peak 1; 

# set your radio relays here
set relays "url van je streamzooi";

# and edit these, if you want.

set listen_trigger "!luisteren";
set listeners_trigger "!luisteraars";
set playing_trigger "!oa";
set next_trigger "!volgende";
set prev_trigger "!vorige";
set search_trigger "!zoek";
set help_trigger "!help";
set req_trigger "!verzoek";
set peak_trigger "!piek";
set triggers_trigger "!commandos";

# ... and end here
# ---------------------------------------------------------
# and I recommend that you don't look at the code below <.<
# it's really messy and not done in the most optimal way :P

set nickz "";
set textz "";
set chanz "";
set nextsong 0;
set nextsong_l 0;
set c_playing 0;

bind pub - $listen_trigger listen;
bind pub - $listeners_trigger listeners;
bind pub - $playing_trigger playing;
bind pub - $next_trigger next;
bind pub - $prev_trigger prev;
bind pub - $search_trigger search;
bind pub - $req_trigger req;
bind pub - $help_trigger help;
bind pub - $peak_trigger peak;
bind pub - $triggers_trigger triggers;

bind msg - $listen_trigger listen_msg;
bind msg - $listeners_trigger listeners_msg;
bind msg - $playing_trigger playing_msg;
bind msg - $next_trigger next_msg;
bind msg - $prev_trigger prev_msg;
bind msg - $search_trigger search_msg;
bind msg - $peak_trigger peak_msg;
bind msg - $help_trigger help_msg;
bind msg - $triggers_trigger triggers_msg;

proc listen_msg { nick user handle text } { listen $nick $user $handle $nick $text; }
proc listeners_msg { nick user handle text } { listeners $nick $user $handle $nick $text; }
proc playing_msg { nick user handle text } { playing $nick $user $handle $nick $text; }
proc next_msg { nick user handle text } { next $nick $user $handle $nick $text; }
proc prev_msg { nick user handle text } { prev $nick $user $handle $nick $text; }
proc search_msg { nick user handle text } { search $nick $user $handle $nick $text; }
proc peak_msg { nick user handle text } { peak $nick $user $handle $nick $text; }
proc help_msg { nick user handle text } { help $nick $user $handle $nick $text; }
proc triggers_msg { nick user handle text } { triggers $nick $user $handle $nick $text; }


bind time - "* * * * *" songi

bind pub - !DJ2 pub_DJ2
bind pub - !DJ1 pub_DJ1

proc pub_DJ1 {nick user handle channel text} {
if {$channel != "#FC_Radio.r"} {return};
global DJ1;
set DJ1 1;
}

proc pub_DJ2 {nick user handle channel text} {
if {$channel != "#FC_Radio.r"} {return};
global DJ1;
set DJ1 0;
}





proc triggers { nick user handle channel text } {
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
		set reqs_on '';
		if {$::enable_requests == 1} {set reqs_on $::req_trigger;}
		putserv "PRIVMSG $channel :\002 FC Radio commandos:\002 $::listeners_trigger $::playing_trigger $::next_trigger $::prev_trigger $::search_trigger $::peak_trigger $::help_trigger $::listen_trigger $reqs_on";
	}
}

proc listen { nick user handle channel text } {
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
		putserv "PRIVMSG $channel :\002 $::relays \002";
	}
}

proc songi { min hour day month year } {
global DJ1;
	global nextsong;
	global nextsong_l;
	global c_playing;
	set hour -1;
	set seuraava 0;
	set time [expr [clock seconds] - ($::erotus * 60 * 60) - ($::minutes_d * 60)];
	set tunti [clock format $time -format %k];
	set minuutti [clock format $time -format %M];
	set sekunti [clock format $time -format %S];
	set aika [clock format $time -format "%a %l:%M %p"];
	set vkpv [clock format $time -format %u];
	regexp {.* (.+?):(.+?):(.+?)} [lindex $nextsong] - hour min sec

	set jee 0;
	regexp {0(.+?)} $minuutti - jee
	if {$jee != 0} {set minuutti $jee}
	set jee 0;
	regexp {0(.+?)} $sekunti - jee
	if {$jee != 0} {set sekunti $jee}

	set nytten [expr ($minuutti * 60) + $sekunti];
	if {$hour != -1} {
		set jee 0;
		regexp {0(.+?)} $hour - jee
		if {$jee != 0} {set hour $jee}
		set jee 0;
		regexp {0(.+?)} $min - jee
		if {$jee != 0} {set min $jee}
		set jee 0;
		regexp {0(.+?)} $sec - jee
		if {$jee != 0} {set sec $jee}

		set seuraava [expr ($min * 60) + $sec];
		if {$tunti > $hour} {
			set nytten [expr $nytten + 3600];
			if {$tunti == 23} {
				set nytten [expr $nytten - 3600];
				set seuraava [expr $seuraava + 3600];
			}
		}
		if {$tunti < $hour} {
			set seuraava [expr $seuraava + 3600];
			if {$hour == 23} {
				set nytten [expr $nytten + 3600];
				set seuraava [expr $seuraava - 3600];
			}
		}
	}

	set continue 0;
	set seuraava [expr $seuraava + $nextsong_l];

	if {$c_playing == 0} {set continue 1;}
	if {$nytten >= $seuraava} {set continue 1;}

	if {$continue == 1} {

if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}
                
                
		mysqluse $h $::tietokanta;
		set biisi [mysqlsel $h "SELECT songlist.artist, songlist.title, songlist.duration, songlist.ID, historylist.requestID, historylist.date_played, songlist.album, historylist.listeners FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY historylist.date_played DESC LIMIT 0, 1" -flatlist];
		if {[file exists "radio_listeners.txt"] == 0} {
			set fl [open "radio_listeners.txt" w]
			puts $fl [lindex $biisi 7];
			close $fl;
			if {$::announce_listener_peak == 1} {
				for {set x 0} {$x < [llength $::dachan]} {incr x} {
					putserv "PRIVMSG [lindex $::dachan $x] :\002Nieuw luisteraar record:\002 Er zijn momenteel [lindex $biisi 7] luisteraars";
				}
			}
		} else {
			set fl [open "radio_listeners.txt" r]
			while {[gets $fl line] >= 0} {
			    set listeners $line;
			}
			close $fl;

			if {$listeners < [lindex $biisi 7]} {
				set fl [open "radio_listeners.txt" w]
				puts $fl [lindex $biisi 7];
				close $fl;
				if {$::announce_listener_peak == 1} {
					for {set x 0} {$x < [llength $::dachan]} {incr x} {
						putserv "PRIVMSG [lindex $::dachan $x] :\002Nieuw luisteraar record:\002 Er zijn momenteel [lindex $biisi 7] luisteraars";
					}
				}
			}
		}
		set nextsong [lindex $biisi 7];
		set nextsong_l [expr [lindex $biisi 2] / 1000];
		if {$c_playing != [lindex $biisi 3]} {
		#	putserv "NOTICE Shaysus : mySQL touched $nytten $seuraava";
			set dedication [mysqlsel $h "SELECT name, msg FROM requestlist WHERE (ID = '[lindex $biisi 4]') LIMIT 0, 1" -flatlist];

			set songid [lindex $biisi 3];
			set duration [expr [lindex $biisi 2] / 1000];
			set min [expr floor($duration / 60.0)];
			set sec [expr $duration - ($min * 60)];
			set min [string replace $min [string first . $min] [string last 0 $min] ""];
			set sec [string replace $sec [string first . $sec] [string last 0 $sec] ""];
			if {[string length $sec] == 1 } {
				set sec "0$sec";
			}
			set time "$min:$sec";
			if {$::announce_song > 0} {
				set announce_it 0;
				set alku "\00300,04 Onair: \003\00304,00 [lindex $biisi 0] - [lindex $biisi 1] \003";
				if {$::announce_song == 1} {
					if {[lindex $dedication 0] != ""} {
						set announce_it 1;
					}
				}
				if {$::announce_song == 2} {
					set announce_it 1;
				}
				if {$announce_it == 1} {
					if {[lindex $dedication 0] != ""} {
						set alku "$alku\002 -=-\002 \00300,04 Aangevraagd door: \003\002 [lindex $dedication 0]\002";
					}
					if {[lindex $dedication 1] != ""} {set alku "$alku - [lindex $dedication 1]";}
					for {set x 0} {$x < [llength $::dachan]} {incr x} {
						putserv "PRIVMSG [lindex $::dachan $x] :$alku";
					}
				}			
			}
			set c_playing [lindex $biisi 3];
		}

		mysqlclose $h;
	}
}

proc peak { nick user handle channel text } {
	global botnick;
global DJ1;
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
#		set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana];
if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}


		mysqluse $h $::tietokanta;
		set biisi [mysqlsel $h "SELECT listeners FROM historylist ORDER BY date_played DESC LIMIT 0, 1" -flatlist]

		if {[file exists "radio_listeners.txt"] == 0} {
			set fl [open "radio_listeners.txt" w]
			puts $fl [lindex $biisi 0];
			close $fl;
			set listeners [lindex $biisi 0];
		} else {
			set fl [open "radio_listeners.txt" r]
			while {[gets $fl line] >= 0} {
			    set listeners $line;
			}
		}
		close $fl;
		mysqlclose $h;
		putserv "PRIVMSG $channel :\002Het huidige luisteraar record is:\002 $listeners luisteraars";
	}
}

proc help { nick user handle channel text } {
	global botnick;

	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
	
	putserv "NOTICE $nick :\0033$botnick commando lijst:\0033";
	putserv "NOTICE $nick :\0033-\0033";
	putserv "NOTICE $nick :\00312$::listeners_trigger\00312 \00314-\00314\0033 Geeft weer hoeveel luisteraars er zijn.";
	putserv "NOTICE $nick :\00312$::playing_trigger\00312 \00314-\00314\0033 Geeft het huidige nummer weer.";
	putserv "NOTICE $nick :\00312$::next_trigger\00312 \00314-\00314\0033 Geeft de volgende nummers weer.";
	putserv "NOTICE $nick :\00312$::prev_trigger\00312 \00314-\00314\0033 Geeft de afgelopen nummers weer";
	putserv "NOTICE $nick :\00312$::peak_trigger\00312 \00314-\00314\0033 Geeft de luisteraarpiek weer.";
	if {$::enable_requests == 1} {putserv "NOTICE $nick :\00312$::req_trigger\00312 \0037<song id>\0037 \00314-\00314\0033 Request a song to be played. Song ID is shown in \0035$::search_trigger\0035\0033\, \0033\0035$::next_trigger\0035\0033\ and \0033\0035$::prev_trigger\0035";}
	putserv "NOTICE $nick :\00312$::search_trigger\00312 \0037<query>\0037 \00314-\00314\0033 Searches songs by \0035Song ID\0035\0033,\0033 \0035Artist\0035\0033,\0033 \0035Song Title\0035\0033,\0033 \0035Album Name\0035";
	putserv "NOTICE $nick :\0033 -> For example \00312$::search_trigger move\00312 \0033will ouput every song with artist, album or song title \0035move\0035";
	putserv "NOTICE $nick :\0033 -> You can use % as wildcard, for example \00312$::search_trigger move%\00312 \0033will ouput every song with artist, album or song title that starts with \0035move\0035";
	}
}

proc req { nick user handle channel text } {
global DJ1;
global nickz;
global textz;
global chanz;
if {$::enable_requests == 1} {
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; set chanz $channel;}
	}
	if { $continue == 1 } {

	if { $text == "" } {
		putserv "NOTICE $nick :\00312Gee een SongID,... begin te geven!\00312";
	}
	if { $text != "" } {
	set nickz $nick;
	set textz $text;
if {$DJ1 == 0} {set sock [egghttp:geturl "$::request_url?songid=$text&host=$user" connect_callback]}
                 
if {$DJ1 == 1} {set sock [egghttp:geturl "$::request_url2?songid=$text&host=$user" connect_callback]}

}
}
}
}

proc connect_callback {sock} {
global DJ1;
	set html [egghttp:data $sock]
	regsub -all "\n" $html "" html
#	putserv "NOTICE SharkMa-san : $html";
	regexp {<body><i>(.+?)</i></body>} $html - failure
	regexp {<body><b>(.+?)</b></body>} $html - success;

#	set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana];
if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}

	mysqluse $h $::tietokanta;

#	set tekstii [lrange [split $textz " "] 1 end];
#	set textz [lindex [split $textz " "] 0];
	set biisi [mysqlsel $h "SELECT artist, title, duration, album FROM songlist WHERE ID = '$::textz'" -flatlist];

	if { [lindex $biisi 0] == "" } {
		putserv "PRIVMSG $::chanz :\002$::nickz:\002 Je verzoek is mislukt omdat: je het verkeerde SongID hebt gebruikt";
	}

	if { [lindex $biisi 0] != "" } {

		set duration [lindex $biisi 2];
		set duration [expr $duration / 1000];
		set min [expr floor($duration / 60.0)];
		set sec [expr $duration - ($min * 60)];
		set min [string replace $min [string first . $min] [string last 0 $min] ""];
		set sec [string replace $sec [string first . $sec] [string last 0 $sec] ""];
		if {[string length $sec] == 1 } {
			set sec "0$sec";
		}
		set time "$min:$sec";
		set kappale "\002 [lindex $biisi 0] - [lindex $biisi 1] ($time) ([lindex $biisi 3])\002";

	      if {[info exists failure] == 0} {
			if {[info exists success] == 0} { 
				putserv "PRIVMSG $::chanz :\002$::nickz:\002 Je verzoek is mislukt omdat::\002 No #$%§@ idea\002 -=- $kappale";
			}
		}
	      if {[info exists success] != 0} { 
			putserv "PRIVMSG $::chanz :\002$::nickz:\002 Je verzoek is succesvol aangevraagd: \002 -=- $kappale\002";
		}
	      if {[info exists failure] != 0} { 
			putserv "PRIVMSG $::chanz :\002$::nickz:\002 Je verzoek is mislukt, omdat:\002 $failure\002 -=- $kappale";
		}
	}
	mysqlclose $h;
	egghttp:cleanup $sock
	#putserv "PRIVMSG $::dachan :\0034$html\0034";
}

proc search { nick user handle channel text } {
global DJ1;
	global search_trigger;
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
	if {$text == ""} {putserv "NOTICE $nick :\00312Gebruik een trefwoord bv.:\00312\0033 $search_trigger trefwoord";}

	if {$text != ""} {

	regsub -all "\'" $text "\\'" text

#	set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana];
if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}

	mysqluse $h $::tietokanta;

	mysqlsel $h "SELECT artist, title, duration, ID, album FROM songlist WHERE (title like '$text') OR (artist like '$text') OR (album like '$text') OR (ID = '$text') ORDER BY rating DESC LIMIT 0, 10";
	set i 0;
	mysqlmap $h {artist title duration id album} {
	
		set duration [expr $duration / 1000];
		set min [expr floor($duration / 60.0)];
		set sec [expr $duration - ($min * 60)];
		set min [string replace $min [string first . $min] [string last 0 $min] ""];
		set sec [string replace $sec [string first . $sec] [string last 0 $sec] ""];
		if {[string length $sec] == 1 } {
			set sec "0$sec";
		}
		set time "$min:$sec";
		incr i;
		putserv "NOTICE $nick :->\00312 $id\00312 -\0033 $artist - $title \0033\00310($time)\00310 \0037($album)\0037";
	}

	if { $i == 0 } { putserv "NOTICE $nick :\00312Helaas, maar ik kon geen enkel nummer voor je vinden\00312";
		putserv "NOTICE $nick :\00312Als je problemen hebt met het vinden van nummers gebruik dan % als wildcard\00312";
		putserv "NOTICE $nick :\00312Bijvoorbeeld:\00312\0033 $search_trigger trefwoord% \0033\00312 zoekt naar titels of artiesten dat begint met \00312\0033trefwoord\0033";
	}
	mysqlclose $h;
	}
	}
}

proc playing { nick user handle channel text } {
global DJ1;
	global userit;
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
#	set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana];
if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}
	mysqluse $h $::tietokanta;
	mysqlsel $h "SELECT songlist.artist, songlist.title, songlist.duration, songlist.ID, songlist.album FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY historylist.date_played DESC LIMIT 0, 1";
	mysqlmap $h {artist title duration id album} {
	
		set songid $id;
		set duration [expr $duration / 1000];
		set min [expr floor($duration / 60.0)];
		set sec [expr $duration - ($min * 60)];
		set min [string replace $min [string first . $min] [string last 0 $min] ""];
		set sec [string replace $sec [string first . $sec] [string last 0 $sec] ""];
		if {[string length $sec] == 1 } {
			set sec "0$sec";
		}
		set time "$min:$sec";
		set alku "\00304,00Momenteel ON-AIR via http://www.fcradio.eu\003 :  $artist \002-\002 $title";
	}

	putserv "PRIVMSG $channel :$alku";
	mysqlclose $h;
	}
}

proc next { nick user handle channel text } {
global DJ1;
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
#	set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana];
if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}
	mysqluse $h $::tietokanta;
	mysqlsel $h "SELECT songlist.ID, songlist.artist, songlist.title, songlist.duration, songlist.album FROM queuelist, songlist WHERE (queuelist.songID = songlist.ID)  AND (songlist.songtype='S') AND (songlist.artist <> '') ORDER BY queuelist.sortID ASC LIMIT 0, 5";
	set i 0;
	mysqlmap $h {songid artist title duration album} {

		set duration [expr $duration / 1000];
		set min [expr floor($duration / 60.0)];
		set sec [expr $duration - ($min * 60)];
		set min [string replace $min [string first . $min] [string last 0 $min] ""];
		set sec [string replace $sec [string first . $sec] [string last 0 $sec] ""];
		if {[string length $sec] == 1 } {
			set sec "0$sec";
		}
		set time "$min:$sec";
		if { $i == 0 } { set result "\002Zometeen op FC Radio:\002 $artist \002-\002 $title"; }
		if { $i != 0 } { set result "$result \002-=-\002 $artist \002-\002 $title"; }
		incr i;
	}
	putserv "PRIVMSG $channel :$result";
	mysqlclose $h;
	}
}

proc prev { nick user handle channel text } {
global DJ1;
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
#	set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana];
if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}
	mysqluse $h $::tietokanta;
	mysqlsel $h "SELECT songlist.ID, songlist.artist, songlist.title, songlist.duration, songlist.album FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY historylist.date_played DESC LIMIT 1, 2"

	set i 0;
	mysqlmap $h {songid artist title duration album} {

		set duration [expr $duration / 1000];
		set min [expr floor($duration / 60.0)];
		set sec [expr $duration - ($min * 60)];
		set min [string replace $min [string first . $min] [string last 0 $min] ""];
		set sec [string replace $sec [string first . $sec] [string last 0 $sec] ""];
		if {[string length $sec] == 1 } {
			set sec "0$sec";
		}
		set time "$min:$sec";
		if { $i == 0 } { set result "\002Zojuist geweest:\002 $artist \002-\002 $title"; }
		if { $i != 0 } { set result "$result \002-=-\002 $artist \002-\002 $title"; }
		incr i;
	}
	putserv "PRIVMSG $channel :$result";
	mysqlclose $h;
	}
}

proc listeners { nick user handle channel text } {
global DJ1;
	set continue 0;
	for {set x 0} {$x < [llength $::dachan]} {incr x} {
		if { [lindex $::dachan $x] == $channel } { set continue 1; }
	}
	if { $nick == $channel } { set continue 1; }
	if { $continue == 1 } {
#	set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana];
if {$DJ1 == 0} {set h [mysqlconnect -h  $::serveri -u $::useri -password $::salasana]}     
if {$DJ1 == 1} {set h [mysqlconnect -h  $::serveri2 -u $::useri -password $::salasana]}

	mysqluse $h $::tietokanta;
	mysqlsel $h "SELECT listeners FROM historylist ORDER BY date_played DESC LIMIT 0, 1"
	mysqlmap $h {listeners} {
		putserv "PRIVMSG $channel : Er zijn $listeners luisteraars";
	}
	mysqlclose $h
	}
}



Plaats reactie
  • Vergelijkbare Onderwerpen
    Reacties
    Weergaves
    Laatste bericht