Advertisement
MegaLoler

Page.php

Aug 25th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.39 KB | None | 0 0
  1. <?php
  2.  
  3. // lol hi
  4.  
  5. class Page // where to put page infos
  6. {
  7.     public $from = "Mystery"; // mystery person sending you messages :o
  8.     public $to = "God"; // lol
  9.     public $where = "Hell"; // :B
  10.     public $message = "GIMME A REFUND";
  11.  
  12.     function __construct($where, $from, $to, $message)
  13.     {
  14.         $this->where = $where;
  15.         $this->from = $from;
  16.         $this->to = $to;
  17.         $this->message = $message;
  18.     }
  19.  
  20.     function format()
  21.     {
  22.         $to = $this->to;
  23.         $from = $this->from;
  24.         $where = explode(":", $this->where, 2)[1];
  25.         $message = $this->message;
  26.         return "<b>$to:</b> $from sent a message to you from $where: \"$message\"";
  27.     }
  28. }
  29.  
  30. class PageModule extends extension
  31. {
  32.     public $name = 'Page';
  33.     public $version = 1;
  34.     public $about = 'Leave messages for other users the next time they are seen.';
  35.     public $status = true; // What da heck is this? o.O
  36.     public $author = 'MegaLoler'; // :D
  37.     public $type = EXT_CUSTOM;
  38.  
  39.     public $pages; // Where we put da pages :D
  40.  
  41.     function init() //mispelled function at first, lol
  42.     {
  43.         $this->pages = array();
  44.  
  45.         $this->addCmd('page', 'c_page'); // only command? o.o
  46.         $this->cmdHelp('page', 'Leave a message for someone the next time they are seen.');
  47.         $this->hook('e_recv', 'recv_msg');
  48.     }
  49.  
  50.     function e_recv($ns, $from, $message, $target)
  51.     {
  52.         if(array_key_exists(strtolower($from), $this->pages)) // oh noes, they have pages!
  53.         {
  54.             $list = $this->pages[strtolower($from)];
  55.             foreach($list as $p)
  56.             {
  57.                 $this->dAmn->say($ns, $p->format());
  58.             }
  59.             unset($this->pages[strtolower($from)]); // throw away the pages :D
  60.         }
  61.     }
  62.  
  63.     function c_page($ns, $from, $message, $target) // where dey said it, who said it, what dey said, and...something, I dunno
  64.     {
  65.         $parts = explode(" ", $message, 3); // GO BOOM!
  66.         if(count($parts) > 2) // exploded enough
  67.         {
  68.             $recipient = $parts[1];
  69.             $msg = $parts[2];
  70.             $p = new Page($ns, $from, $recipient, $msg);
  71.             if(array_key_exists(strtolower($recipient), $this->pages))
  72.             {
  73.                 array_push($this->pages[strtolower($recipient)], $p);
  74.             }
  75.             else
  76.             {
  77.                 $this->pages[strtolower($recipient)] = array($p);
  78.             }
  79.             $this->dAmn->say($ns, "Okay, $from, I will let $recipient know that the next time I see them!");
  80.         }
  81.         else // didn't explide enough :noes: so complain about it :lol:
  82.         {
  83.             $this->dAmn->say($ns, "<b>$from:</b> The correct syntax is this: \"page [recipient] [message]\"");
  84.         }
  85.     }
  86. }
  87.  
  88. new PageModule($core);
  89.  
  90. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement