Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $commands = array(
- "say" => function($info) {
- socket_write($info["socket"], "PRIVMSG ".$info["channel"]." :".$info["msg"]." (".$info["sender"]["nick"].")\r\n");
- },
- "msg" => function($info) {
- $receiver = $info["d"][4];
- unset($info["d"][4]);
- $msg = trim(implode(" ", $info["d"]));
- socket_write($info["socket"], "PRIVMSG $receiver :$msg (sent by ".$info["sender"]["nick"].")\r\n");
- },
- "notice" => function($info) {
- $receiver = $info["d"][4];
- unset($info["d"][4]);
- $msg = trim(implode(" ", $info["d"]));
- socket_write($info["socket"], "NOTICE $receiver :$msg (sent by ".$info["sender"]["nick"].")\r\n");
- },
- "join" => function($info) {
- if (isOwner($info["sender"])) {
- socket_write($info["socket"], "JOIN ".$info["d"][4]."\r\n");
- }
- },
- "nick" => function($info) {
- if (isOwner($info["sender"])) {
- socket_write($info["socket"], "NICK ".$info["d"][4]."\r\n");
- }
- },
- "leave" => function($info) {
- if (isOwner($info["sender"])) {
- socket_write($info["socket"], "PART ".$info["channel"]."\r\n");
- }
- }
- );
- $commands["quote"] = function($info, $quotes) {
- print_r($quotes);
- $action = $info["d"][4];
- if ($action == "add") {
- unset($info["d"][4]);
- $quote = trim(preg_replace('/[\x00-\x1F\x7F]/', '', trim(implode(" ", $info["d"]))));
- if ($quote == "") {
- socket_write($info["socket"], "PRIVMSG ".$info["channel"]." :Error: can't add a blank quote\r\n");
- } else {
- $quotes[] = array(
- "quote" => $quote,
- "user" => $info["sender"]["nick"],
- "time" => date("Y-n-j G:i")
- );
- file_put_contents("./quotes.json", json_encode($quotes));
- socket_write($info["socket"], "PRIVMSG ".$info["channel"]." :Quote added at index ".count($quotes)."\r\n");
- }
- } elseif ($action == "read") {
- $index = ltrim($info["d"][5], '0');
- if ($index > count($quotes) || $index < 1) {
- socket_write($info["socket"], "PRIVMSG ".$info["channel"]." :Error: index given out of bounds. Try with a number between 1 and ".count($quotes)."\r\n");
- } else {
- $quote = $quotes[$index-1];
- socket_write($info["socket"], "PRIVMSG ".$info["channel"]." :Quote #$index added by ".$quote["user"]." at ".$quote["time"]."\r\n");
- socket_write($info["socket"], "PRIVMSG ".$info["channel"]." :".$quote["quote"]."\r\n");
- }
- }
- return $quotes;
- };
- $commands["uno"] = function($info) {
- $topcard_msg = "imabot's turn. Top Card:";
- $msg = trim(preg_replace('/[\x00-\x1F\x7F]/', '',substr($info["message"], 0, 27)));
- if ($msg == $topcard_msg) {
- write("topcard");
- }
- return false;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment