Example #1
0
 function fetchDefinitionE(Dog_Plugin $plugin, $term)
 {
     $output = array();
     $res = GWF_HTTP::getFromUrl('http://www.urbandictionary.com/define.php?term=' . $term);
     if ($res === false) {
         return Dog::lang('err_timeout');
     }
     if (strstr($res, "isn't defined <a href")) {
         return $plugin->lang('none_yet', array($term, urlencode($term)));
     }
     preg_match('#<div class=\'meaning\'>(.+?)</div>.*?<div class=\'example\'>(.*?)</div>#s', $res, $arr);
     $definition = trim(html_entity_decode(strip_tags(preg_replace('#<\\s*?br\\s*?/?\\s*?>#', "\n", $arr[1]))));
     $definition = strtr($definition, array("\r" => ' ', "\n" => ' '));
     while (false !== strstr($definition, '  ')) {
         $definition = str_replace('  ', ' ', $definition);
     }
     if (strlen($definition) > 800) {
         $definition = substr($definition, 0, 800) . '...';
     }
     $output['definition'] = $definition;
     if (!empty($arr[2])) {
         $example = trim(html_entity_decode(strip_tags(preg_replace('#<\\s*?br\\s*?/?\\s*?>#', "\n", $arr[2]))));
         $example = strtr($example, array("\r" => ' | ', "\n" => ' | '));
         while (false !== strstr($example, ' |  | ')) {
             $example = str_replace(' |  | ', ' | ', $example);
         }
         while (false !== strstr($example, '  ')) {
             $example = str_replace('  ', ' ', $example);
         }
         if (strlen($example) > 800) {
             $example = substr($example, 0, 800) . '...';
         }
         $output['example'] = $example;
     }
     return $output;
 }
Example #2
0
 public function getHelp()
 {
     return 'help' === ($help = $this->lang('help')) ? Dog::lang('err_no_help') : $help;
 }
Example #3
0
 public function getHelp($trigger, $args = NULL)
 {
     $key = 'help_' . $trigger;
     if ($key === ($help = $this->lang_->lang($key))) {
         return Dog::lang('err_no_help');
     }
     return $this->replaceLang($help, $args, $trigger);
 }
Example #4
0
 public static function showVarNames(array $vars, $scope = NULL)
 {
     $serv = Dog::getServer();
     $chan = Dog::getChannel();
     $user = Dog::getUser();
     $back = array();
     foreach ($vars as $var) {
         $var instanceof Dog_Var;
         if ($var->inScope($scope) && $var->hasPermission($serv, $chan, $user)) {
             $back[] = $var->getName();
         }
     }
     return count($back) ? implode(', ', $back) : Dog::lang('none');
 }
Example #5
0
 public function connect()
 {
     if ($this->next_connect <= microtime(true)) {
         $this->attempt++;
         echo "Dog_IRC::connect() to {$this->getURL()}{$this->displaySSL()} attempt {$this->attempt}.\n";
         if (false === $this->connection->connect($this)) {
             $this->setConnectIn($this->getNextConnectTime());
             if (false !== ($connector = $this->getVarDefault('dog_connector', false))) {
                 $connector instanceof Dog_User;
                 $connector->sendPRIVMSG(Dog::lang('err_connecting', array($this->displayLongName())));
             }
             if ($this->attempt > 3 && !$this->hasConnectedOnce()) {
                 Dog::removeServer($this);
                 $this->delete();
             }
             return false;
         } else {
             $this->attempt = 2;
             return Dog_Auth::connect($this);
         }
     }
 }
Example #6
0
 public function onSend(Dog_Server $server, Dog_User $user, $message)
 {
     // 		$c = Dog::getTrigger();
     if (false === ($nickname = Common::substrUntil($message, ' ', false))) {
         return $this->lang('help_send');
     }
     $message = Common::substrFrom($message, ' ');
     if (false === ($user_to = Dog_User::getForServer($server->getID(), $nickname))) {
         return Dog::lang('err_user');
     }
     if (false === Dog_Note::isWithinLimits($user->getID())) {
         return $this->lang('err_limit', array(Dog_Note::LIMIT_AMT, GWF_Time::humanDuration(Dog_Note::LIMIT_TIME)));
     }
     if (false !== ($channel = Dog::getChannel())) {
         if (false !== $channel->getUserByName($nickname)) {
             return $this->lang('err_in_chan', array($nickname));
         }
     }
     if (false === Dog_Note::insertNote($user, $user_to, $message)) {
         return GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->lang('msg_sent', array($nickname));
 }
Example #7
0
 function dogplug_scopetxt(Dog_Plugin $plugin, $priv, $scope)
 {
     $priv = Dog::lang('priv_' . $priv);
     $scope = Dog::lang('scop_' . $scope);
     return ' ' . $plugin->lang('scope', array($scope, $priv));
 }
Example #8
0
 public static function displayChar($char)
 {
     return Dog::lang('priv_' . $char);
 }
Example #9
0
<?php

# :irc.giz.org 001 Dog :Welcome to the gizmore IRC Network Dog!Dawg@localhost
# Set bot mode
$server = Dog::getServer();
$nick = Dog::getNickname();
Dog::getOrCreateUserByName(Dog::argv(0));
if (!$server->isOptionEnabled(Dog_Server::NO_BOTFLAG)) {
    $server->sendRAW("MODE {$nick} +b");
    $server->sendRAW("MODE {$nick} +B");
}
if (false !== ($connector = $server->getVarDefault('dog_connector', false))) {
    $server->unsetVar('dog_connector');
    $connector instanceof Dog_User;
    $connector->sendPRIVMSG(Dog::lang('msg_connected', array($server->displayLongName(), Dog::getNickname(), $server->getConf('ircoppass'))));
}
$server->saveOption(Dog_Server::HAS_CONNECTED_ONCE);
$server->getNick()->identify();