function register_event_handler($cmd, $data) { $cmd = strtoupper(trim($cmd)); $index = "<<EXEC_EVENT_HANDLERS>>"; $value = serialize(array($cmd => $data)); append_array_bucket($index, $value); term_echo("REGISTERED EVENT HANDLER: {$cmd} => \"{$data}\""); }
function run_append_array_bucket_test() { global $passed; unset_bucket(TEST_BUCKET); $count = 20; for ($i = 0; $i < $count; $i++) { append_array_bucket(TEST_BUCKET, $i); } $bucket = get_array_bucket(TEST_BUCKET); var_dump($bucket); if (count($bucket) != $count) { term_echo("run_append_array_bucket_test failed! (1)"); $passed = False; } unset_bucket(TEST_BUCKET); if (get_bucket(TEST_BUCKET) != "") { term_echo("run_append_array_bucket_test failed! (2)"); $passed = False; } }
$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); #####################################################################################################