function chromas_log($alias, $trailing, $dest)
{
    $params = parse_parameters($trailing, "=", " ");
    if ($params !== False) {
        foreach ($params as $key => $value) {
            if (strpos($key, " ") !== False) {
                $params = False;
                break;
            }
        }
    }
    if ($params === False) {
        term_echo("chromas_log failed: invalid parameters");
        return False;
    }
    # chromas, 23 march 2015
    if (isset($params["until"]) == False) {
        date_default_timezone_set("UTC");
        $params["until"] = strftime("%F %T", time() - 5);
    }
    $paramstr = "";
    foreach ($params as $key => $value) {
        if ($paramstr != "") {
            $paramstr = $paramstr . "&";
        }
        $paramstr = $paramstr . urlencode($key) . "=" . urlencode($value);
    }
    if (isset($params["channel"]) == False) {
        $paramstr = $paramstr . "&channel=" . urlencode($dest);
    }
    if (isset($params["out"]) == False) {
        $paramstr = $paramstr . "&out=irc-full";
    }
    if ($alias == "~log") {
        $uri = "/s/soylent_log.php?" . $paramstr;
    } else {
        $uri = "/s/soylent_log.php?op=" . $alias . "&" . $paramstr;
    }
    if (get_bucket("chromas_irc_log_debug") == "on") {
        pm("chromas", "http://chromas.0x.no" . $uri);
        pm("crutchy", "http://chromas.0x.no" . $uri);
    }
    $response = wget("chromas.0x.no", $uri, 80, ICEWEASEL_UA, "", 10, "", 1024, False);
    $html = trim(strip_headers($response));
    if ($html == "") {
        pm("#", "chromas_log failed: no response");
        return False;
    }
    $lines = explode("\n", trim($html));
    return $lines;
}
Exemple #2
0
 } else {
     $server = "irc.sylnt.us";
     $port = "6667";
 }
 $socket = fsockopen($server, $port);
 if ($socket === False) {
     term_echo("ERROR CREATING IRC SOCKET");
     return;
 }
 stream_set_blocking($socket, 0);
 rawmsg("NICK {$bot_nick}");
 rawmsg("USER {$bot_nick} 0host 0server :{$bot_nick}.bot");
 #add_minion($bot_nick);
 while (True) {
     usleep(100000.0);
     $data = get_bucket("MINION_CMD_{$bot_nick}");
     if ($data != "") {
         term_echo($data);
         if (unset_bucket("MINION_CMD_{$bot_nick}") == True) {
             $items = parse_data($data);
             if ($items !== False) {
                 rawmsg($data);
             } else {
                 $tokens = explode(" ", $data);
                 if (count($tokens) == 2 and strtoupper($tokens[0]) == "FORWARD") {
                     $forward = $tokens[1];
                     term_echo("*** FORWARD SET: ALL DATA WILL BE FORWARDED TO {$forward} ON EXEC BOT HOST NETWORK");
                 }
                 unset($tokens);
             }
         }
Exemple #3
0
function handle_switch($alias, $dest, $nick, $trailing, $channels_bucket, $switch_alias, $internal_alias, &$msg)
{
    $channels = get_bucket($channels_bucket);
    if ($channels != "") {
        $channels = unserialize($channels);
        if ($channels === False) {
            $channels = array();
            save_channels($channels, $channels_bucket);
        }
    } else {
        $channels = array();
        save_channels($channels, $channels_bucket);
    }
    if ($alias == $switch_alias) {
        switch (strtolower($trailing)) {
            case "on":
                if (in_array($dest, $channels) == False) {
                    $channels[] = $dest;
                    save_channels($channels, $channels_bucket);
                    return 1;
                } else {
                    return 2;
                }
                break;
            case "off":
                if (channel_off($channels, $dest, $channels_bucket) == True) {
                    return 3;
                } else {
                    return 4;
                }
                break;
            default:
                return 11;
        }
    } elseif ($alias == $internal_alias) {
        $parts = explode(" ", $trailing);
        $command = strtolower($parts[0]);
        array_shift($parts);
        $msg = implode(" ", $parts);
        switch ($command) {
            case "kick":
                if (count($parts) == 2) {
                    if ($parts[1] == get_bot_nick()) {
                        channel_off($channels, $parts[0], $channels_bucket);
                        return 5;
                    }
                }
                break;
            case "part":
                if ($nick == get_bot_nick()) {
                    channel_off($channels, $msg, $channels_bucket);
                    return 6;
                }
                break;
            case "privmsg":
                if (in_array($dest, $channels) == True and $nick != get_bot_nick()) {
                    return 7;
                }
                return 8;
            case "join":
                if (in_array($dest, $channels) == True and $nick != get_bot_nick()) {
                    return 9;
                }
                return 10;
        }
    }
    return 0;
}
Exemple #4
0
*/
#####################################################################################################
# TODO: WEB PAGE VIEWER FOR FILESYSTEM STRUCTURE
ini_set("display_errors", "on");
require_once "lib.php";
require_once "execfs_lib.php";
$trailing = trim($argv[1]);
$nick = strtolower(trim($argv[2]));
$dest = strtolower(trim($argv[3]));
$alias = strtolower(trim($argv[4]));
$fs = get_fs();
$privmsg = True;
switch ($alias) {
    case "~execfs":
        if ($trailing == "sync") {
            $data = get_bucket(BUCKET_FS);
            $fp = fsockopen("irciv.us.to", 80);
            if ($fp === False) {
                privmsg("  execfs sync error: unable to connect to remote host");
            } else {
                fwrite($fp, $request);
                $response = "";
                while (!feof($fp)) {
                    $response = $response . fgets($fp, 1024);
                }
                fclose($fp);
            }
        }
        break;
    case "~cat":
    case "~get":
Exemple #5
0
    $parts = explode(" ", $trailing);
    $action = strtolower($parts[0]);
    array_shift($parts);
    switch ($action) {
        case "register-events":
            register_event_handler("PRIVMSG", ":%%nick%% INTERNAL %%dest%% :~title-internal event-privmsg %%nick%% %%dest%% %%trailing%%");
            return;
        case "event-privmsg":
            # trailing = <nick> <channel> <trailing>
            $nick = strtolower($parts[0]);
            $channel = strtolower($parts[1]);
            array_shift($parts);
            array_shift($parts);
            $trailing = trim(implode(" ", $parts));
            $show_rd = False;
            if (get_bucket("<exec_title_url_{$dest}>") != "") {
                $show_rd = True;
            }
            if ($bucket == "on") {
                title_privmsg($trailing, $channel, $show_rd);
            }
            break;
    }
} elseif ($alias == "~sizeof") {
    $redirect_data = get_redirected_url($trailing, "", "", array());
    if ($redirect_data === False) {
        term_echo("get_redirected_url=false");
        return;
    }
    $rd_url = $redirect_data["url"];
    $rd_cookies = $redirect_data["cookies"];
Exemple #6
0
function run_event_registration_test()
{
    global $passed;
    unset_bucket(TEST_BUCKET);
    $bucket_index = "<<EXEC_EVENT_HANDLERS>>";
    $test_cmd = "PRIVMSG";
    $test_data = ":%%nick%% INTERNAL %%dest%% :~event-test %%trailing%%";
    $data1 = get_bucket($bucket_index);
    if (check_handler($bucket_index, $test_cmd, $test_data) == True) {
        term_echo("run_event_registration_test failed! (1)");
        $passed = False;
    }
    register_event_handler($test_cmd, $test_data);
    if (check_handler($bucket_index, $test_cmd, $test_data) == False) {
        term_echo("run_event_registration_test failed! (2)");
        $passed = False;
    }
    set_bucket("<<SELF_TRIGGER_EVENTS_FLAG>>", "1");
    privmsg("event test message");
    sleep(2);
    $test = get_bucket(TEST_BUCKET);
    term_echo("*** TEST BUCKET => {$test}");
    if ($test != TEST_VALUE) {
        term_echo("run_event_registration_test failed! (3)");
        $passed = False;
    }
    unset_bucket(TEST_BUCKET);
    unset_bucket("<<SELF_TRIGGER_EVENTS_FLAG>>");
    delete_event_handler($test_cmd, $test_data);
    sleep(2);
    if (check_handler($bucket_index, $test_cmd, $test_data) == True) {
        term_echo("run_event_registration_test failed! (4)");
        $passed = False;
    }
    $data2 = get_bucket($bucket_index);
    if ($data1 != $data2) {
        term_echo("run_event_registration_test failed! (5)");
        $passed = False;
    }
}
Exemple #7
0
function wiki_unspamctl($nick, $trailing)
{
    $account = users_get_account($nick);
    $allowed = array("crutchy", "chromas", "mrcoolbp", "paulej72", "juggs", "martyb");
    if (in_array($account, $allowed) == False) {
        privmsg("  error: not authorized");
        return;
    }
    $title = trim(substr($trailing, strlen(".unspamctl")));
    if ($title == "") {
        privmsg("  syntax: .unspamctl <page title>");
        return;
    }
    if (login($nick, True) == False) {
        return;
    }
    $cookieprefix = get_bucket("wiki_login_cookieprefix");
    $sessionid = get_bucket("wiki_login_sessionid");
    if ($cookieprefix == "" or $sessionid == "") {
        privmsg("  not logged in");
        return;
    }
    $headers = array("Cookie" => login_cookie($cookieprefix, $sessionid));
    $uri = "/w/api.php?action=query&format=php&meta=tokens&type=rollback";
    $response = wget(WIKI_HOST, $uri, 80, WIKI_USER_AGENT, $headers);
    $data = unserialize(strip_headers($response));
    if (isset($data["query"]["tokens"]["rollbacktoken"]) == False) {
        privmsg("  error getting rollbacktoken");
        logout(True);
        return;
    }
    $token = $data["query"]["tokens"]["rollbacktoken"];
    /*$uri="/w/api.php?action=edit";
      $params=array(
        "format"=>"php",
        "title"=>$title,
        "text"=>$text,
        "contentformat"=>"text/x-wiki",
        "contentmodel"=>"wikitext",
        "bot"=>"",
        "token"=>$token);
      $response=wpost(WIKI_HOST,$uri,80,WIKI_USER_AGENT,$params,$headers);
      $data=unserialize(strip_headers($response));
      if (isset($data["error"])==True)
      {
        privmsg("  error: ".$data["error"]["code"]);
      }
      else
      {
        $msg=$data["edit"]["result"];
        if ($data["edit"]["result"]=="Success")
        {
          if ((isset($data["edit"]["oldrevid"])==True) and (isset($data["edit"]["newrevid"])==True))
          {
            $msg=$msg.", oldrevid=".$data["edit"]["oldrevid"].", newrevid=".$data["edit"]["newrevid"];
          }
        }
        privmsg("  $msg");
        $title=str_replace(" ","_",$title);
        privmsg("  http://wiki.soylentnews.org/wiki/".urlencode($title));
      }*/
    logout(True);
}
Exemple #8
0
            if (count($params) == 2) {
                $title = $params[0];
                $section = $params[1];
            }
        }
        $result = get_text($title, $section, True, True);
        if ($result !== False) {
            if (count($result) >= 2) {
                privmsg("  " . chr(3) . "03" . $linkstr . chr(3) . " => " . chr(3) . "13" . $result[0]);
                privmsg("  └─ " . chr(3) . "02" . $result[count($result) - 1]);
            }
        }
    }
    return;
}
$login = get_bucket("wiki_login_cookieprefix");
if (strtolower($trailing) == "login") {
    login($nick);
} elseif ($login != "") {
    $parts = explode(" ", $trailing);
    $action = $parts[0];
    switch (strtolower($action)) {
        case "edit":
            array_shift($parts);
            $trailing = implode(" ", $parts);
            $parts = explode("|", $trailing);
            if (count($parts) != 3) {
                privmsg("syntax: ~wiki title|section|text");
                return;
            }
            $title = $parts[0];
Exemple #9
0
#####################################################################################################
/*
exec:~help|20|0|0|1|||||php scripts/help.php %%trailing%% %%dest%% %%nick%% %%alias%%
*/
#####################################################################################################
require_once "lib.php";
require_once "wiki_lib.php";
$trailing = trim($argv[1]);
$dest = trim($argv[2]);
$nick = trim($argv[3]);
$alias = strtolower(trim($argv[4]));
if ($trailing == "") {
    privmsg("http://sylnt.us/exec#Quick_start");
    return;
}
$exec_list = unserialize(base64_decode(trim(get_bucket("<<EXEC_LIST>>"))));
if (isset($exec_list[$trailing]["help"]) == True) {
    $help_lines = $exec_list[$trailing]["help"];
    for ($i = 0; $i < count($help_lines); $i++) {
        privmsg(chr(3) . "06" . $help_lines[$i]);
    }
    return;
}
$parts = explode(" ", $trailing);
delete_empty_elements($parts);
$cmd = strtolower($parts[0]);
array_shift($parts);
$trailing = trim(implode(" ", $parts));
unset($parts);
$result = get_help($cmd);
if ($result == "" and $result !== False and $result !== True) {
Exemple #10
0
require_once "lib.php";
$trailing = $argv[1];
$dest = strtolower(trim($argv[2]));
$nick = strtolower(trim($argv[3]));
$start = $argv[4];
$alias = strtolower(trim($argv[5]));
$cmd = strtoupper(trim($argv[6]));
$data = $argv[7];
$params = $argv[8];
$timestamp = $argv[9];
$global_execute = get_bucket("LIVE_SCRIPT_GLOBAL_EXECUTE");
$scripts = get_array_bucket("<<LIVE_SCRIPTS>>");
$code = "";
$script_data = array();
$script_lines = array();
$script_name = get_bucket("LOADED_SCRIPT_" . $nick . "_" . $dest);
if ($script_name != "") {
    if (isset($scripts[$script_name]["code"]) == True) {
        $code = base64_decode($scripts[$script_name]["code"]);
        if ($code != "") {
            $script_lines = explode("\n", $code);
        }
    }
}
$parts = explode(" ", $trailing);
$action = strtolower($parts[0]);
array_shift($parts);
$trailing = trim(implode(" ", $parts));
$data_changed = False;
switch ($action) {
    case "register-events":
Exemple #11
0
    if ($parts[1] == "unset") {
        unset_bucket($index);
        if (get_bucket($index) == "") {
            privmsg("unset bucket");
        } else {
            privmsg("error unsetting bucket");
        }
        return;
    }
}
if (count($parts) >= 2) {
    array_shift($parts);
    $data = implode(" ", $parts);
    set_bucket($index, $data);
    if (get_bucket($index) == "") {
        privmsg("error setting bucket");
    } else {
        privmsg("set bucket");
    }
    return;
}
if (count($parts) == 1) {
    $data = get_bucket($index);
    if ($data == "") {
        privmsg("bucket not found");
    } else {
        privmsg($data);
    }
    return;
}
#####################################################################################################
Exemple #12
0
function handle_macros($nick, $channel, $trailing)
{
    $reserved_triggers = array(".macro", ".macro-list");
    $reserved_commands = array("~restart-internal", "~q", "~ps", "~kill", "~killall", "~restart", "~rehash", "~dest-override", "~dest-clear", "~ignore", "~unignore", "~ignore-list", "~buckets-dump", "~eval", "~say", "~bucket", "~buckets-save", "~buckets-load", "~buckets-flush", "~buckets-list", "~exec-conflicts", "~exec-list", "~exec-timers", "~exec-errors", "~op", "~deop", "~voice", "~devoice", "~invite", "~kick", "~topic", "~exec-add", "~exec-del", "~exec-save", "<init>", "<quit>", "<startup>");
    $allowed = array("crutchy", "chromas", "TheMightyBuzzard", "Bytram", "arti", "paulej72", "mrcoolbp", "juggs");
    if ($nick == "" or $channel == "" or $trailing == "") {
        return;
    }
    if ($trailing == ".macro") {
        pm($channel, chr(3) . "02" . "  syntax to add: .macro <trigger> <chanlist> PRIVMSG|INTERNAL <command_template>");
        pm($channel, chr(3) . "02" . "  syntax to delete: .macro <trigger> -");
        #pm($channel,chr(3)."02"."  <chanlist> is comma-separated or * for any");
    }
    $macro_file = DATA_PATH . "exec_macros.txt";
    $macros = load_settings($macro_file, "=");
    if ($macros !== False and $trailing == ".macro-list") {
        foreach ($macros as $trigger => $data) {
            $data = unserialize($data);
            $cmd = "INTERNAL";
            if (isset($data["cmd"]) == True) {
                $cmd = $data["cmd"];
            }
            pm($channel, chr(3) . "13" . "  {$trigger} [" . $data["chanlist"] . "] {$cmd} " . $data["command"]);
        }
    }
    if ($macros === False) {
        $macros = array();
    }
    $parts = explode(" ", $trailing);
    delete_empty_elements($parts);
    if (count($parts) == 0) {
        return;
    }
    if (trim($parts[0]) == ".macro" and count($parts) > 2) {
        $account = users_get_account($nick);
        if (in_array($account, $allowed) == False) {
            return;
        }
        $trigger = trim($parts[1]);
        if (in_array($trigger, $reserved_triggers) == True) {
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" not permitted");
            return;
        }
        if (in_array($trigger, $reserved_commands) == True) {
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" not permitted");
            return;
        }
        $exec_list = unserialize(base64_decode(trim(get_bucket("<<EXEC_LIST>>"))));
        if (isset($exec_list[$trigger]) == True) {
            privmsg(chr(3) . "02" . "  *** error: macro with trigger that is the same as existing alias is not permitted");
            return;
        }
        $chanlist = trim($parts[2]);
        if ($chanlist == "-") {
            unset($macros[$trigger]);
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" deleted");
        } elseif (count($parts) >= 5) {
            array_shift($parts);
            array_shift($parts);
            array_shift($parts);
            $cmd = strtoupper(trim($parts[0]));
            if ($cmd != "PRIVMSG" and $cmd != "INTERNAL") {
                privmsg(chr(3) . "02" . "  *** error: invalid cmd (must be either INTERNAL or PRIVMSG)");
                return;
            }
            array_shift($parts);
            if (isset($macros[$parts[0]]) == True) {
                privmsg(chr(3) . "02" . "  *** error: triggering other macros is not permitted");
                return;
            }
            $command = implode(" ", $parts);
            for ($i = 0; $i < count($reserved_commands); $i++) {
                if (strtolower(substr($command, 0, strlen($reserved_commands[$i]))) == strtolower($reserved_commands[$i])) {
                    privmsg(chr(3) . "02" . "  *** macro with command \"{$command}\" not permitted");
                    return;
                }
            }
            $data = array();
            $data["chanlist"] = $chanlist;
            $data["command"] = $command;
            $data["cmd"] = $cmd;
            $macros[$trigger] = serialize($data);
            privmsg(chr(3) . "02" . "  *** macro with trigger \"{$trigger}\" and {$cmd} command template \"{$command}\" saved");
        }
        save_settings($macros, $macro_file, "=");
    } else {
        foreach ($macros as $trigger => $data) {
            if (trim($parts[0]) == $trigger) {
                $data = unserialize($data);
                if ($data["chanlist"] == "*" or in_array(strtolower($channel), explode(",", strtolower($data["chanlist"]))) == True) {
                    $account = users_get_account($nick);
                    if ($account != "") {
                        $cmd = "INTERNAL";
                        if (isset($data["cmd"]) == True) {
                            $cmd = $data["cmd"];
                        }
                        $trailing = trim(substr($trailing, strlen($trigger)));
                        # TODO: MAKE MORE TRAILING PARSING REPLACE ARGS
                        $command = str_replace("%%channel%%", $channel, $data["command"]);
                        $command = str_replace("%%nick%%", $nick, $command);
                        $command = str_replace("%%trailing%%", $trailing, $command);
                        echo "/IRC :" . get_bot_nick() . " {$cmd} {$channel} :{$command}\n";
                    }
                }
                return;
            }
        }
    }
}
Exemple #13
0
#####################################################################################################
#exec:~pong|10|0|0|0||INTERNAL|||php scripts/ping.php %%trailing%% %%alias%%
#exec:~ping|10|300|0|0||INTERNAL|||php scripts/ping.php %%trailing%% %%alias%%
#####################################################################################################
require_once "lib.php";
$trailing = trim($argv[1]);
$alias = trim($argv[2]);
switch ($alias) {
    case "~ping":
        # called every 5 mins (trailing is empty)
        $t = microtime(True);
        if (get_bucket(BUCKET_CONNECTION_ESTABLISHED) != "1") {
            rawmsg("PING {$t}");
            return;
        }
        $ping = get_bucket("<<PING>>");
        $pong = get_bucket("<<PONG>>");
        if ($ping != "" and $ping != $pong) {
            term_echo("==================== PING TIMEOUT DETECTED ====================");
            echo "/INTERNAL ~restart-internal\n";
            return;
        }
        set_bucket("<<PING>>", $t);
        rawmsg("PING {$t}");
        return;
    case "~pong":
        # called in response to PONG received (trailing contains timestamp)
        set_bucket("<<PONG>>", $trailing);
        return;
}
#####################################################################################################
Exemple #14
0
if ($trailing == "register-events") {
    register_event_handler("PRIVMSG", ":%%nick%% INTERNAL %%dest%% :~antispam-internal %%nick%% %%dest%% %%trailing%%");
    return;
}
$parts = explode(" ", $trailing);
if (count($parts) < 3) {
    return;
}
$nick = strtolower($parts[0]);
$channel = strtolower($parts[1]);
array_shift($parts);
array_shift($parts);
$trailing = trim(implode(" ", $parts));
return;
define("PREVIOUS_MSG_TRACK", 5);
if (get_bucket("<<IRC_CONNECTION_ESTABLISHED>>") != "1") {
    return;
}
$items = unserialize($argv[1]);
$nick = $items["nick"];
if (users_get_account($nick) == get_bot_nick()) {
    return;
}
$trailing = $items["trailing"];
$dest = strtolower($items["destination"]);
$exec = users_get_data(get_bot_nick());
if (isset($exec["channels"][$dest]) == True) {
    if (strpos($exec["channels"][$dest], "@") === False) {
        return;
    }
} else {
Exemple #15
0
        output_message($content);
    } elseif ($content != "") {
        $request_ids = unserialize($content);
        for ($i = 0; $i < count($request_ids); $i++) {
            $id = $request_ids[$i];
            $request_params = array();
            $request_params["exec_key"] = $key;
            $response = wpost("irciv.us.to", "/?exec&request_id={$id}", 80, "", $request_params);
            $content = trim(strip_headers($response));
            var_dump($content);
            if (strpos(strtoupper($content), "ERROR") !== False) {
                output_message($content);
            } elseif ($content != "") {
                $content = unserialize($content);
                output_message($content["request_uri"]);
                $data = get_bucket($content["data"]);
                $response_params = array();
                $response_params["exec_key"] = $key;
                $response_params["request_id"] = $id;
                $response_params["data"] = $data;
                $response = wpost("irciv.us.to", "/?exec", 80, "", $response_params);
                $content = trim(strip_headers($response));
                output_message($content);
            }
        }
    }
    sleep(10);
}
#####################################################################################################
function output_message($msg)
{
Exemple #16
0
function shell_sed($trailing, $nick, $dest)
{
    # [nick[:|,|>|.] ]sed_cmd
    global $delims;
    $trailing = trim($trailing);
    if (trim($trailing) == "") {
        return False;
    }
    if (strtolower(substr($trailing, strlen($trailing) - 2)) == "/e") {
        die;
    }
    $parts = explode(" ", $trailing);
    $sed_nick = "";
    if (count($parts) > 1) {
        $break = False;
        for ($i = 0; $i < count($delims); $i++) {
            if (strpos($parts[0], $delims[$i]) == True) {
                $break = True;
                break;
            }
        }
        if ($break == False) {
            $sed_nick = $parts[0];
            if (strpos(":,>.", substr($sed_nick, strlen($sed_nick) - 1)) !== False) {
                $sed_nick = substr($sed_nick, 0, strlen($sed_nick) - 1);
            }
            array_shift($parts);
        }
    }
    if ($sed_nick == "") {
        $sed_nick = $nick;
    }
    $sed_cmd = implode(" ", $parts);
    if (strlen($sed_cmd) < 5) {
        return False;
    }
    if (strtolower($sed_cmd[0]) != "s") {
        return False;
    }
    if (in_array($sed_cmd[1], $delims) == False) {
        return False;
    }
    $index = "last_" . strtolower($sed_nick) . "_" . strtolower($dest);
    $last = get_bucket($index);
    if ($last == "") {
        return False;
    }
    $action_delim = chr(1) . "ACTION ";
    if (strtoupper(substr($last, 0, strlen($action_delim))) == $action_delim) {
        $last = trim(substr($last, strlen($action_delim)), chr(1));
    }
    #$command="echo ".escapeshellarg($last)." | sed -e --posix ".escapeshellarg($sed_cmd);
    $command = "echo " . escapeshellarg($last) . " | sed -e " . escapeshellarg($sed_cmd);
    var_dump($command);
    $cwd = NULL;
    $env = NULL;
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
    $result = trim(stream_get_contents($pipes[1]));
    $result_lines = explode("\n", $result);
    var_dump($result_lines);
    if (count($result_lines) > 1) {
        return False;
    }
    fclose($pipes[1]);
    $stderr = trim(stream_get_contents($pipes[2]));
    fclose($pipes[2]);
    proc_close($process);
    if ($stderr != "") {
        term_echo($stderr);
        return True;
    }
    if ($result == $last or $result == $sed_cmd) {
        $result = "";
    }
    if ($result != "") {
        if ($nick == $sed_nick) {
            privmsg("<{$sed_nick}> {$result}");
        } else {
            privmsg("<{$nick}> <{$sed_nick}> {$result}");
        }
    }
    return True;
}
#####################################################################################################
require_once "lib.php";
require_once "translate_lib.php";
$trailing = trim($argv[1]);
$dest = $argv[2];
$nick = $argv[3];
$alias = $argv[4];
if ($trailing == "") {
    privmsg("syntax: .trans <nick>");
    privmsg("uses google translate");
    return;
}
$lang_from = "auto";
$lang_to = "en";
$index = "last_" . strtolower($trailing) . "_" . strtolower($dest);
$msg = get_bucket($index);
if ($msg == "") {
    privmsg("message by {$trailing} not found");
    return;
}
$def = translate($lang_from, $lang_to, $msg);
if ($def == $msg) {
    return;
}
if (strlen($def) > 500) {
    $def = substr($def, 0, 500) . "...";
}
if ($def != "") {
    privmsg("<{$trailing}> {$msg}: {$def}");
} else {
    privmsg("error translating");
Exemple #18
0
            }
        } else {
            term_echo("funding: amount not found in http response");
        }
        sn_logout();
        return;
    case "~verifier-nick-change":
        $parts = explode(" ", $trailing);
        if (count($parts) == 2) {
            $old_nick = trim(strtolower($parts[0]));
            $new_nick = trim(strtolower($parts[1]));
            $registered_nick = get_bucket(BUCKET_VERIFIER_NICK);
            if ($old_nick == $registered_nick) {
                set_bucket(BUCKET_VERIFIER_NICK, $new_nick);
                pm("#", "SN status verifier nick updated from \"{$registered_nick}\" to \"{$new_nick}\"");
            }
        }
        return;
    case "~verifier-nick":
        $registered_nick = get_bucket(BUCKET_VERIFIER_NICK);
        if ($trailing == "") {
            privmsg("registered verifier nick: " . $registered_nick);
        } else {
            $new_nick = trim(strtolower($trailing));
            set_bucket(BUCKET_VERIFIER_NICK, $new_nick);
            $msg = "SN status verifier nick updated from \"{$registered_nick}\" to \"{$new_nick}\"";
            privmsg($msg);
        }
        return;
}
#####################################################################################################
Exemple #19
0
function unset_bucket($index, $timeout = 5)
{
    $t = microtime(True);
    do {
        echo "/BUCKET_UNSET {$index}\n";
        usleep(50000.0);
        $test = get_bucket($index);
        if (microtime(True) - $t > $timeout) {
            return False;
        }
    } while ($test != "");
    return True;
}
Exemple #20
0
*/
#####################################################################################################
require_once "lib.php";
$trailing = trim($argv[1]);
$nick = trim($argv[2]);
if ($trailing == "") {
    return;
}
$adverbs = array("brazenly", "spontaneously", "prematurely", "unjustifiably", "insatiably", "abnormally", "abrasively", "accidentally", "allegedly", "clumsily", "cohesively", "covertly", "dexterously", "diabolically", "fanatically", "suspiciously");
$actions = array("cracks open" => "for", "passes" => "to", "throws" => "at", "slides" => "to", "hurls" => "at", "poops" => "for", "drops" => "on", "blows" => "at", "pours" => "for", "flings" => "at", "offers" => "to", "tosses" => "to", "postulates" => "towards");
$containers = array("a cold can", "a used franger", "a pair of used panties full", "a cheap plastic cup", "a wine flute", "a bathtub", "a spoon", "a socket", "a caravan", "a buzz saw", "a blagoblag", "a DD cup", "a tinfoil hat", "an assfull", "a bucket", "a wad", "an anvil", "a toilet bowl", "a coffee++ mug");
$beverages = array("beer", "g'day juice", "coffee", "NCommander", "milo", "boogers", "bewb", "red cordial", "splodge", "skittles", "vibrating rooster sammich", "glowballs", "spew", "pancakes", "\$insert_beverage_here", "toilet water", "ciri poo", "bacon", "dag", "Debian", "coffee++", "Soylent Green");
$last_adverb = get_bucket("<<GDAY_LAST_ADVERB>>");
$last_action = get_bucket("<<GDAY_LAST_ACTION>>");
$last_container = get_bucket("<<GDAY_LAST_CONTAINER>>");
$last_beverage = get_bucket("<<GDAY_LAST_BEVERAGE>>");
$action_keys = array_keys($actions);
do {
    $adverb = $adverbs[rand(0, count($adverbs) - 1)];
} while ($adverb == $last_adverb);
do {
    $action1 = $action_keys[rand(0, count($action_keys) - 1)];
} while ($action1 == $last_action);
do {
    $container = $containers[rand(0, count($containers) - 1)];
} while ($container == $last_container);
do {
    $beverage = $beverages[rand(0, count($beverages) - 1)];
} while ($beverage == $last_beverage);
$action2 = $actions[$action1];
set_bucket("<<GDAY_LAST_ADVERB>>", $adverb);
Exemple #21
0
<?php

