Example #1
0
function handleCommand($nick, $message, $channel)
{
    $messageparts = explode(' ', $message);
    $command = trim(substr($messageparts['0'], 1, strlen($messageparts['0'])));
    echo "Command received: {$command}\n";
    switch ($command) {
        case "test":
            echo "Sending test response!\n";
            sendCommand("PRIVMSG {$channel} :Your connection is working, {$nick}!\n\r");
            break;
        default:
            echo "I don't know this command...\n";
            sendCommand("PRIVMSG {$channel} :Unknown command!\n\r");
            break;
    }
}
Example #2
0
    while (true) {
        $socket_data = getData();
        if (is_array($socket_data) && !empty($socket_data)) {
            if (array_key_exists("notifytextmessage", $socket_data)) {
                sendCommand("servernotifyunregister");
                $status = $multibotObject->executeCommand($socket_data);
                if ($status == "4") {
                    $tsAdmin->sendMessage(1, $socket_data['invokerid'], $lang['commands_mode']['chat_command_doesnt_exist']);
                } elseif ($status == "2") {
                    $tsAdmin->sendMessage(1, $socket_data['invokerid'], $lang['commands_mode']['chat_no_permission']);
                } elseif ($status == "3") {
                    $tsAdmin->sendMessage(1, $socket_data['invokerid'], $lang['commands_mode']['chat_permission_error']);
                } elseif ($status == false) {
                    $tsAdmin->sendMessage(1, $socket_data['invokerid'], $lang['unknown_error']);
                }
                sendCommand("servernotifyregister event=textprivate");
            }
        }
        //Sprawdza kim jest aby achować połączenie z serwerem
        if ($whoAmi_timer < date('r')) {
            $tsAdmin->whoAmI();
            $whoAmi_timer = date('r', time() + 120);
        }
        usleep(500000);
    }
    //**************************************************************************************
    //*********************************** Multibot Mode ************************************
    //**************************************************************************************
} elseif ($start_options['startmode'] == "multibot") {
    require $paths['files']['multibot-commands'];
    require $paths['files']['multibot-core'];
Example #3
0
File: bot.php Project: tseeker/LWB5
    global $aConfig;
    $fName = $aConfig['ctrlFifo'];
    if (!file_exists($fName)) {
        return false;
    }
    $fifo = fopen($fName, "w");
    fwrite($fifo, "{$cmd}\n");
    fclose($fifo);
    redirect();
}
if ($_GET['c'] == 'kb') {
    __logAdmin("is stopping the IRC bot");
    sendCommand("BOTOFF");
} elseif ($_GET['c'] == 'sb') {
    __logAdmin("is starting the IRC bot");
    sendCommand("BOTON");
}
$running = file_exists($config['cs_path'] . "/ircbot.pid");
?>
<html>
 <head>
  <title>LegacyWorlds Beta 5 > Administration > IRC bot</title>
 </head>
 <body>
  <h1><a href="index.html">LWB5 > Administration</a> > IRC bot</h1>
<?php 
if ($running) {
    ?>
 <p>
  IRC bot is (probably) running. <a href="?c=kb">Kill bot</a>
 </p>
Example #4
0
function set_country_code()
{
    global $_cfg;
    sendCommand("iw reg set {$_cfg["country"]}");
}
Example #5
0
 case 'version':
     if ($debug) {
         echo json_encode("debug");
     } else {
         echo json_encode($version);
     }
     break;
 case 'ping':
     echo json_encode(true);
     break;
 case 'sendCommand':
     if ($_GET['command'] == 'custom' && isset($_GET['key'])) {
         sendKeyCode($_GET['key']);
         break;
     }
     sendCommand($_GET['command']);
     break;
 case 'play':
     if (isset($_GET['file'])) {
         $file = $_GET['file'];
     }
     if (isset($_GET['files'])) {
         $files = $_GET['files'];
     }
     if (isset($_GET['directory'])) {
         $directory = $_GET['directory'];
     }
     if (isset($_GET['service'])) {
         $service = $_GET['service'];
     }
     if ($root && $normal) {
Example #6
0
<!DOCTYPE html>
<html>
<body>

<h1>Cat's toy!</h1>

<form method="POST" action="">
<?php 
if (isset($_POST['command']) && $_POST['command'] == 'Start') {
    sendCommand("start");
    echo 'Started !';
    echo '<input name="command" type="submit" value="Stop">';
} else {
    if (isset($_POST['command']) && $_POST['command'] == 'Stop') {
        sendCommand("stop");
        echo 'Stopped !';
    }
    echo '<input name="command" type="submit" value="Start">';
}
?>
</form>

</body>
</html>


<?php 
function sendCommand($n)
{
    $serial = new phpSerial();
Example #7
0
        echo $ex->response->raw;
        break;
    }
}
function deviceCommands()
{
    try {
        $m2x = new M2X(API_KEY);
        $device = $m2x->device(DEVICE_ID);
        // Retrieve the list of recent commands sent to target device.
        $commands = $device->commands(array('status' => 'pending', 'limit' => 2));
        foreach ($commands as $command) {
            // Get details of a received commands for the device.
            $responseCommand = $device->command($command->id);
            if ($responseCommand->name == 'SAY_COMMAND') {
                echo "\n\rMark the given command as processed....\n\r";
                $device->process($responseCommand);
            } else {
                echo "\n\rMark the given command as rejected....\n\r";
                $device->reject($responseCommand);
            }
        }
    } catch (M2XException $ex) {
        echo 'Error: ' . $ex->getMessage();
        echo $ex->response->raw;
        break;
    }
}
sendCommand();
listCommands();
deviceCommands();
Example #8
0
function desliga()
{
    sendCommand('O');
}