Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- ini_set("display_errors", 1);
- $host='irc.quakenet.org';
- $port=6667;
- $mynickname='Sakarinpelin';
- echo "Connecting...\r\n";
- $game_won = false;
- $gamestate = 0;
- function game_reset()
- {
- global $gamestate;
- $gamestate = 0;
- sleep(2);
- irc_cmsg('Sakarin villapaitapeli!');
- sleep(2);
- }
- function game_start()
- {
- global $gamestate;
- $gamestate = 1;
- sleep(2);
- irc_cmsg('Pue sakarille villapaita');
- sleep(2);
- }
- function game_win()
- {
- global $gamestate;
- $gamestate = 2;
- $game_won = true;
- sleep(2);
- irc_cmsg(chr(1).'ACTION pukee päällensä sakarin villapaidan'.chr(1));
- sleep(4);
- irc_cmsg('Hihihi!');
- sleep(1);
- irc_cmsg('Kutittaa!');
- sleep(1);
- irc_cmsg('Voitit pelin!');
- sleep(2);
- }
- function game_lose()
- {
- global $gamestate;
- $gamestate = 2;
- $game_won = false;
- sleep(2);
- irc_cmsg('Hmm...');
- sleep(2);
- irc_cmsg('Hävisit pelin!');
- sleep(2);
- }
- $fp=fsockopen($host,$port,$errno,$errstr,15);
- $ch = "#soldat.dota";
- if (!$fp) die("Error: $errstr ($errno)\r\n");
- IRCSocketMsg('NICK '.$mynickname."\r\n");
- IRCSocketMsg('USER '.strtolower($mynickname)." * * :rofl\r\n");
- function IRCSocketMsg($string) {
- global $fp;
- fputs($fp,$string);
- }
- function IRCMsg($msg) {
- global $ch;
- IRCSocketMsg("PRIVMSG $ch :\00307".$msg."\r\n");
- }
- function irc_cmsg($msg) {
- global $ch;
- IRCSocketMsg("PRIVMSG $ch :".$msg."\n");
- }
- function IRCJoin($channel,$password) {
- IRCSocketMsg("JOIN $channel $password\r\n");
- }
- function IRCPart($channel) {
- IRCSocketMsg("PART $channel\r\n");
- }
- function GetNIH($useraddress,&$nickname,&$ident,&$hostname) {
- $nickname=substr($useraddress,0,strpos($useraddress,'!'));
- $ident=substr($useraddress,strpos($useraddress,'!')+1,-strpos($useraddress,'@')-1);
- $hostname=substr($useraddress,strpos($useraddress,'@')+1);
- }
- while (true) {
- sleep(1);
- while ($data = fgets($fp)) {
- $data=trim($data);
- echo $data."\r\n";
- $arg=explode(' ',$data);
- $msg=substr($data,strpos($data,':',1)+1);
- switch ($arg[0]) {
- case 'PING':
- IRCSocketMsg("PONG $arg[1]\r\n");
- break;
- }
- switch ($arg[1]) {
- case '004':
- IRCJoin($ch,"");
- sleep(1);
- game_reset();
- echo "Done!\r\n";
- break;
- case '431': //ERR_NONICKNAMEGIVEN
- case '432': //ERR_ERRONEUSNICKNAME
- case '433': //ERR_NICKNAMEINUSE
- case '436': //ERR_NICKCOLLISION
- $mynickname.=rand(1,9);
- IRCSocketMsg('NICK '.$mynickname."\r\n");
- break;
- case 'PRIVMSG':
- $chan = $arg[2];
- $msgarg = explode(' ', $msg);
- if (strtolower($arg[2]) != $ch)
- break;
- switch (strtolower($msgarg[0]))
- {
- case 'aloita':
- if ($gamestate == 0)
- game_start();
- break;
- case 'en':
- if ($gamestate == 1)
- game_lose();
- break;
- case 'joo':
- if ($gamestate == 1)
- game_win();
- break;
- case 'uudestaan':
- if ($gamestate == 2 && $game_won == false)
- game_reset();
- break;
- case 'uudelleen':
- if ($gamestate == 2 && $game_lost == true)
- game_reset();
- break;
- }
- break;
- }
- }
- }
- fclose($fp);
- ?>
Add Comment
Please, Sign In to add comment