--- /dev/null
+<?php
+class {$_NAME} extends Bot {
+ private $uplink;
+ private $quote;
+ private $topic = false;
+
+ public function load($uplink, $old = false) {
+ $this->uplink = $uplink;
+ if(!$old) {
+ $nick = "quote";
+ $ident = "QuoteBot";
+ $host = "Services.NextIRC.net";
+ $ip = "127.0.0.1";
+ $realname = "QuoteBot";
+ $modes = "ioknISD";
+ $this->quote = $this->uplink->addUser($nick,$ident,$host,$ip,$modes,$realname);
+ if(is_a($this->quote, "P10_User")) {
+ $this->uplink->join($this->quote, "#lobby", P10_Channel::USERPRIV_OPED);
+ }
+ } else {
+ $this->quote = $old;
+ }
+
+ ModCMD::bind($this, BIND_CHANMSG, "recive_privmsg");
+ ModCMD::bind($this, BIND_QUIT, "recive_quit");
+ }
+
+ public function unload($rehash = false) {
+ if($rehash) {
+ return $this->quote;
+ } else {
+ $this->uplink->delUser($this->quote, "Bye.");
+ }
+ }
+
+ public function loop() {
+
+ }
+
+ public function recive_privmsg($user, $channel, $message) {
+ $exp=explode(" ", $message, 3);
+ switch (strtolower($exp[0])) {
+ case "~bash":
+ $quelltext = file_get_contents('http://german-bash.org/action/random');
+ preg_match('#<span class="id">(.*?)</span>#is', $quelltext, $t);
+ preg_match('#<a(.*?)>(.*?)</a>#is', $t[1], $z);
+ preg_match('#<div class="zitat">(.*?)</div>#is', $quelltext, $m);
+ $string = nl2br(strip_tags($m[1]));
+ $array = explode("<br />", $string);
+ $length = count($array)-1;
+ $url = file_get_contents('http://tinyurl.com/api-create.php?url=http://german-bash.org/index.php?action=show&id='.str_replace('#', '', $z[2]));
+
+ foreach($array AS $index=>$value) {
+ $array[$index] = trim($value);
+ }
+ $this->uplink->privmsg($this->quote, $channel, "\ 2\ 39Zitatnummer:\ 2\ 30 ".$z[2]." ".$url);
+ for($i = 1; $i <= $length; $i++) {
+ if($array[$i] != '' && $array[$i] != '<br />') {
+ $this->uplink->privmsg($this->quote, $channel, html_entity_decode($array[$i]));
+ }
+ }
+ break;
+ case "~ibash":
+ $doc = new DOMDocument();
+ @$doc->loadHTMLFile("http://mobil.ibash.de/zitate.php?order=random");
+ $tags = $doc->getElementsByTagName('code');
+ $codes = $tags->item($id)->childNodes;
+ $nas = "90";
+ $bash='';
+ for ($i = 1; $i < $codes->length; $i++)
+ {
+ //$text = utf8_decode(htmlspecialchars($codes->item($i)->nodeValue));
+ $text = utf8_decode($codes->item($i)->nodeValue);
+ $bash = $bash.$text;
+ }
+ $bash = str_replace(" ", " ", $bash);
+ $bash = explode("\n", $bash);
+ #sendserv("PRIVMSG $e[2] :\002iBashDE\002");
+ $this->uplink->privmsg($this->quote, $channel, "\002iBashDE\002");
+
+ $i = 0;
+ #$this->uplink->privmsg($this->quote, $channel, print_r($bash));
+ foreach($bash as $line) {
+ $line = trim($line);
+ if(!empty($line)) {
+ $line = str_replace("<", "<", $line);
+ $line = str_replace(">", ">", $line);
+ $line = str_replace(""", '"', $line);
+ #sendserv("PRIVMSG $e[2] :".$line);
+ if($line != '') {
+ $this->uplink->privmsg($this->quote, $channel, $line);
+ } else break;
+ }
+ }
+ break;
+ }
+ }
+
+ public function recive_quit($user, $reason) {
+ if($user === $this->quote) {
+ $this->load($this->uplink);
+ }
+ }
+
+}
+?>