#####################################################################################################
/*
exec:~scramble|10|0|0|1|||||php scripts/scramble.php %%trailing%% %%nick%% %%dest%%
*/
#####################################################################################################
require_once "lib.php";
$trailing = strtolower(trim($argv[1]));
$nick = strtolower(trim($argv[2]));
$dest = strtolower(trim($argv[3]));
if ($trailing == "") {
    $index = "last_" . $nick . "_" . $dest;
} else {
    $index = "last_" . $trailing . "_" . $dest;
}
$last = trim(get_bucket($index));
if ($last == "") {
    return;
}
$parts = explode(" ", $last);
if (count($parts) < 4) {
    return;
}
if (shuffle($parts) == False) {
    return;
}
privmsg(implode(" ", $parts));
#####################################################################################################
Exemple #22
0
<?php

#####################################################################################################
/*
#exec:~butt|10|0|0|1|@||||php scripts/000.php
*/
#####################################################################################################
require_once "lib.php";
privmsg(get_bucket("process_template_nick"));
#####################################################################################################
Exemple #23
0
<?php

#####################################################################################################
# "soon" is intended to be a sort of macro processor that can translate pseudo-code to php
#####################################################################################################
/*
exec:~soon|30|0|0|1|@||||php scripts/soon/soon.php
*/
#####################################################################################################
ini_set("display_errors", "on");
require_once __DIR__ . "/../lib.php";
require_once "soon_lib.php";
$dest = get_bucket("process_template_destination");
if ($dest != "#irciv") {
    return;
}
$translations = load_translations();
var_dump(soon_explode("for ({$i}=1;{$i}<=n;{$i}++) { code }"));
#soon_test("loop 3 fart","loop n code","for ($i=1;$i<=n;$i++) { code }","for ($i=1;$i<=3;$i++) { fart }");
#####################################################################################################
function soon_test($code, $key, $value, $result)
{
    $map = map_key($code, $key);
}
#####################################################################################################
function map_key($code, $key)
{
    # code = loop 3 fart
    # key = loop n code
    $code_parts = soon_explode($code);
    $key_parts = soon_explode($key);