예제 #1
0
 public function onAddLink(Dog_Server $server, Dog_User $user, $from, $origin, $message)
 {
     if ($message === '') {
         $count = count($this->links);
         return "I have {$count} active links.";
     }
     $links = preg_split('/ +/', $message);
     $the_link = array();
     foreach ($links as $link) {
         list($s, $chan) = explode(':', $link);
         $chan = strtolower($chan);
         if (false === ($serv = Dog_Server::getByMsg($s))) {
             return 'Unknown Server: ' . $s;
         }
         $sid = $serv->getID();
         $l = "{$sid}:{$chan}";
         if ('' !== ($error = $this->checkLink($l, true))) {
             return $error;
         }
         $the_link[] = $l;
     }
     $the_link = array_unique($the_link);
     if (count($the_link) < 2) {
         return "You need at least 2 different spam destinations.";
     }
     $the_link = implode(',', $the_link);
     $this->links[] = $the_link;
     if ($this->links_saved !== '') {
         $this->links_saved .= ';';
     }
     $this->links_saved .= $the_link;
     if (false === $this->saveLinks()) {
         return "DATABASE ERROR!";
     }
     return sprintf("Added IRC Link: %s", $the_link);
 }