コード例 #1
0
ファイル: header.php プロジェクト: cmn32480/exec-irc-bot
function get_header_login($host, $uri, $port, $header, $url)
{
    $extra_headers = array();
    $extra_headers["Cookie"] = sn_login();
    $response = whead($host, $uri, $port, ICEWEASEL_UA, $extra_headers);
    sn_logout();
    $header_value = exec_get_header($response, $header, False);
    if ($header_value != "") {
        privmsg("  {$header} header for {$url} = {$header_value}");
    }
}
コード例 #2
0
ファイル: weather_lib.php プロジェクト: cmn32480/exec-irc-bot
function set_location_alias($alias, $trailing)
{
    $parts = explode(" ", $trailing);
    if (count($parts) > 1) {
        $name = $parts[0];
        array_shift($parts);
        $location = implode(" ", $parts);
        if (set_location($name, $location) == False) {
            privmsg("error setting name \"{$name}\" for location \"{$location}\"");
        } else {
            privmsg("name \"{$name}\" set for location \"{$location}\"");
        }
    } else {
        privmsg("syntax: {$alias} name location (name cannot contain spaces but location can contain spaces)");
    }
}
コード例 #3
0
ファイル: welcome.php プロジェクト: cmn32480/exec-irc-bot
function show_welcome($nick)
{
    $location = get_location($nick);
    if ($location === False) {
        return;
    }
    $time = get_time($location);
    if ($time == "") {
        return;
    }
    $arr = convert_google_location_time($time);
    $data = process_weather($location, $nick, True);
    if ($data === False) {
        return;
    }
    if ($data["tempC"] === False or $data["tempF"] === False) {
        return;
    }
    privmsg("welcome {$nick}: " . trim($arr["location"]) . ", " . $data["tempC"] . "/" . $data["tempF"] . ", " . date("g:i a", $arr["timestamp"]) . " " . $arr["timezone"] . ", " . date("l, j F Y", $arr["timestamp"]));
}
コード例 #4
0
ファイル: help.php プロジェクト: cmn32480/exec-irc-bot
function get_help($cmd)
{
    $title = "IRC:exec aliases";
    $section = $cmd;
    if (login(True) == False) {
        return False;
    }
    $result = "";
    $text = get_text($title, $section, True, True);
    if ($text !== False) {
        for ($i = 0; $i < min(count($text), 3); $i++) {
            bot_ignore_next();
            privmsg(trim($text[$i]));
        }
        if ($cmd[0] == "~") {
            $cmd = ".7E" . substr($cmd, 1);
        }
        privmsg("http://wiki.soylentnews.org/wiki/IRC:exec_aliases#{$cmd}");
        $result = True;
    }
    logout(True);
    return $result;
}
コード例 #5
0
ファイル: 000.php プロジェクト: cmn32480/exec-irc-bot
<?php

#####################################################################################################
/*
#exec:~butt|10|0|0|1|@||||php scripts/000.php
*/
#####################################################################################################
require_once "lib.php";
privmsg(get_bucket("process_template_nick"));
#####################################################################################################
コード例 #6
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));
#####################################################################################################
コード例 #7
0
ファイル: seen.php プロジェクト: cmn32480/exec-irc-bot
            if ($delta_h != "") {
                $delta_h = $delta_h . ", ";
            }
            if ($delta_m > 1) {
                $delta_m = "{$delta_m} minutes";
            } else {
                $delta_m = "{$delta_m} minute";
            }
        } else {
            $delta_m = "";
        }
        $delta_s = round($delta - $delta_m * 60, 0);
        if ($delta_s > 0) {
            if ($delta_m != "") {
                $delta_m = $delta_m . ", ";
            }
            if ($delta_s > 1) {
                $delta_s = "{$delta_s} seconds";
            } else {
                $delta_s = "{$delta_s} second";
            }
        } else {
            $delta_s = "";
        }
        if (strlen($records[0]["trailing"]) > 300) {
            $records[0]["trailing"] = trim(substr($records[0]["trailing"], 0, 300)) . "...";
        }
        privmsg(chr(3) . $items["nick"] . ", {$trailing} was last seen in " . $items["destination"] . " {$delta_d}{$delta_h}{$delta_m}{$delta_s} ago with message: " . $records[0]["trailing"]);
    }
}
#####################################################################################################
コード例 #8
0
ファイル: confucius.php プロジェクト: cmn32480/exec-irc-bot
$host = "www.just-one-liners.com";
$port = 80;
if (mt_rand(0, 4) == 0) {
    $uri = "/";
} else {
    $uri = "/category/confucius-say-wordplay";
}
$response = wget($host, $uri, $port, $agent);
$delim1 = "<h2 class=\"title\" id=\"post-";
$delim2 = "</h2>";
$text = extract_text($response, $delim1, $delim2);
if ($text === False) {
    return;
}
$i = strpos($text, "<");
if ($i === False) {
    return;
}
$text = substr($text, $i);
$text = replace_ctrl_chars($text, " ");
$text = trim(strip_tags($text));
$text = str_replace("  ", " ", $text);
$text = html_decode($text);
$text = html_decode($text);
$text_len = strlen($text);
$max_text_length = 300;
if (strlen($text) > $max_text_length) {
    $text = trim(substr($text, 0, $max_text_length)) . "...";
}
privmsg($text);
#####################################################################################################
コード例 #9
0
ファイル: staff.php プロジェクト: cmn32480/exec-irc-bot
            }
        }
        if ($result != "") {
            term_echo($result);
            $result = strip_tags($result);
            $result = replace_ctrl_chars($result, " ");
            $result = str_replace("  ", " ", $result);
            if (strlen($result) > $max_len) {
                $result = trim(substr($result, 0, $max_len)) . "...";
            }
        } else {
            require_once "wiki_lib.php";
            $title = "Issues to Be Raised at the Next Board Meeting";
            $section = "Next meeting";
            $result = get_text($title, $section, True);
            var_dump($result);
            if (is_array($result) == True) {
                $result = trim(implode(" ", $text));
            }
            if ($result == "") {
                return;
            }
        }
        if (strlen($result) > 200) {
            $result = trim(substr($result, 0, 200)) . "...";
        }
        privmsg(chr(3) . "03" . "********** " . chr(3) . "05" . chr(2) . "SOYLENTNEWS BOARD MEETING" . chr(2) . chr(3) . "03" . " **********");
        privmsg(chr(3) . "03" . trim($result));
        break;
}
#####################################################################################################
コード例 #10
0
ファイル: say.php プロジェクト: cmn32480/exec-irc-bot
<?php

#####################################################################################################
/*
exec:~say|10|0|0|1|crutchy,chromas||||php scripts/say.php %%trailing%% %%nick%%
*/
#####################################################################################################
ini_set("display_errors", "on");
require_once "lib.php";
$trailing = $argv[1];
$parts = explode(" ", $trailing);
$dest = substr(strtolower($parts[0]), 1, strlen($parts[0]) - 2);
$ischan = False;
$isnick = False;
$delim1 = substr($parts[0], 0, 1);
$delim2 = substr($parts[0], strlen($parts[0]) - 1);
if ($delim1 == "<" and $delim2 == ">") {
    $ischan = users_chan_exists($dest);
    $isnick = users_nick_exists($dest);
}
if ($ischan == True or $isnick == True) {
    array_shift($parts);
    $trailing = implode(" ", $parts);
    pm($dest, $trailing);
    pm("crutchy", $trailing);
} else {
    privmsg($trailing);
}
#####################################################################################################
コード例 #11
0
ファイル: join.php プロジェクト: cmn32480/exec-irc-bot
<?php

#####################################################################################################
/*
exec:~invite|5|0|0|0|||||php scripts/join.php %%trailing%%
exec:~join|5|0|0|0|||||php scripts/join.php %%trailing%%
*/
#####################################################################################################
require_once "lib.php";
$parts = explode(",", $argv[1]);
$prefixes = "#&";
for ($i = 0; $i < count($parts); $i++) {
    $parts[$i] = trim($parts[$i]);
    if (strpos($prefixes, substr($parts[$i], 0, 1)) === False) {
        return;
    }
}
$chans = trim(implode(",", $parts));
if ($chans != "") {
    echo "/IRC JOIN {$chans}\n";
} else {
    privmsg("syntax: ~join <channel>[,<channel>[,<channel>]]");
}
#####################################################################################################
コード例 #12
0
ファイル: wget.php プロジェクト: cmn32480/exec-irc-bot
<?php

#####################################################################################################
/*
exec:~wget|20|0|0|1|||||php scripts/wget.php %%trailing%%
*/
#####################################################################################################
require_once "lib.php";
require_once "wget_lib.php";
$trailing = trim($argv[1]);
term_echo("wget: {$trailing}");
if ($trailing == "") {
    privmsg("syntax: ~wget url delim 1 <> delim 2");
    return;
}
$result = quick_wget($trailing);
if ($result == False) {
    privmsg("syntax: ~wget url delim 1 <> delim 2");
    return;
}
if (strlen($result) > 300) {
    $result = trim(substr($result, 0, 300)) . "...";
}
privmsg(chr(3) . "07" . $result);
#####################################################################################################
コード例 #13
0
ファイル: minion.php プロジェクト: cmn32480/exec-irc-bot
$parts = explode(" ", $trailing);
if (count($parts) < 2) {
    return;
}
$valid_data_cmd = get_valid_data_cmd(False);
$cmd = strtolower($parts[0]);
array_shift($parts);
$trailing = trim(implode(" ", $parts));
$bot_nick = $parts[0];
array_shift($parts);
$trailing = trim(implode(" ", $parts));
$forward = False;
switch ($cmd) {
    case "new":
        if (users_nick_exists($bot_nick, $dest) == True) {
            privmsg("{$bot_nick} is already here");
            return;
        }
        #$socket=fsockopen("ssl://irc.sylnt.us","6697");
        if (count($parts) == 3) {
            $server = $parts[0];
            $port = $parts[1];
        } else {
            $server = "irc.sylnt.us";
            $port = "6667";
        }
        $socket = fsockopen($server, $port);
        if ($socket === False) {
            term_echo("ERROR CREATING IRC SOCKET");
            return;
        }
コード例 #14
0
ファイル: slash_test.php プロジェクト: cmn32480/exec-irc-bot
function comment_test()
{
    global $passed;
    $subject = "test subject";
    $comment_body = "test comment body";
    $sid = "15/04/17/1849229";
    # sd-key-sid
    $parent_cid = "";
    if (sn_comment($subject, $comment_body, $sid, $parent_cid) === False) {
        privmsg("comment test failed (1)");
        $passed = False;
    }
}
コード例 #15
0
ファイル: definitions.php プロジェクト: cmn32480/exec-irc-bot
function source_define($host, $term, $params)
{
    global $debug;
    $sterm = $term;
    if ($params["space_delim"] != "") {
        $sterm = str_replace(" ", $params["space_delim"], $sterm);
    }
    $uri = str_replace($params["template"], urlencode($sterm), $params["uri"]);
    term_echo("*** DEFINE: trying {$host}{$uri} on port " . $params["port"]);
    $response = wget($host, $uri, $params["port"], ICEWEASEL_UA, "", 20);
    $html = strip_headers($response);
    $html = replace_ctrl_chars($html, " ");
    strip_all_tag($html, "head");
    strip_all_tag($html, "script");
    if ($debug == "ON") {
        privmsg("debug [{$host}]: uri = \"{$uri}\"");
        $L = strlen($html);
        privmsg("debug [{$host}]: html length = \"{$L}\"");
        unset($L);
        privmsg("debug [{$host}]: delim_start = \"" . $params["delim_start"] . "\"");
        privmsg("debug [{$host}]: delim_end = " . $params["delim_end"] . "\"");
    }
    $i = strpos($html, $params["delim_start"]);
    $def = "";
    if ($i !== False) {
        if ($debug == "ON") {
            privmsg("debug [{$host}]: delim_start pos = \"{$i}\"");
        }
        $html = substr($html, $i + strlen($params["delim_start"]));
        $i = strpos($html, $params["delim_end"]);
        if ($i !== False) {
            if ($debug == "ON") {
                privmsg("debug [{$host}]: delim_end pos = \"{$i}\"");
            }
            $def = trim(strip_tags(substr($html, 0, $i)));
            $def = str_replace(array("\n", "\r"), " ", $def);
            $def = str_replace("  ", " ", $def);
            if (strlen($def) > MAX_DEF_LENGTH) {
                $def = trim(substr($def, 0, MAX_DEF_LENGTH)) . "...";
            }
        }
    }
    if ($def == "") {
        $location = exec_get_header($response, "location");
        if ($location == "") {
            return False;
        } else {
            $new_term = extract_text($location, $params["get_param"], "&", True);
            if ($new_term != $term) {
                term_echo("redirecting to \"{$location}\"");
                if ($debug == "ON") {
                    privmsg("debug [{$host}]: redirecting to \"{$location}\"");
                }
                return source_define($host, $new_term, $params);
            } else {
                return False;
            }
        }
    } else {
        if ($params["ignore"] != "" and strpos($def, $params["ignore"]) !== False) {
            return False;
        }
        if (strpos($def, "There aren't any definitions") !== False) {
            return False;
        }
        privmsg("[" . $params["name"] . "] " . chr(3) . "03{$term}" . chr(3) . ": " . html_decode($def));
        return True;
    }
}
コード例 #16
0
ファイル: submit.php プロジェクト: cmn32480/exec-irc-bot
    return;
}
sleep(25);
$params = array();
$params["reskey"] = $reskey;
#$params["name"]=trim(substr($nick,0,50));
$params["name"] = get_bot_nick();
$params["email"] = "";
$params["subj"] = trim(substr($source_title, 0, 100));
$params["primaryskid"] = "1";
$params["tid"] = "6";
$params["sub_type"] = "plain";
$params["story"] = $source_body . "\n\n" . $url . "\n\n-- submitted from IRC";
$params["op"] = "SubmitStory";
$response = wpost($host, $uri, $port, ICEWEASEL_UA, $params);
$html = strip_headers($response);
strip_all_tag($html, "head");
strip_all_tag($html, "script");
strip_all_tag($html, "style");
strip_all_tag($html, "a");
$html = strip_tags($html);
$html = clean_text($html);
var_dump($html);
# TODO: extract success/error message and output to IRC
if (strpos($html, "Perhaps you would like to enter an email address or a URL next time. Thanks for the submission.") !== False) {
    privmsg("submission successful - https://{$host}/submit.pl?op=list");
} else {
    privmsg("error: something went wrong with your submission");
}
# TODO: testing... much more testing
#####################################################################################################
コード例 #17
0
ファイル: google.php プロジェクト: cmn32480/exec-irc-bot
<?php

