Fibrewire Posted February 8, 2011 Share Posted February 8, 2011 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()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/ Share on other sites More sharing options...
Maq Posted February 8, 2011 Share Posted February 8, 2011 What's the error? Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171531 Share on other sites More sharing options...
Fibrewire Posted February 8, 2011 Author Share Posted February 8, 2011 Parse error: syntax error, unexpected T_IF, expecting '&' or T_VARIABLE <removed> on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171535 Share on other sites More sharing options...
BlueSkyIS Posted February 8, 2011 Share Posted February 8, 2011 public static function onCommandRadio() { don't know what this is supposed to be doing... event $event, // ??? datahelper $dh = null, // ??? $help = 'use !Radio to toggle stream info On/Off') // ??? Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171543 Share on other sites More sharing options...
lastkarrde Posted February 8, 2011 Share Posted February 8, 2011 EDIT: Nvm. Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171546 Share on other sites More sharing options...
Fibrewire Posted February 8, 2011 Author Share Posted February 8, 2011 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. } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171547 Share on other sites More sharing options...
KevinM1 Posted February 8, 2011 Share Posted February 8, 2011 The onCommandExample1() method uses type hinting to ensure arguments passed in are of the right type. You can't use type hinting except in an argument list. In short, the code at the beginning of your while-loop is gibberish. Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171551 Share on other sites More sharing options...
Fibrewire Posted February 8, 2011 Author Share Posted February 8, 2011 workaround? Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171554 Share on other sites More sharing options...
KevinM1 Posted February 8, 2011 Share Posted February 8, 2011 Not to be snarky, but the best workaround would be to learn PHP. Looking at your code more closely, as it stands right now, the part you've shown will need to be completely rewritten. Quote Link to comment https://forums.phpfreaks.com/topic/227086-stupid-mistake/#findComment-1171567 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.