Jump to content

Stupid Mistake


Fibrewire

Recommended Posts

I beleive that my code is "ok" overall, but i am getting a syntax error on lines 6 & 26, pretty sure im making a stupid mistake here,

 

Code is a plugin for a PHP IRC Bot, basically a toggle on/off command via "!radio" to send meta data from the audio stream every 5minutes.

 

<?php
  require_once('shoutcast_class.php');
  $radio = false;
  class plugRadio{
public static function onCommandRadio(
  if($radio == false)
	$radio = true;
	$dh->reply('3 Info Stream : ON', $event->getName(), $dh->getCommandTrailing());
	while($radio == true){
	  event $event, 
	  datahelper $dh = null, 
	  $help = 'use !Radio to toggle stream info On/Off')
	  {
		$display_array = array("Stream Title", "Stream Genre", "Stream URL", "Current Song", "Server Status", "Stream Status", "Listener Peak", "Average Listen Time", "Stream Title", "Content Type", "Stream Genre", "Stream URL", "Current Song");	
		$radio = new Radio("radio.anonops.ru:8000");
		$data_array = $radio->getServerInfo($display_array);
		$dh->reply('15,1 #RadioPayback | 9,1On Air: '.$data_array[8].' 15,1| 9,1Now Playing: '.$data_array[12].' ', $event->getName(), $dh->getCommandTrailing());	
		$event->delete();
		flush();
	    sleep(300);
	  }
	}
  if($radio == true)
	$radio = false;
	$dh->reply('4 Info Stream : OFF', $event->getName(), $dh->getCommandTrailing());
  }
?>

 

Link to comment
Share on other sites

Example:

class plugExample1{
  // Here we build our handler function that will be called on the !example1 command.
  // Note that the parameter always is an event. The rest of the data is in that event.
  public static function onCommandExample1(
    event $event, 
    // We will use the datahelper class to parse this data and send a reply.
    datahelper $dh = null, 
    // Now we add some help so that people requestion "!help example1" will get the right help.
    $help = 'Params: <text>. Example command that says the text back at you again.')
  {
    // Sending a reply is quite easy when you have it setup like this. Let me show:
    $dh->reply('You used the "%s" command with the following text: "%s".', $event->getName(), $dh->getCommandTrailing());
    // Or use the following method. It will show up as an action.
//    $dh->replyAction('You used the "%s" command with the following text: "%s".', $event->getName(), $dh->getCommandTrailing());
    // Or a notice:
//    $dh->notice('You used the "%s" command with the following text: "%s".', $event->getName(), $dh->getCommandTrailing());
    // We can also force it to reply or notice in private.
//    $dh->replyPrivate('You used the "%s" command with the following text: "%s".', $event->getName(), $dh->getCommandTrailing());
//    $dh->noticePrivate('You used the "%s" command with the following text: "%s".', $event->getName(), $dh->getCommandTrailing());
    // Thats it. Except we need to make the eventhandler aware of that this event is completed.
    // We do this like this:
    $event->delete();
    // Quite easy right?
    
    // Thats it a plugin that reply's on a command. It couldn't be more easy.
  }
}
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.