Changeset 94 for devel/www/chat/irc_bot.php
- Timestamp:
- Jul 26, 2008, 10:16:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/www/chat/irc_bot.php
r92 r94 16 16 function __construct() 17 17 { 18 $ Jokes = file($this->JokeFileName);18 $this->Jokes = file($this->JokeFileName); 19 19 $this->File = fsockopen($this->Server, $this->Port, $ErrNumber, $ErrString, 5); 20 20 $this->Connect($this->File, $this->Nick, $this->Channel, 0); … … 29 29 } 30 30 31 function Say Private($Message, $Recepient)31 function Say($Message, $Recipient = '') 32 32 { 33 $this->Command(': PRIVMSG '.$Recepient.' :'.$Message); 34 } 35 36 function Say($Message) 37 { 38 $this->Command(':'.$Message); 33 if($Recipient == '') $Recipient = $this->Channel; 34 $this->Command(': PRIVMSG '.$Recipient.' :'.$Message); 39 35 } 40 36 … … 92 88 if($Command == 'hhelp') 93 89 { 94 $this->Say Private('Ja jsem Harvester.', $this->Channel);90 $this->Say('Ja jsem Harvester.'); 95 91 /* 96 92 irc_say( $sfp, "Harvester - Posle vizitku", $nick, $channel ); … … 107 103 } 108 104 109 // hsay:Message - Posle zpravu110 if($Command == 'hsay')111 {112 $this->SayPrivate($Commands[3], $this->Channel);113 echo("-SAID: ".$Commands[3]."\n");114 }105 // hsay:Message - Posle zpravu 106 if($Command == 'hsay') 107 { 108 $this->Say($Commands[3]); 109 echo("-SAID: ".$Commands[3]."\n"); 110 } 115 111 116 // hpsay:to:Message - Posle soukromou zpravu kanalu nebo osobe117 if($Command == 'hpsay')118 {119 $this->SayPrivate($Commands[4], $Commands[3]);120 echo("-SAID: ".$Commands[4]." -- To: ".$Commands[3]."\n");121 }112 // hpsay:to:Message - Posle soukromou zpravu kanalu nebo osobe 113 if($Command == 'hpsay') 114 { 115 $this->Say($Commands[4], $Commands[3]); 116 echo("-SAID: ".$Commands[4]." -- To: ".$Commands[3]."\n"); 117 } 122 118 123 /* 124 // hcol:to:Message - Posle kolizni zpravu kanalu nebo osobe 125 if($Command == 'hcol') 126 { 127 irc_say( $sfp, trim($commands[4]), trim($commands[3]), $channel ); 128 echo("-COLIDED: ".trim($commands[4])." To: ".trim($commands[3])."\n"); 129 } 119 // hcol:to:Message - Posle kolizni zpravu kanalu nebo osobe 120 if($Command == 'hcol') 121 { 122 $this->Say($Commands[4], $Commands[3]); 123 echo("-COLIDED: ".$Commands[4]." To: ".$Commands[3]."\n"); 124 } 130 125 131 // hdo:Command - Posle serveru prikaz132 if(trim($commands[2]) == "hdo")133 {134 $hdo = explode("hdo:", $line);135 fwrite( $sfp, trim($hdo[1])."\n");136 echo("-DONE: ".trim($hdo[1])."\n");137 }126 // hdo:Command - Posle serveru prikaz 127 if($Command == 'hdo') 128 { 129 $hdo = explode('hdo:', $Line); 130 $this->Command(trim($hdo[1])); 131 echo("-DONE: ".trim($hdo[1])."\n"); 132 } 138 133 139 // hpart:Channel - Odpoji se z kanalu 140 if(trim($commands[2]) == "hpart") 141 { 142 $hdo = explode("hpart:", $line); 143 if(trim($hdo[1]) != trim($home_channel)) 144 { 145 fwrite( $sfp, "PART :".trim($hdo[1])."\n" ); 146 echo("-PARTED: ".trim($hdo[1])."\n"); 134 // hpart:Channel - Odpoji se z kanalu 135 if($Command == 'hpart') 136 { 137 $hdo = explode('hpart:', $Line); 138 if(trim($hdo[1]) != trim($this->Channel)) 139 { 140 $this->Command('PART :'.trim($hdo[1])."\n"); 141 echo("-PARTED: ".trim($hdo[1])."\n"); 142 } 143 } 144 145 // hmove:Channel - Zmeni aktivni kanal 146 if($Command == 'hmove') 147 { 148 $hdo = explode("hmove:", $Line); 149 if(trim($hdo[1]) != trim($$this->Cannel)) 150 { 151 $this->Channel = trim($hdo[1]); 152 $this->Command('JOIN '.$this->Channel."\n"); 153 $this->Say('Hi, im here...'); 154 echo("-ACTIVATED: ".trim($hdo[1])."\n"); 155 } 156 } 157 158 // htime - udaje o casu 159 if($Command == 'htime') 160 { 161 $Date = implode("-", getdate(time())); 162 $this->Say(trim($Date)); 163 echo("-TIMED"."\n"); 164 } 165 166 // hjoke - Posle nahodny vtip 167 if($Command == 'hjoke') 168 { 169 $Joke = ($this->Jokes[rand(0, (sizeof($this->Jokes) - 1))]); 170 $this->Say(trim($Joke)); 171 echo("-JOKED"."\n"); 172 } 147 173 } 148 }149 150 // hmove:Channel - Zmeni aktivni kanal151 if(trim($commands[2]) == "hmove")152 {153 $hdo = explode("hmove:", $line);154 if(trim($hdo[1]) != trim($home_channel))155 {156 $home_channel = trim($hdo[1]);157 fwrite($sfp, "JOIN $home_channel\n");158 irc_say( $sfp, "Hi, im here...", $nick, $home_channel );159 echo("-ACTIVATED: ".trim($hdo[1])."\n");160 }161 }162 163 // htime - udaje o casu164 if(trim($commands[2]) == "htime")165 {166 $msg = implode("-", getdate(time()));167 irc_say( $sfp, trim($msg), $nick, $channel );168 echo("-TIMED"."\n");169 }170 171 // hjoke - Posle nahodny vtip172 if(trim($commands[2]) == "hjoke")173 {174 $joke = ($jokes[ rand(0, (sizeof($jokes)-1) ) ]);175 //$ftip = "Potkaji se dve blondyny a jedna rika te druhe: \"How do you do?\" a ta ji odpovi co? kde ses to naucila? To vis vzdycky pretocim radio doprava a tam mluvi jen anglicky tak se to tak ucim. Potkaji se za 2 tydny a jedna rika druhe How do you do a druha ji odpovi chsrchsrsrshchsrshchs";176 irc_say( $sfp, trim($joke), $nick, $channel );177 echo("-JOKED"."\n");178 }179 */ }180 174 } 181 175 echo("-Connection lost.\n");
Note:
See TracChangeset
for help on using the changeset viewer.