示例#1
0
 private static function getAutoTargetISO()
 {
     if (false !== ($channel = Dog::getChannel())) {
         return $channel->getLangISO();
     } else {
         return Dog::getUser()->getLangISO();
     }
 }
示例#2
0
 /**
  * We hook into PRIVMSG to record activity.
  */
 public function event_privmsg()
 {
     if (!Dog::isTriggered()) {
         if (false !== Dog::getUser()) {
             Dog_Seen::record(Dog::getUser(), Dog::getChannel(), 'privmsg', $this->msg());
         }
     }
 }
示例#3
0
 /**
  * Rejoin on kick :)
  */
 public function event_KICK()
 {
     $server = Dog::getServer();
     if (Dog::argv(1) === $server->getNick()->getName()) {
         if ($this->getConfig('kickjoin')) {
             $server->joinChannel(Dog::getChannel());
         }
     }
 }
示例#4
0
 public function on_slap_Pc()
 {
     $message = $this->msgarg();
     if ($message === '') {
         return $this->showHelp('slap');
     }
     $channel = Dog::getChannel();
     $origin = $channel->getName();
     require $this->getPath() . 'slaps.php';
     $server = Dog::getServer();
     $user = Dog::getUser();
     $damage = 10000;
     list($adverb, $dmg_adv) = $this->getRandomItem($slaps['adverbs']);
     $damage = $this->applyDamage($damage, $dmg_adv);
     list($verb, $dmg_verb) = $this->getRandomItem($slaps['verbs']);
     $damage = $this->applyDamage($damage, $dmg_verb);
     list($adjective, $dmg_adj) = $this->getRandomItem($slaps['adjectives']);
     $damage = $this->applyDamage($damage, $dmg_adj);
     list($item, $dmg_item) = $this->getRandomItem($slaps['items']);
     $damage = $this->applyDamage($damage, $dmg_item);
     $damage = round($damage);
     $target_name = Common::substrUntil($message, ' ');
     # Check if a non record slap
     $fake = false;
     if (false === ($target = $this->getTarget($server, $target_name, $origin))) {
         $fake = true;
     } elseif (true !== ($remain = Dog_SlapHistory::maySlap($user->getID(), $target->getID(), $this->getTimeout()))) {
         $fake = true;
     } elseif (true !== ($toomuch = Dog_SlapHistory::maySlapMore($user->getID(), $this->getTimeout(), $this->getSlapsPerPlayer()))) {
         $fake = true;
     }
     if ($target instanceof Dog_User) {
         $target_name = Dog::softhyphe($target->getName());
     }
     $message = sprintf('%s %s %s %s with %s %s.', $user->getVar('user_name'), $adverb, $verb, $target_name, $adjective, $item);
     # Insert slap
     if ($fake === true) {
         if (false === Dog_SlapHistory::slapTimeout($adverb, $dmg_adv, $verb, $dmg_verb, $adjective, $dmg_adj, $item, $dmg_item)) {
             return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
         }
         if (isset($remain) && $remain !== true) {
             $malus = $this->getRemainMalus();
             Dog_SlapUser::removePoints($user->getID(), $malus);
             $message .= sprintf(' (%s remaining, Lost %d points).', GWF_Time::humanDuration($remain), $malus);
         } elseif (isset($toomuch) && $toomuch !== true) {
             $malus = $this->getPerPlayerMalus();
             Dog_SlapUser::removePoints($user->getID(), $malus);
             $message .= sprintf(' (more than %d slaps within %s. Lost %d points).', $this->getSlapsPerPlayer(), GWF_Time::humanDuration($this->getTimeout()), $malus);
         }
     } else {
         if (false === Dog_SlapHistory::slap($user, $target, $adverb, $dmg_adv, $verb, $dmg_verb, $adjective, $dmg_adj, $item, $dmg_item, $damage)) {
             return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__);
         }
         $message .= ' (' . $damage . ' damage).';
     }
     $server->reply($message);
 }