#####################################################################################################
/*
exec:~google|20|0|0|1|||||php scripts/google.php %%trailing%%
exec:~g|20|0|0|1|||||php scripts/google.php %%trailing%%
*/
#####################################################################################################
require_once "lib.php";
require_once "google_lib.php";
$trailing = trim($argv[1]);
if ($trailing == "") {
    return;
}
$results = google_search($trailing);
if ($results !== False) {
    if (count($results) > 0) {
        if (strlen($results[0]) > 300) {
            return;
        }
        privmsg("[google] " . $results[0]);
    }
}
#####################################################################################################
コード例 #18
0
ファイル: tell.php プロジェクト: cmn32480/exec-irc-bot
$trailing = trim($argv[1]);
$dest = $argv[2];
$nick = strtolower($argv[3]);
$alias = $argv[4];
$server = $argv[5];
if ($trailing == "register-events") {
    register_event_handler("PRIVMSG", ":%%nick%% INTERNAL %%dest%% :~tell-internal %%trailing%%");
    return;
}
if ($alias == "~tell") {
    if ($trailing == "") {
        privmsg("syntax: ~tell <nick> <message>");
        return;
    }
    $parts = explode(" ", $trailing);
    $target = strtolower($parts[0]);
    array_shift($parts);
    $trailing = trim(implode(" ", $parts));
    append_array_bucket("TELL_MESSAGES_" . $server . "_" . $target, $target . ", at " . date("Y-m-d H:i:s", microtime(True)) . " (UTC), " . $nick . " left message from " . $dest . ": " . $trailing);
    privmsg("message saved");
    return;
}
if (substr($trailing, 0, 5) == "~tell") {
    return;
}
$messages = get_array_bucket("TELL_MESSAGES_" . $server . "_" . $nick);
for ($i = 0; $i < count($messages); $i++) {
    notice($nick, $messages[$i]);
}
unset_bucket("TELL_MESSAGES_" . $server . "_" . $nick);
#####################################################################################################
コード例 #19
0
ファイル: jisho2.php プロジェクト: cmn32480/exec-irc-bot
    }
    if (count($results["data"][$i]["senses"]) > 0) {
        $out = $out . " ";
    }
    $senses = $results["data"][$i]["senses"];
    for ($j = 0; $j < count($senses); $j++) {
        $meanings = "";
        if (count($senses) > 1) {
            if (count($senses[$j]["english_definitions"]) > 0) {
                if ($j > 0) {
                    $meanings = $meanings . " | ";
                }
            }
        }
        for ($k = 0; $k < count($senses[$j]["english_definitions"]); $k++) {
            if ($k > 0) {
                $meanings = $meanings . ", ";
            }
            $meanings = $meanings . $senses[$j]["english_definitions"][$k];
        }
        $out = $out . $meanings;
    }
    if ($out != "") {
        privmsg($out);
    }
}
if (count($results["data"]) == 0) {
    privmsg("http://jisho.org/search/" . $trailing . " [no results]");
} else {
    privmsg("http://jisho.org/search/" . $trailing . " [" . count($results["data"]) . " results]");
}
コード例 #20
0
ファイル: irc_lib.php プロジェクト: cmn32480/exec-irc-bot
function kill($items, $pid)
{
    global $handles;
    foreach ($handles as $index => $handle) {
        if ($handle["pid"] == $pid) {
            if (kill_process($handle) == True) {
                unset($handles[$index]);
                privmsg($items["destination"], $items["nick"], "successfully terminated process with pid {$pid}");
            } else {
                privmsg($items["destination"], $items["nick"], "error terminating process with pid {$pid}");
            }
            return;
        }
    }
    privmsg($items["destination"], $items["nick"], "unable to find process with pid {$pid}");
}
コード例 #21
0
ファイル: jisho.php プロジェクト: cmn32480/exec-irc-bot
    $result["kanji"] = False;
    if ($result_kanji !== False) {
        $result["kanji"] = trim(strip_tags($result_kanji));
    }
    if ($result_english !== False) {
        $result["english"] = trim(strip_tags($result_english));
        $results[] = $result;
    }
}
$n = 0;
for ($i = 0; $i < count($results); $i++) {
    if ($results[$i]["hiragana"] === False and $results[$i]["kanji"] !== False) {
        privmsg(chr(3) . $results[$i]["kanji"] . ", " . $results[$i]["english"]);
        $n++;
    } elseif ($results[$i]["hiragana"] !== False and $results[$i]["kanji"] === False) {
        privmsg(chr(3) . $results[$i]["hiragana"] . ", " . $results[$i]["english"]);
        $n++;
    } elseif ($results[$i]["hiragana"] !== False and $results[$i]["kanji"] !== False) {
        privmsg(chr(3) . $results[$i]["hiragana"] . ", " . $results[$i]["kanji"] . ", " . $results[$i]["english"]);
        $n++;
    }
    if ($n >= $max_items) {
        break;
    }
}
if ($n == 0) {
    privmsg("no results");
} else {
    privmsg(count($results) . " results");
}
#####################################################################################################
コード例 #22
0
ファイル: remind.php プロジェクト: cmn32480/exec-irc-bot
$value = $parts[0];
$unit = $parts[1];
array_shift($parts);
array_shift($parts);
$msg = implode(" ", $parts);
if (exec_is_integer($value) == False or $value == "" or $value < 0 or $value > 99990) {
    privmsg("error: value must be a positive integer");
    privmsg($syntax);
    return;
}
switch (strtolower($unit)) {
    case "min":
    case "m":
        $value = $value * 60;
        break;
    case "sec":
    case "s":
        break;
    default:
        privmsg("error: invalid unit");
        privmsg($syntax);
        return;
}
privmsg("*** reminder set for {$nick}: {$msg}");
sleep($value);
if ($msg != "") {
    privmsg("*** reminder for {$nick}: {$msg}");
} else {
    privmsg("*** reminder for {$nick}");
}
#####################################################################################################
コード例 #23
0
ファイル: wiki_lib.php プロジェクト: cmn32480/exec-irc-bot
function wiki_blockuser($nick, $trailing, $return = False)
{
    $title = trim(substr($trailing, strlen(".delpage") + 1));
    if ($title == "") {
        wiki_privmsg($return, "wiki: delpage=invalid title");
        return False;
    }
    $account = users_get_account($nick);
    $allowed = array("ncommander", "funpika", "mrcoolbp", "paulej72");
    # official wiki admins
    if (in_array($account, $allowed) == False) {
        $allowed = array("juggs", "crutchy", "chromas", "themightybuzzard", "martyb");
        # trusted irc nickserv accounts
        if (in_array($account, $allowed) == True) {
            $del_pages_list = array();
            $auth = False;
            if (file_exists(DATA_PATH . "wiki_del_pages") == True) {
                $del_pages_list = explode(PHP_EOL, file_get_contents(DATA_PATH . "wiki_del_pages"));
                delete_empty_elements($del_pages_list, True);
                $title_exists = False;
                for ($i = 0; $i < count($del_pages_list); $i++) {
                    $parts = explode(" ", $del_pages_list[$i]);
                    $del_page_account = trim($parts[0]);
                    array_shift($parts);
                    $del_page_title = implode(" ", $parts);
                    if ($del_page_title === $title) {
                        $title_exists = True;
                        if ($del_page_account != $account) {
                            $auth = True;
                            unset($del_pages_list[$i]);
                            break;
                        }
                    }
                }
                if ($auth == False) {
                    if ($title_exists == False) {
                        $del_pages_list[] = $account . " " . $title;
                        privmsg("page with title \"{$title}\" added to wiki del pages file. need another authorized account to finalize page deletion [1]");
                    } else {
                        privmsg("page with title \"{$title}\" already added to wiki del pages file. need a different authorized account to finalize page deletion");
                    }
                }
            } else {
                $del_pages_list[] = $account . " " . $title;
                privmsg("page with title \"{$title}\" added to wiki del pages file. need another authorized account to finalize page deletion [2]");
            }
            if (file_put_contents(DATA_PATH . "wiki_del_pages", implode(PHP_EOL, $del_pages_list)) === False) {
                privmsg("error writing del pages list file");
            }
            if ($auth == False) {
                return False;
            }
        } else {
            privmsg("  error: not authorized");
            return False;
        }
    }
    # make sure title not in del pages file
    if (file_exists(DATA_PATH . "wiki_del_pages") == True) {
        $del_pages_list = explode(PHP_EOL, file_get_contents(DATA_PATH . "wiki_del_pages"));
        delete_empty_elements($del_pages_list, True);
        for ($i = 0; $i < count($del_pages_list); $i++) {
            $parts = explode(" ", $del_pages_list[$i]);
            array_shift($parts);
            $del_page_title = implode(" ", $parts);
            if ($del_page_title === $title) {
                unset($del_pages_list[$i]);
            }
        }
        file_put_contents(DATA_PATH . "wiki_del_pages", implode("\n", $del_pages_list));
    }
    /*if (login($nick,True)==False)
      {
        privmsg("  login error");
        return;
      }
      $cookieprefix=get_bucket("wiki_login_cookieprefix");
      $sessionid=get_bucket("wiki_login_sessionid");
      if (($cookieprefix=="") or ($sessionid==""))
      {
        wiki_privmsg($return,"wiki: delpage=not logged in");
        return False;
      }
      $headers=array("Cookie"=>login_cookie($cookieprefix,$sessionid));
      $uri="/w/api.php?action=query&meta=tokens&format=php&type=csrf";
      $response=wget(WIKI_HOST,$uri,80,WIKI_USER_AGENT,$headers);
      $data=unserialize(strip_headers($response));
      if (isset($data["query"]["tokens"]["csrftoken"])==False)
      {
        wiki_privmsg($return,"wiki: delpage=error getting csrftoken");
        return False;
      }
      $token=$data["query"]["tokens"]["csrftoken"];
      $uri="/w/api.php?action=delete&title=".urlencode($title)."&format=php&reason=spamctl";
      $params=array("token"=>$token);
      $response=wpost(WIKI_HOST,$uri,80,WIKI_USER_AGENT,$params,$headers);
      $data=unserialize(strip_headers($response));
      logout(True);
      if (isset($data["error"])==True)
      {
        wiki_privmsg($return,"wiki: delpage=".$data["error"]["code"]);
        return False;
      }
      else
      {
        if (isset($data["delete"]["logid"])==True)
        {
          $msg="wiki: delpage=logid ".$data["delete"]["logid"];
          wiki_privmsg($return,$msg);
          return True;
        }
        else
        {
          $msg="wiki: delpage=logid not found";
          wiki_privmsg($return,$msg);
          return False;
        }
      }*/
}
コード例 #24
0
ファイル: sed.php プロジェクト: cmn32480/exec-irc-bot
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;
}
コード例 #25
0
ファイル: time.php プロジェクト: cmn32480/exec-irc-bot
            privmsg("location \"{$trailing}\" deleted");
        } else {
            if (trim($trailing) != "") {
                privmsg("location for \"{$trailing}\" not found");
            } else {
                privmsg("syntax: ~time-del <name>");
            }
        }
        break;
    case "~time":
        $loc = get_location($trailing, $nick);
        if ($loc === False) {
            if ($trailing == "") {
                privmsg("syntax: ~time location");
                privmsg("time data courtesy of Google");
                return;
            }
            $loc = $trailing;
        }
        term_echo("*** TIME LOCATION: {$loc}");
        $result = get_time($loc);
        if ($result != "") {
            $arr = convert_google_location_time($result);
            #privmsg($result);
            privmsg(date("l, j F Y @ g:i a", $arr["timestamp"]) . " " . $arr["timezone"] . " - " . $arr["location"]);
        } else {
            privmsg("location not found - UTC timestamp: " . date("l, j F Y, g:i a"));
        }
        break;
}
#####################################################################################################
コード例 #26
0
ファイル: japanese.php プロジェクト: cmn32480/exec-irc-bot
    return;
}
$uri = "/dictionary/meaning-of-" . urlencode($trailing) . ".html";
$response = wget(HOST, $uri);
$html = strip_headers($response);
if ($html === False) {
    privmsg("error downloading");
    return;
}
$items = explode("<div class=\"search_items\">", $html);
array_shift($items);
$n = min(MAX_ITEMS, count($items));
$results = array();
for ($i = 0; $i < $n; $i++) {
    $delim1 = "<ruby>";
    $delim2 = "</ruby>";
    $result = extract_text($items[$i], $delim1, $delim2);
    if ($result !== False) {
        $result = str_replace("<rp>(", " <rp>(", $result);
        $results[] = strip_tags($result);
    }
}
if (count($results) > 0) {
    for ($i = 0; $i < count($results); $i++) {
        privmsg($results[$i]);
    }
    privmsg(HOST . $uri);
} else {
    privmsg("no results");
}
#####################################################################################################
コード例 #27
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;
    }
}
コード例 #28
0
ファイル: wiki.php プロジェクト: cmn32480/exec-irc-bot
            }
            $title = $parts[0];
            $section = $parts[1];
            $text = $parts[2];
            edit($title, $section, $text);
            break;
        case "get":
            array_shift($parts);
            $trailing = implode(" ", $parts);
            $parts = explode("|", $trailing);
            if (count($parts) != 1 and count($parts) != 2) {
                privmsg("syntax: ~wiki get title[|section]");
                return;
            }
            $title = $parts[0];
            $section = "";
            if (isset($parts[1]) == True) {
                $section = $parts[1];
            }
            get_text($title, $section);
            break;
        case "logout":
            logout();
            break;
        default:
            privmsg("wiki: no action specified");
    }
} else {
    privmsg("wiki: not logged in");
}
#####################################################################################################
コード例 #29
0
ファイル: location.php プロジェクト: cmn32480/exec-irc-bot
<?php

#####################################################################################################
/*
exec:~location|5|0|0|0|||||php scripts/location.php %%trailing%%
*/
#####################################################################################################
require_once "lib.php";
require_once "weather_lib.php";
$location = strtolower(trim($argv[1]));
$code = get_location($location);
if ($code === False or $code == "") {
    privmsg("*** location \"{$location}\" not found");
} else {
    privmsg("*** location \"{$location}\" = \"{$code}\"");
}
#####################################################################################################
コード例 #30
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;
}
#####################################################################################################