X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=Bots%2FQuote.class.php;fp=Bots%2FQuote.class.php;h=9826c509e2c7eee67dcb71dc2bc5f35a3111b76c;hp=0000000000000000000000000000000000000000;hb=db4efc501d78e76da03e2a87513f3e18ee627978;hpb=f2518601341be698541f0a642aa750ef0187cfd4
diff --git a/Bots/Quote.class.php b/Bots/Quote.class.php
new file mode 100644
index 0000000..9826c50
--- /dev/null
+++ b/Bots/Quote.class.php
@@ -0,0 +1,106 @@
+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('#(.*?)#is', $quelltext, $t);
+ preg_match('#(.*?)#is', $t[1], $z);
+ preg_match('#
(.*?)
#is', $quelltext, $m);
+ $string = nl2br(strip_tags($m[1]));
+ $array = explode("
", $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, "9Zitatnummer:0 ".$z[2]." ".$url);
+ for($i = 1; $i <= $length; $i++) {
+ if($array[$i] != '' && $array[$i] != '
') {
+ $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);
+ }
+ }
+
+}
+?>