示例#5
0
 private function announceVideo(array $data)
 {
     // Pick ISO for channel?
     if (false !== ($chan = Dog::getChannel())) {
         $iso = $chan->getLangISO();
     } else {
         $iso = Dog::getUser()->getLangISO();
     }
     $vars = array($data['title'], GWF_TimeConvert::humanDurationISO($iso, $data['duration']), sprintf('%.02f', $data['rating']), number_format($data['views']), number_format($data['num_raters']));
     Dog::reply($this->langISO($iso, 'video', $vars));
 }
示例#6
0
 public function on_hang_Pc()
 {
     $channel = Dog::getChannel();
     if (false === isset($this->instances[$channel->getID()])) {
         $config = array('solution_allowed_everytime' => $this->getConfig('solve_anytime', 'c') === '1', 'placeholder' => $this->getConfig('placeholder', 'c'), 'lives' => $this->getConfig('lives', 'c'), 'singleplayer' => $this->getConfig('singleplayer', 'c') === '1');
         $this->instances[$channel->getID()] = new HangmanGame($config);
     }
     $hang = $this->instances[$channel->getID()];
     $hang instanceof HangmanGame;
     $this->reply($hang->onGuess(Dog::getUser()->getName(), $this->msgarg()));
 }
示例#7
0
 public function on_peak_Lc()
 {
     $channel = Dog::getChannel();
     if (false === ($peak = Dog_ChannelPeak::getPeak($channel))) {
         return Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $date = $peak->getVar('lcpeak_date');
     $count = $peak->getVar('lcpeak_peak');
     $count_now = $channel->getUserCount();
     $age = GWF_Time::displayAge($date);
     $date = GWF_Time::displayDate($date);
     $args = array($count, $channel->getName(), Dog::getServer()->displayLongName(), $date, $age, $this->peekshowstring());
     $this->rply('old_peak', $args);
 }
示例#8
0
 public function collectorEnabled($collector = 'collect')
 {
     if (Dog::getUser() === false) {
         return false;
     }
     $user = $this->getCollectConf($collector . '_user', 'u');
     $chan = $this->getCollectConf($collector . '_chan', 'c');
     $serv = $this->getCollectConf($collector . '_serv', 's');
     $glob = $this->getCollectConf($collector . '_glob', 'g');
     if (false !== Dog::getChannel()) {
         return $this->collectorEnabledArray(array($user, $chan, $serv, $glob));
     } else {
         return $this->collectorEnabledArray(array($user, $serv, $glob));
     }
 }
示例#9
0
 public static function onLocationGlobalMessage(SR_Player $player, $key, $args = NULL)
 {
     $server = Dog::getServer();
     $channel = Dog::getChannel();
     $sid = $server->getID();
     //		$cid = $channel->getID();
     $party = $player->getParty();
     //		$b = chr(2);
     //		$message = sprintf('%s in %s: "%s".', $player->getName(), $party->getLocation(), $message);
     // 		$sent = 0;
     foreach (Shadowrun4::getParties() as $pid => $p) {
         // 			echo "party $pid\n";
         if ($party->sharesLocation($p)) {
             // 				echo "partyy $pid\n";
             foreach ($p->getMembers() as $m) {
                 $m instanceof SR_Player;
                 if ($m->isCreated()) {
                     // 						if (false === ($u = $m->getUser()))
                     // 						{
                     // 							continue;
                     // 						}
                     // 						if (false === ($s = $u->getServer()))
                     // 						{
                     // 							continue;
                     // 						}
                     // 						$c = $s->getChannelByName('#shadowlamb');
                     // 						if ($sid === $s->getID())
                     // 						{
                     // 							if ( ($channel !== false) && ($channel->getUserByName($u->getName()) !== false) )
                     // 							{
                     // 								# TODO: fix this
                     // //								continue; # player already read it in irc.
                     // 							}
                     // 						}
                     # send to player.
                     echo "Sending to {$m->getName()}\n";
                     $m->msg($key, $args);
                     // 						$m->message($message);
                     // 						$sent++;
                 }
             }
         }
     }
     //		if ($sent > 0)
     //		{
     //			$player->message(sprintf('%s players on cross servers read your message inside the same location. Use #exit or privmsg/query/pm with the bot.'));
     //		}
 }
示例#10
0
文件: help_Pb.php 项目: sinfocol/gwf3
 function dogplug_help_all($entry, $fullpath, $cutlen)
 {
     global $DPH_ALL;
     $priv = $entry[0];
     $chan = Dog::getChannel();
     $serv = Dog::getServer();
     $user = Dog::getUser();
     $name = substr($entry, 0, -7);
     if (false !== ($plug = Dog_Plugin::getPlugWithPerms($serv, $chan, $user, $name)) && $plug->isEnabled($serv, $chan)) {
         $dir = substr($fullpath, $cutlen);
         $dir = substr($dir, 0, strrpos($dir, '/'));
         if (!isset($DPH_ALL[$dir])) {
             $DPH_ALL[$dir] = array();
         }
         if (!array_search($name, $DPH_ALL[$dir], true)) {
             $DPH_ALL[$dir][] = $name;
         }
     }
 }
示例#11
0
 /**
  *
  * @param string $user the username
  * @param string|char $message the guess
  * @return the answer
  */
 public function onGuess($user, $message)
 {
     $message = trim($message);
     if ($this->finish) {
         if ($message === 'false') {
             $this->CONFIG['solution_allowed_everytime'] = false;
         }
         $iso = Common::substrFrom($message, ' ', Dog::getChannel()->getLangISO());
         $this->onStartGame($iso);
     } elseif ($message === '') {
         $this->sendOutput('The game has already started');
     } else {
         if (GWF_String::strlen($message) !== 1) {
             $this->trySolution($user, $message);
         } else {
             $this->tryChar($user, $message);
         }
         if (GWF_String::toLower($this->grid) === GWF_String::tolower($this->solution)) {
             $this->winGame($nick);
         }
     }
     return $this->clearOutput();
 }
示例#12
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Figure out who is to blame.', 'blame' => 'I blame %s.'));
$plugin = Dog::getPlugin();
# tehron'ed version
$goats = array_map(array('Dog', 'softhyphe'), array("spaceone", "spaceone", "spaceone"));
shuffle($goats);
$rand_keys = array_rand($goats, count($goats));
shuffle($goats);
if (false !== ($channel = Dog::getChannel()) && !strcasecmp($channel->getName(), '#revolutionelite')) {
    $scapegoat = 'sabretooth';
} else {
    $scapegoat = $goats[$rand_keys[rand(0, count($goats) - 1)]];
}
$plugin->rply('blame', array($scapegoat));
示例#13
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<triggers>]. Show or set the triggers configured for this channel/server. Needs admin/ircop to set it. Use %CMD% default to switch back to defaults.', 'chan' => 'This channel overrides triggers to %s.', 'chan_by_serv' => 'This channel uses the triggers from the server: %s.', 'chan_by_bot' => 'This channel uses the bot triggers: %s.', 'serv' => 'This server overrides triggers to %s.', 'serv_by_bot' => 'This server uses the bot triggers: %s.', 'chan_to_default' => 'This channel now uses the server or %BOT% triggers.', 'chan_to' => 'This channel now overrides triggers to %s.', 'serv_to_default' => 'This server now uses the %BOT% triggers.', 'serv_to' => 'This server now defaults triggers to %s.'));
$plugin = Dog::getPlugin();
$user = Dog::getUser();
$serv = Dog::getServer();
$chan = Dog::getChannel();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    if ($chan !== false) {
        if (NULL !== ($t = $chan->getTriggers())) {
            $plugin->rply('chan', array($t));
        } elseif (NULL !== ($t = $serv->getTriggers())) {
            $plugin->rply('chan_by_serv', array($t));
        } else {
            $plugin->rply('chan_by_bot', array(Dog_Init::getTriggers()));
        }
    } else {
        if (NULL !== ($t = $serv->getTriggers())) {
            $plugin->rply('serv', array($t));
        } else {
            $plugin->rply('serv_by_bot', array(Dog_Init::getTriggers()));
        }
    }
} elseif ($argc === 1) {
    if ($chan !== false) {
        if ($argv[0] === 'default') {
            $chan->saveVar('chan_triggers', NULL);
            $plugin->rply('chan_to_default');
        } else {
示例#14
0
 public function event_privmsg()
 {
     $message = $this->msg();
     # Triggered in channel?
     if (false !== ($channel = Dog::getChannel())) {
         if (strpos($this->getConfig('triggers', 'c'), $message[0]) !== false) {
             Shadowrun4::onTrigger(Dog::getUser(), substr($message, 1));
         }
     } elseif (strpos($this->getConfig('servtrig', 's'), $message[0]) !== false) {
         Shadowrun4::onTrigger(Dog::getUser(), substr($message, 1));
     }
 }
示例#15
0
文件: part_Ab.php 项目: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<channel>[!<SID>]]. Command %BOT% to leave a channel. IRCOps can utilize this across networks.', 'not_there' => 'The channel you are trying to leave ist not occupied by %BOT% at all.', 'parting' => 'I am leaving %s now, and won´t come back on my own.'), 'de' => array('help' => 'Nutze: %CMD% [<Kanal>[!<SID>]]. Befehle %BOT% einen Kanal zu verlassen. IRCOps können dies Netzwerkübergreifend erledigen.', 'not_there' => 'Der Kanal den Du verlassen möchtest wird ist %BOT% zur Zeit unbekannt.', 'parting' => 'Ich verlasse nun %s und komme auch nicht von selbst wieder.'));
$plugin = Dog::getPlugin();
$serv = Dog::getServer();
$user = Dog::getUser();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    if (false === ($channel = Dog::getChannel())) {
        return $plugin->showHelp();
    }
} elseif ($argc === 1) {
    if (false === ($channel = Dog::getOrLoadChannelByArg($argv[0]))) {
        return Dog::rply('err_channel');
    }
    if ($channel->getSID() !== $serv->getID()) {
        if (!Dog::hasPermission($serv, false, $user, 'i')) {
            return Dog::noPermission('i');
        }
    }
} else {
    return $plugin->showHelp();
}
# Do it!
$channel->saveOption(Dog_Channel::AUTO_JOIN, false);
$plugin->rply('parting', array($channel->displayLongName()));
$serv->partChannel($channel);
示例#16
0
 public static function map($method_name, $args = NULL)
 {
     $server = Dog::getServer();
     $channel = Dog::getChannel();
     foreach (self::$MODULES as $module) {
         $module instanceof Dog_Module;
         if (method_exists($module, $method_name)) {
             if ($module->isEnabled($server, $channel)) {
                 call_user_func(array($module, $method_name), $args);
             }
         }
     }
 }
示例#17
0
文件: log_Ib.php 项目: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<on|off|default>]. Set or show logging for a channel.', 'serv_on' => 'This server has set it´s logging to explicit enabled.', 'serv_off' => 'This server has set it´s logging to explicit disabled.', 'serv_default' => 'This server has set it´s logging to %BOT% settings.', 'chan_on' => 'This channel has set it´s logging to explicit enabled.', 'chan_off' => 'This channel has set it´s logging to explicit disabled.', 'chan_default' => 'This channel has set it´s logging to %BOT% settings.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc > 1 || $argc === 1 && !in_array($argv[0], array('on', 'off', 'default'))) {
    return $plugin->showHelp();
}
$serv = Dog::getServer();
if (false !== ($chan = Dog::getChannel())) {
    if ($argc === 0) {
        if ($chan->isOptionEnabled(Dog_Channel::LOGGING_ON)) {
            $plugin->rply('chan_on');
        } elseif ($chan->isOptionEnabled(Dog_Channel::LOGGING_OFF)) {
            $plugin->rply('chan_off');
        } else {
            $plugin->rply('chan_default');
        }
    } else {
        $chan->saveOption(Dog_Channel::LOGBITS, false);
        if ($argv[0] === 'on') {
            $chan->saveOption(Dog_Channel::LOGGING_ON, true);
        } elseif ($argv[0] === 'off') {
            $chan->saveOption(Dog_Channel::LOGGING_OFF, true);
        }
    }
} else {
    if ($argc === 1) {
        $serv->saveOption(Dog_Server::LOGBITS, false);
        if ($argv[0] === 'on') {
示例#18
0
 public function on_greet_again_Fc()
 {
     $channel = Dog::getChannel();
     $dropped = Dog_Greeting::dropChannel($channel->getID());
     $this->rply('again', array($dropped, $channel->displayLongName()));
 }
示例#19
0
 public function configSetAbbos($s)
 {
     return Dog_Conf_Mod_Chan::setConf($this->getName(), Dog::getChannel()->getID(), 'boards', $s);
 }
示例#20
0
文件: Dog_Var.php 项目: sinfocol/gwf3
 public static function setVar(array $vars, $scope = NULL, $varname, $value)
 {
     if (false === ($var = self::getVar($vars, $varname, $scope))) {
         Dog::rply('err_unk_var');
     } elseif (!self::isValid($var->getType(), $value)) {
         Dog::rply('err_variabl', array($var->displayName(), $varname, $var->displayType()));
     } elseif (!$var->hasPermission(Dog::getServer(), Dog::getChannel(), Dog::getUser())) {
         Dog::noPermission($var->getPriv());
     } elseif (false === ($oldval = $var->getValue())) {
         Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
     } elseif (!$var->setValue($value)) {
         Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
     } else {
         Dog::rply('msg_set_var', array($var->displayName(), $varname, $oldval, $var->getValue()));
     }
 }
示例#21
0
 public static function isPersonalRecord(Dog_User $user, $dur, $startdate, $enddate)
 {
     if (false === ($record = self::getUserRecord($user)) || $record->getVar('dqj_duration') > $dur) {
         if (false === self::table(__CLASS__)->insertAssoc(array('dqj_uid' => $user->getID(), 'dqj_cid' => Dog::getChannel()->getID(), 'dqj_duration' => $dur, 'dqj_date_quit' => $enddate, 'dqj_date_join' => $startdate), true)) {
             return false;
         }
         return true;
     }
     return $dur < $record->getVar('dqj_duration');
 }
示例#22
0
 private function scumInit(Dog_User $user)
 {
     if (false === ($slot = $this->getGameSlot())) {
         return $this->errorSlot();
     }
     if (!isset($this->games[$slot])) {
         $this->games[$slot] = new Dog_ScumGame(Dog::getChannel());
     }
     $game = $this->games[$slot];
     $game instanceof Dog_ScumGame;
     if ($game->isInited()) {
         return $this->errorInited();
     }
     if ($game->isRunning()) {
         return $this->errorRunning();
     }
     $game->init();
     $game->join($user);
     return $this->lang('msg_inited', array($this->getMaxPlayers() - 1, Dog::getTrigger()));
 }
示例#23
0
 public function getConfChan($key, $def)
 {
     return Dog_Conf_Plug_Chan::getConf($this->name, Dog::getChannel()->getID(), $key, $def);
 }
示例#24
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));
 }
示例#25
0
 public function on_repo_subscribe_Pb()
 {
     if ($this->argc() !== 1) {
         return $this->showHelp('repo_subscribe');
     }
     if (false === ($repo = $this->getRepoForRead())) {
         return;
     }
     if (!($chan = Dog::getChannel())) {
         if (!($ru = Dog_RepoUsers::getOrCreateForRepoAndUser($repo, Dog::getUser()))) {
             return Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         if ($ru->isSubscribed()) {
             return $this->error('err_already_subscribed');
         }
         $ru->subscribe();
         return $this->rply('msg_subscribed_private');
     } else {
         if (Dog_RepoSubscribes::isSubscribed($repo, $chan)) {
             return $this->error('err_already_subscribed');
         }
         if (!Dog_RepoSubscribes::subscribe($repo, $chan)) {
             return Dog::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         return $this->rply('msg_subscribed_channel');
     }
 }
示例#26
0
 private function logOutput($to, $message)
 {
     if ($this->isLogging()) {
         if (false !== ($channel = Dog::getChannel())) {
             Dog_Log::channel($channel, $message);
         }
         if (false !== ($user = $this->getUserByName($to))) {
             Dog_Log::user($user, $message);
         }
     }
 }