Advertisement
Guest User

complete

a guest
Feb 25th, 2013
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. <?php
  2. // Namespace
  3. namespace Command;
  4.  
  5. /**
  6.  * Sends the arguments to the channel, like say from a user.
  7.  * arguments[0] == Channel or User to say message to.
  8.  * arguments[1] == Message text.
  9.  *
  10.  * @package IRCBot
  11.  * @subpackage Command
  12.  * @author Daniel Siepmann <coding.layne@me.com>
  13.  */
  14. class Horoscoop extends \Library\IRC\Command\Base {
  15.     /**
  16.      * The command's help text.
  17.      *
  18.      * @var string
  19.      */
  20.     protected $help = '!horoscoop [#channel|username] whatever you want to say';
  21.  
  22.     /**
  23.      * The number of arguments the command needs.
  24.      *
  25.      * @var integer
  26.      */
  27.     protected $numberOfArguments = 1;
  28.  
  29.     /**
  30.      * Sends the arguments to the channel, like say from a user.
  31.      *
  32.      * IRC-Syntax: PRIVMSG [#channel]or[user] : [message]
  33.      */
  34.     public function command() {
  35.        switch($msg)
  36.     {
  37.         case 'ram':
  38.         case 'stier':
  39.         case 'tweeling':
  40.         case 'kreeft':
  41.         case 'leeuw':
  42.         case 'maagd':
  43.         case 'weegschaal':
  44.         case 'schorpioen':
  45.         case 'boogschutter':
  46.         case 'steenbok':
  47.         case 'waterman':
  48.         case 'vissen':
  49.             $link = 'http://www.daghoroscoop.org/sterrenbeeld/' . $msg .'.html';
  50.         break;
  51.         default:
  52.             $link = "";
  53.         break;
  54.     }
  55.     if($link == "") {
  56.             $this->send('PRIVMSG jumper : foutieve ingave, keuze uit ram stier tweeling kreeft leeuw maagd weegschaal schorpioen boogschutter steenbok waterman vissen');
  57.         } else {
  58.             $homepage = file_get_contents($link);
  59.             preg_match('#<b>(.*?)</b>#', $homepage, $match);
  60.             $result = $match[1];
  61.             $this->send('PRIVMSG ' . $chan . ' :' . $result);
  62.             preg_match('#</b><br /><br /><br />(.*?)<br /><br /><div align="center">#', $homepage, $match);
  63.  
  64.             $result = $match[1];
  65. //          $this->send('PRIVMSG ' . $chan . ' :' . $result);
  66.            
  67.             $healthy = array("&egrave;", "&eacute;");
  68.             $yummy = array("ë", "é") ;
  69.            
  70.             $result = str_replace($healthy, $yummy, $result);
  71.             $pos = 0;
  72.             $mijnarray = array();
  73.             while($pos !== false) {
  74.                 $lpos = $pos;
  75.                 $pos = strpos($result, '.', $lpos);
  76.                     if ($pos !== false) {
  77.                         $pos = strpos($result, ' ', $pos);
  78.                         if ($pos !== false) {
  79.                             $mijnarray[] = trim(substr($result,$lpos,$pos - $lpos));
  80.                             }
  81.                         else {
  82.                             $mijnarray[] = trim(substr($result, $lpos));
  83.                         }
  84.                     }
  85.            
  86.             }
  87.     }
  88.         foreach ($mijnarray as $value) {
  89.         $this->send('PRIVMSG ' . $chan . ' :' . $value);
  90.         }
  91.     }
  92. }
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement