コード例 #1
0
ファイル: wiki_lib.php プロジェクト: cmn32480/exec-irc-bot
function login($nick, $return = False)
{
    $account = users_get_account($nick);
    $allowed = array("wikirc", "ncommander", "funpika", "mrcoolbp", "paulej72", "juggs", "crutchy", "chromas", "themightybuzzard", "martyb");
    if (in_array($account, $allowed) == False) {
        privmsg("  error: not authorized (login)");
        return;
    }
    $user_params = explode("\n", file_get_contents("../pwd/wiki.bot"));
    $params["lgname"] = $user_params[0];
    $params["lgpassword"] = $user_params[1];
    $response = wpost(WIKI_HOST, "/w/api.php?action=login&format=php", 80, WIKI_USER_AGENT, $params);
    $data = unserialize(strip_headers($response));
    $headers["Cookie"] = login_cookie($data["login"]["cookieprefix"], $data["login"]["sessionid"]);
    $params["lgtoken"] = $data["login"]["token"];
    $response = wpost(WIKI_HOST, "/w/api.php?action=login&format=php", 80, WIKI_USER_AGENT, $params, $headers);
    $data = unserialize(strip_headers($response));
    $msg = "wiki: login="******"login"]["result"];
    if ($data["login"]["result"] == "Success") {
        set_bucket("wiki_login_cookieprefix", $data["login"]["cookieprefix"]);
        set_bucket("wiki_login_sessionid", $data["login"]["sessionid"]);
        $msg = $msg . ", username="******"login"]["lgusername"] . " (userid=" . $data["login"]["lguserid"] . ")";
        wiki_privmsg($return, $msg);
        return True;
    } else {
        wiki_privmsg($return, $msg);
        return False;
    }
}
コード例 #2
0
ファイル: test.php プロジェクト: cmn32480/exec-irc-bot
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;
    }
}
コード例 #3
0
ファイル: gday.php プロジェクト: cmn32480/exec-irc-bot
}
$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);
set_bucket("<<GDAY_LAST_ACTION>>", $action1);
set_bucket("<<GDAY_LAST_CONTAINER>>", $container);
set_bucket("<<GDAY_LAST_BEVERAGE>>", $beverage);
$parts = explode(" ", $trailing);
$target = $parts[0];
privmsg(chr(1) . "ACTION {$adverb} {$action1} {$container} of {$beverage} {$action2} {$target}" . chr(1));
#####################################################################################################
コード例 #4
0
ファイル: sed.php プロジェクト: cmn32480/exec-irc-bot
        # bot parted channel
        return;
    case 7:
        if (shell_sed($msg, $nick, $dest) == True) {
            return;
        }
        break;
    case 8:
        # privmsg
        break;
    case 9:
        return;
    case 10:
        return;
}
set_bucket("last_" . strtolower($nick) . "_" . strtolower($dest), $msg);
#####################################################################################################
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) {
コード例 #5
0
ファイル: sn.php プロジェクト: cmn32480/exec-irc-bot
            }
        } 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;
}
#####################################################################################################
コード例 #6
0
ファイル: switches.php プロジェクト: cmn32480/exec-irc-bot
function save_channels($channels, $channels_bucket)
{
    $channels = serialize($channels);
    set_bucket($channels_bucket, $channels);
}
コード例 #7
0
ファイル: minion.php プロジェクト: cmn32480/exec-irc-bot
function handle_bot_data($data, $bot_nick)
{
    $items = parse_data($data);
    if ($items !== False) {
        term_echo("MINION_CMD_{$bot_nick} bucket set");
        set_bucket("MINION_CMD_{$bot_nick}", $data);
    } else {
        term_echo("invalid command \"{$data}\"");
    }
}
コード例 #8
0
ファイル: chromas_log.php プロジェクト: cmn32480/exec-irc-bot
/*
exec:~first|60|0|0|1|||||php scripts/chromas_log.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~last|60|0|0|1|||||php scripts/chromas_log.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~random|60|0|0|1|||||php scripts/chromas_log.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~count|60|0|0|1|||||php scripts/chromas_log.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~log|60|0|0|1|||||php scripts/chromas_log.php %%trailing%% %%dest%% %%nick%% %%alias%%
*/
#####################################################################################################
require_once "lib.php";
require_once "chromas_log_lib.php";
$trailing = trim($argv[1]);
$dest = $argv[2];
$nick = $argv[3];
$alias = substr($argv[4], 1);
if ($trailing == "debug on") {
    set_bucket("chromas_irc_log_debug", "on");
    privmsg("  enabled debug pm");
    return;
} elseif ($trailing == "debug off") {
    unset_bucket("chromas_irc_log_debug");
    privmsg("  disabled debug pm");
    return;
}
$lines = chromas_log($alias, $trailing, $dest);
if ($lines === False) {
    $response = wget("chromas.0x.no", "/s/soylent_log.php", 80);
    $html = trim(strip_headers($response));
    $html = str_replace("\n", " ", $html);
    privmsg(chr(3) . "03" . $html);
    privmsg(chr(3) . "  http://chromas.0x.no/s/soylent_log.php");
    return;
コード例 #9
0
ファイル: definitions.php プロジェクト: cmn32480/exec-irc-bot
       {
         if ($out<>"")
         {
           $out=$out.", ";
         }
         $out=$out.$host;
       }
       privmsg("definition sources: $out");*/
     foreach ($sources as $host => $params) {
         privmsg("{$host} => " . $params["name"] . "|" . $params["port"] . "|" . $params["uri"] . "|" . $params["template"] . "|" . $params["get_param"] . "|" . $params["order"] . "|" . $params["delim_start"] . "|" . $params["delim_end"] . "|" . $params["ignore"] . "|" . $params["space_delim"]);
         usleep(0.5 * 1000000.0);
     }
     break;
 case "~define-source-edit":
     if ($trailing == "debug on") {
         set_bucket("<<DEFINE_DEBUG>>", "ON");
         privmsg("define: debug mode enabled");
         return;
     }
     if ($trailing == "debug off") {
         unset_bucket("<<DEFINE_DEBUG>>");
         privmsg("define: debug mode disabled");
         return;
     }
     $params = explode("|", $trailing);
     if (count($params) == 11) {
         $host = trim($params[0]);
         $action = "inserted";
         if (isset($sources[$host]) == True) {
             $action = "updated";
         }
コード例 #10
0
ファイル: lib_buckets.php プロジェクト: cmn32480/exec-irc-bot
function set_array_bucket($array, $bucket, $unset = True)
{
    $bucket_data = serialize($array);
    if ($bucket_data === False) {
        term_echo("error serializing \"{$bucket}\" bucket");
    } else {
        if ($unset == True) {
            unset_bucket($bucket);
        }
        set_bucket($bucket, $bucket_data);
    }
}
コード例 #11
0
ファイル: scripting.php プロジェクト: cmn32480/exec-irc-bot
         privmsg("error: script named \"{$trailing}\" not found");
         break;
     }
     unset($scripts[$trailing]);
     set_array_bucket($scripts, "<<LIVE_SCRIPTS>>");
     privmsg("deleted script \"{$trailing}\"");
     return;
 case "open":
     # open script
     # ~x open myscript
     if ($trailing == "") {
         privmsg("error: script name not specified");
         break;
     }
     $script_name = $trailing;
     set_bucket("LOADED_SCRIPT_" . $nick . "_" . $dest, $trailing);
     if (isset($scripts[$script_name]) == False) {
         $scripts[$script_name] = array();
         $data_changed = True;
     }
     privmsg("script \"{$script_name}\" opened for editing by {$nick} in {$dest}");
     break;
 case "close":
     # close currently open script
     # ~x close
     if ($script_name != "") {
         unset_bucket("LOADED_SCRIPT_" . $nick . "_" . $dest);
         privmsg("script \"{$script_name}\" closed by {$nick} in {$dest}");
     } else {
         privmsg("error: no script opened for editing by {$nick} in {$dest}");
     }
コード例 #12
0
ファイル: bucket.php プロジェクト: cmn32480/exec-irc-bot
$index = $parts[0];
if (count($parts) == 2) {
    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;
コード例 #13
0
ファイル: ping.php プロジェクト: cmn32480/exec-irc-bot
#####################################################################################################
#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;
}
#####################################################################################################
コード例 #14
0
ファイル: title.php プロジェクト: cmn32480/exec-irc-bot
 if (strtolower($trailing) == "on") {
     if ($bucket == "on") {
         privmsg("  titles already enabled for " . chr(3) . "10{$dest}");
     } else {
         set_bucket("<exec_title_{$dest}>", "on");
         privmsg("  titles enabled for " . chr(3) . "10{$dest}");
     }
 } elseif (strtolower($trailing) == "off") {
     if ($bucket == "") {
         privmsg("  titles already disabled for " . chr(3) . "10{$dest}");
     } else {
         unset_bucket("<exec_title_{$dest}>");
         privmsg("  titles disabled for " . chr(3) . "10{$dest}");
     }
 } elseif (strtolower($trailing) == "url on") {
     set_bucket("<exec_title_url_{$dest}>", "on");
     privmsg("  enabled redirected url output for titles in " . chr(3) . "10{$dest}");
 } elseif (strtolower($trailing) == "url off") {
     unset_bucket("<exec_title_url_{$dest}>");
     privmsg("  disabled redirected url output for titles in " . chr(3) . "10{$dest}");
 } else {
     $redirect_data = get_redirected_url($trailing, "", "", array());
     if ($redirect_data === False) {
         term_echo("  title: get_redirected_url=false");
         return;
     }
     $rd_url = $redirect_data["url"];
     $raw = get_raw_title($redirect_data);
     if ($raw !== False) {
         $def = translate("auto", "en", $raw);
         $msg = chr(3) . "13" . $raw . chr(3);