Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- ini_set('display_errors', 'on');
- $config = array(
- 'server' => 'url ohne http://www.*********.de oder IP',
- 'port' => 'Port',
- 'channel' => 'Channelname mit #Davor zb: #Nehirm',
- 'name' => 'Channel Bot - #Nehirm',
- 'nick' => 'ChanServ',
- 'pass' => 'Meist leerlassen',
- );
- class IRCBot {
- var $socket;
- var $ex = array();
- var $info = "Dies is eine Info, die mit dem befehl !info aufgerufen werden kann";
- var $witze = "Was fragt Abraham, Betraham? Kann ich ma n Zebra ham.";
- var $neil = "Neil du sollst Evolutio mal anschreiben ^^"; function __construct($config) {
- $this->socket = fsockopen($config['server'], $config['port']);
- $this->login($config);
- }
- function login($config) { $this->sd('PASS', $config['pass']);
- $this->sd('USER', $config['ident'].' test test :'.$config['name']); $this->sd('NICK', $config['nick']); }
- public function main($config)
- {
- $data = fgets($this->socket, 256);
- echo nl2br($data);
- flush();
- $this->ex = explode(' ', $data);
- if($this->ex[0] == 'PING')
- { $this->sd('PONG', $this->ex[1]); //spielt pingpong mit dem server um die verbindung aufrechtzuerhalten ;)
- }
- $unick = explode('!', $this->ex[0]);
- $nicku = explode(':', $unick[0]);
- $message = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]." :"));
- $messageminuseins = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]));
- $message = trim($message); $dbgmessage = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]." :".$this->ex[3]));
- $setmessage = substr($data,strlen($this->ex[0]." ".$this->ex[1]." ".$this->ex[2]." :".$this->ex[3]." ".$this->ex[4])); $uhost = explode('@', $this->ex[0]); $mps = explode(' ',$message);
- switch($this->ex[1]) {
- case 'JOIN':
- $this->msg($this->ex[2],'Da ist wohl wer gejoint! - Hallo '.$nicku[1]);
- break;
- }
- if($this->ex[1] == "JOIN" AND $uhost[1] =="Evolutio.user.OnlineGamesNet") $this->sd('MODE '.$this->ex[1].' +o '.$nicku[1]); switch($mps[0]) {
- case '!join':
- $this->sd("JOIN ".$mps[1]);
- break;
- case '!die':
- die();
- break;
- case "!part":
- $this->sd("PART ".$mps[1]);
- break;
- case "!kick":
- $this->sd("KICK ".$this->ex[2]." ".$mps[1]);
- break;
- case '!info':
- $this->msg($this->ex[2],$this->info);
- break;
- case '!witze':
- $this->msg($this->ex[2],$this->witze);
- break;
- case '!oup':
- if($uhost[1] =="Evolutio.user.OnlineGamesNet" OR $uhost[1]=="Neil.user.OnlineGamesNet") {
- if(isset($mps[1])) $nick = $mps[1]; else $nick = $nicku[1]; $this->sd('MODE '.$this->ex[2].' +o '.$nick);
- }
- break;
- case '!odown':
- $this->sd('MODE '.$this->ex[2].' -o '.$nicku[1]);
- break;
- case '!vup':
- if($uhost[1] =="Evolutio.user.OnlineGamesNet" OR $uhost[1]=="Neil.user.OnlineGamesNet") {
- if(isset($mps[1])) $nick = $mps[1]; else $nick = $nicku[1]; $this->sd('MODE '.$this->ex[2].' +v '.$nick);
- }
- break;
- case '!vdown':
- $this->sd('MODE '.$this->ex[2].' -v '.$nicku[1]);
- break;
- case '!wakeup':
- if(isset($mps[1]))
- $this->msg($this->ex[2],$mps[1].' , Du sollst mal Evolutio anschreiben!');
- break;
- case '!debug':
- eval($dbgmessage);
- break;
- }
- }
- function sd($cmd, $msg=NULL) //displays stuff to the broswer and sends data to the server.
- {
- if($msg == NULL)
- {
- fputs($this->socket, $cmd."\r\n"); echo '<strong>'.$cmd.'</strong><br />'; } else {
- fputs($this->socket, $cmd.' '.$msg."\r\n");
- echo '<strong>'.$cmd.' '.$msg.'</strong><br />';
- }
- }
- function msg($target,$msg) {
- fputs($this->socket, 'PRIVMSG '.$target.' :'.$msg."\r\n");
- echo '<strong>PRIVMSG '.$target.' :'.$msg.'</strong><br />';
- }
- function notice($target,$msg) {
- fputs($this->socket, 'NOTICE '.$target.' :'.$msg."\r\n");
- echo '<strong>NOTICE '.$target.' :'.$msg.'</strong><br />';
- }
- function in_str($search,$subject) {
- if(str_replace($search,'',$subject) == $subject) return false;
- else return true; }
- }
- $bot = new IRCbot($config); while(1) {
- $bot->main($config); }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement