예제 #1
0
 public function on_note_Pb()
 {
     $server = Dog::getServer();
     $user = Dog::getUser();
     $message = $this->msgarg();
     $command = Common::substrUntil($message, ' ', $message);
     $message = Common::substrFrom($message, ' ', '');
     switch ($command) {
         case 'send':
             $out = $this->onSend($server, $user, $message);
             break;
         case 'read':
             $out = $this->onRead($server, $user, $message);
             break;
         case 'delete':
             $out = $this->onDelete($server, $user, $message);
             break;
         case 'search':
             $out = $this->onSearch($server, $user, $message);
             break;
         default:
         case 'help':
             $this->onHelp();
             return;
     }
     $this->reply($out);
 }
예제 #2
0
 public function on_autojoin_Ac()
 {
     $user = Dog::getUser();
     $server = Dog::getServer();
     $argv = $this->argv();
     $argc = count($argv);
     # Invoked in channel.
     switch ($argc) {
         # .autojoin
         case 0:
             return $this->showStatus($channel);
             # .autojoin on|#channel
         # .autojoin on|#channel
         case 1:
             if (Dog_Var::isValid('b', $argv[0])) {
                 return $this->setEnabled($channel, Dog_Var::parseValue('b', $argv[0]));
             } elseif (false === ($channel = Dog::getOrLoadChannelByArg($argv[0]))) {
                 return Dog::rply('err_channel');
             } else {
                 return $this->showStatus($channel);
             }
             # .autojoin #wechall on
         # .autojoin #wechall on
         case 2:
             if (false === ($channel = Dog::getOrLoadChannelByArg($argv[0]))) {
                 return Dog::rply('err_channel');
             }
             if (!Dog::hasPermission($server, $channel, $user, 'A')) {
                 return Dog::noPermission('s');
             }
             return $this->setEnabled($channel, Dog_Var::parseValue('b', $argv[1]));
     }
     $this->showHelp('autojoin');
 }
예제 #3
0
 public function event_join()
 {
     $user = Dog::getUser();
     $server = Dog::getServer();
     $channel = Dog::getChannel();
     $cid = $channel->getID();
     if (Dog::isItself() || Dog_Greeting::hasBeenGreeted($user->getID(), $cid) || false === ($greeting = Dog_GreetMsg::getGreetMsg($server, $channel)) || $greeting->isDisabled()) {
         return;
     }
     $message = $greeting->getVar('dgm_msg');
     switch ($greeting->getGreetMode()) {
         case Dog_GreetMsg::MODE_CHAN:
             $server->sendPRIVMSG($channel->getName(), $user->getName() . ': ' . $message);
             break;
         case Dog_GreetMsg::MODE_NOTICE:
             $server->sendNOTICE($user->getName(), $message);
             break;
         case Dog_GreetMsg::MODE_PRIVMSG:
             $server->sendPRIVMSG($user->getName(), $message);
             break;
         default:
             Dog_Log::error('Invalid type of greeting in ' . __FILE__ . ' line ' . __LINE__ . '!');
             return;
     }
     Dog_Greeting::markGreeted($user->getID(), $cid);
 }
예제 #4
0
 private static function getAutoTargetISO()
 {
     if (false !== ($channel = Dog::getChannel())) {
         return $channel->getLangISO();
     } else {
         return Dog::getUser()->getLangISO();
     }
 }
예제 #5
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());
         }
     }
 }
예제 #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
 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));
 }
예제 #8
0
 public function event_privmsg()
 {
     if (!Dog::isTriggered() && $this->collectorEnabled()) {
         $user = Dog::getUser();
         if (preg_match_all('#(https?://[^\\ ]+)#D', $this->msg(), $matches)) {
             array_shift($matches);
             foreach ($matches as $match) {
                 $this->onAdd($user, $match[0]);
             }
         }
     }
 }
예제 #9
0
 public function on_scum_Pc()
 {
     if (false === ($chanel = Dog::getChannel())) {
         return Dog::rply('err_only_channel');
     }
     $user = Dog::getUser();
     $msg = $this->msgarg();
     $command = Common::substrUntil($msg, ' ', $msg);
     $message = Common::substrFrom($msg, ' ', '');
     switch ($command) {
         case '':
         case 'help':
             $out = $this->scumHelp($message);
             break;
         case 'init':
             $out = $this->scumInit($user);
             break;
         case 'join':
             $out = $this->scumJoin($user);
             break;
         case 'start':
             $out = $this->scumStart($user);
             break;
         case 'cards':
             $out = $this->scumCards($user);
             break;
         case 'turn':
         case 'deck':
             $out = $this->scumDeck($user);
             break;
         case 'top5':
             $out = $this->scumTop5($user, $message);
             break;
         case 'stats':
             $out = $this->scumStats($user, $message);
             break;
         case 'abort':
             $out = $this->scumAbort($user);
             break;
         case 'pass':
             $out = $this->scumPass($user);
             break;
         default:
             $out = $this->scumPlay($user, $msg, false);
             break;
     }
     return Dog::reply($out);
 }
예제 #10
0
 public function event_notice()
 {
     if (false !== ($user = Dog::getUser())) {
         if (!strcasecmp($user->getName(), 'NickServ')) {
             if (preg_match('/^STATUS ([^ ]+) ([0-9])$/Di', $this->msgarg(), $matches)) {
                 $server = Dog::getServer();
                 $nickname = $matches[1];
                 $status = (int) $matches[2];
                 if (!$this->probingNickservStatus($server, $nickname, $status) && $status === 3) {
                     if (false !== ($user = $server->getUserByName($nickname))) {
                         $this->onAutoLogin($user);
                     }
                 }
             }
         }
     }
 }
예제 #11
0
 public function getItemDescription()
 {
     if (false === ($user = Dog::getUser())) {
         $username = '';
     } else {
         $username = $user->getName();
     }
     $partner = 'Your PC';
     switch ($username) {
         case 'ynori7':
             $partner = 'CPUkiller';
             break;
         case 'CPUkiller':
             $partner = 'ynori7';
             break;
     }
     return 'Your wedding ring. You are currently married to ' . $partner . '.';
 }
예제 #12
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;
         }
     }
 }
예제 #13
0
    $prot = $server->isSSL() ? 'ircs' : 'irc';
    $port = $server->getPort();
} else {
    $url = parse_url($argv[0]);
    if (!isset($url['host'])) {
        return $plugin->rply('err_url');
    }
    $host = $url['host'];
    $prot = isset($url['scheme']) ? strtolower($url['scheme']) : 'irc';
    if ($prot !== 'irc' && $prot !== 'ircs') {
        return $plugin->rply('err_url');
    }
    $default_port = $prot === 'ircs' ? 6697 : 6667;
    $port = isset($url['port']) ? intval($url['port']) : $default_port;
    $options = Dog_Server::DEFAULT_OPTIONS;
    $options |= $prot === 'ircs' ? Dog_Server::SSL : 0;
}
if (false !== ($server = Dog::getServerByArg($argv[0])) || false !== ($server = Dog::getServerByArg($host))) {
    $plugin->reply('reconnecting');
    $server->saveOption(Dog_Server::ACTIVE, true);
    $server->saveOption(Dog_Server::SSL, $prot === 'ircs');
    $server->saveVar('serv_port', $port);
} else {
    $plugin->reply('adding_server');
    $server = Dog_Server::getOrCreate($host, $port, $options);
    $server->setVar('dog_connector', Dog::getUser());
    $server->setConf('ircoppass', GWF_Random::randomKey(8));
    Dog::addServer($server);
}
$server->setConnectIn(0.5);
$plugin->rply('connect');
예제 #14
0
파일: bed_Pc.php 프로젝트: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'You can use this function to goto bed. It works!', 'm1' => 'nighty night %s!', 'm2' => 'good night %s.'));
$plugin = Dog::getPlugin();
$channel = Dog::getChannel();
$plugin->reply($plugin->lang('m' . rand(1, 2), array(Dog::getUser()->displayName())));
예제 #15
0
 public function on_slaptop5_Pb()
 {
     $this->reply($this->onTop5(Dog::getUser(), $this->msgarg()));
 }
예제 #16
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <evil plan here>. Gain world domination with your evil plan. TODO: implement.', 'm0' => 'This is not bizarroworld.', 'm1' => 'Your evil plan failed.', 'm2' => 'Syntax error in eval(\'$evil_plan\'). Luckily, the bot did not quit.', 'm3' => 'Evil plan is running. You did not specify a main contact email tho.', 'm4' => 'Evil plan is running.', 'm5' => 'Database error. If you are %s you might have exhausted the evil plan slots.'));
$plugin = Dog::getPlugin();
if ($plugin->msg() === '') {
    return $plugin->showHelp();
}
$n = rand(0, 5);
switch ($n) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
        return $plugin->rply('m' . $n);
    case 5:
        return $plugin->rply('m5', array(Dog::getUser()->displayName()));
}
예제 #17
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()));
     }
 }
예제 #18
0
 public function on_ADDquote_Pc()
 {
     Dog::reply($this->onAdd(Dog::getUser()->getName(), $this->msgarg()));
 }
예제 #19
0
파일: reboot_Yb.php 프로젝트: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<message here...>]. Initiate a reboot and quit with a message.', 'default' => '%s is rebooting me :O'));
// GWF_HTTP::getFromURL("")
return Dog::reply('YOU FOUND A TODO!');
$plugin = Dog::getPlugin();
$message = $plugin->argc() === 0 ? $plugin->lang('default', array(Dog::getUser()->displayName())) : $plugin->msg();
foreach (Dog::getServers() as $server) {
    $server instanceof Dog_Server;
    $server->disconnect($message);
}
Dog_Launcher::kill();
예제 #20
0
파일: lang_Pb.php 프로젝트: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<iso>]. Set or show your language.', 'set' => 'Your language on %s has been set from %s to %s.', 'show' => 'Your language on %s is set to %s.'));
# Special language codes
$special = array('bot' => 'Bot', 'ibd' => 'IBDES');
$user = Dog::getUser();
$server = Dog::getServer();
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    $plugin->rply('show', array($server->displayName(), $user->displayLang()));
} elseif ($argc === 1) {
    if (!Dog_Init::isValidISO($argv[0])) {
        return Dog::rply('err_lang_iso');
    } else {
        $old = isset($special[$user->getLangISO()]) ? $special[$user->getLangISO()] : $user->displayLang();
        Dog::getUser()->saveVar('user_lang', $argv[0]);
        $dlang = isset($special[$argv[0]]) ? $special[$argv[0]] : $user->displayLang();
        $plugin->rply('set', array($server->displayName(), $old, $dlang));
    }
} else {
    $plugin->showHelp();
}
예제 #21
0
파일: vodka_Pb.php 프로젝트: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Drink some vodka with %BOT%!', 'young' => 'You are too young for vodka, have no age specified, or your brain would suffer too much!', 'FreeArtMan' => 'Ah ... at least. I am not kid!', 'paipai' => 'Chin Chin!', 'poulse' => 'Cheers and congrats!', 'Oz' => 'Nastrovje!', 'sabretooth' => 'One vodka, Mr. Bond. Shaken, not stirred.', 'dalfor' => 'vodka? what am I russian?', 'MkZ^' => 'You can pop more vodka than i thought!'));
$plugin = Dog::getPlugin();
$uname = Dog::getUser()->getName();
if ($plugin->hasKey($uname)) {
    $plugin->rply($uname);
} else {
    $plugin->rply('young');
}
예제 #22
0
 public function getConfUser($key, $def)
 {
     return Dog_Conf_Plug_User::getConf($this->name, Dog::getUser()->getID(), $key, $def);
 }
예제 #23
0
파일: wc_Pb.php 프로젝트: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Query wechall for user or site info. Usage: %CMD% [<username|rank>] || %CMD% !site <sitename> || %CMD% !sites [<username>] || %CMD% !<sitename> [<username|rank>].'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
switch ($argc) {
    case 0:
        $argv[0] = Dog::getUser()->getName();
        break;
    case 1:
        if ($argv[0][0] === '!') {
            $argv[1] = Dog::getUser()->getName();
        }
        break;
    case 2:
        break;
    default:
        return $plugin->showHelp();
}
$url = 'http://www.wechall.net/wechall.php?username='******' ', $argv));
if (false === ($result = GWF_HTTP::getFromURL($url, false))) {
    return Dog::rply('err_repsonse');
}
Dog::reply($result);
예제 #24
0
 public function reply($message)
 {
     if ('' !== ($message = trim($message))) {
         if (false !== ($user = Dog::getUser())) {
             $username = Dog::getUser()->getName();
             if (false !== ($channel = Dog::getChannel())) {
                 $this->sendPRIVMSG($channel->getName(), $username . ': ' . $message);
             } else {
                 $this->sendPRIVMSG($username, $message);
             }
         }
     }
 }
예제 #25
0
파일: coffee_Pb.php 프로젝트: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Codemonkey gets up gets coffee.', 'coff' => 'hands %s a cup of hot coffee.'));
$plugin = Dog::getPlugin();
if ($plugin->argc() !== 0) {
    $plugin->showHelp();
} else {
    $plugin->rplyAction('coff', array(Dog::getUser()->getName()));
}
예제 #26
0
파일: bot_Xb.php 프로젝트: sinfocol/gwf3
if ($argc < 1 || $argc > 2) {
    return $plugin->showHelp();
}
if (false === ($user = Dog::getOrLoadUserByArg($argv[0]))) {
    return Dog::rply('err_user');
}
if ($argc === 1) {
    if ($user->isOptionEnabled(Dog_User::BOT)) {
        $plugin->rply('bot_on');
    } else {
        $plugin->rply('bot_off');
    }
} else {
    $argv[1] = strtolower($argv[1]);
    if ($argv[1] === 'on') {
        $isx = Dog_PrivServer::hasPermChar($user->getServer(), $user, 'x');
        // he Owner
        $isy = Dog_PrivServer::hasPermChar($user->getServer(), $user, 'y');
        // he Hoster
        $isuy = Dog_PrivServer::hasPermChar($user->getServer(), Dog::getUser(), 'y');
        // Caller Hoster
        if ($isy || $isx && !$isuy) {
            return $plugin->rply('err_owner', $user->getName());
        }
        $user->setOption(Dog_User::BOT, true);
        $plugin->rply('bot_on');
    } elseif ($argv[1] === 'off') {
        $user->setOption(Dog_User::BOT, false);
        $plugin->rply('bot_off');
    }
}
예제 #27
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 {
예제 #28
0
파일: mods_Pb.php 프로젝트: sinfocol/gwf3
        $plugin->rply('not_regged', array($user->displayName()));
    } elseif ($sign === '+' && strlen($argv[1]) >= 1) {
        $u = Dog::getUser();
        $have = Dog_PrivServer::getPermbits($serv, $u);
        $want = Dog_IRCPriv::charsToBits(substr($argv[1], 1));
        $high = Dog_IRCPriv::getHighestBit($have);
        $wigh = Dog_IRCPriv::getHighestBit($want);
        if ($wigh > $high) {
            $plugin->rply('no', array(Dog_IRCPriv::displayBits($wigh, ''), $user->displayName()));
        } else {
            $now = Dog_PrivServer::getPermbits($serv, $user) | $want;
            Dog_PrivServer::setPermbits($serv, $user, $now);
            $plugin->rply('set', array($user->displayName(), $serv->displayName(), Dog_IRCPriv::displayBits($now)));
        }
    } elseif ($sign === '-' && strlen($argv[1]) >= 1) {
        $u = Dog::getUser();
        $have = Dog_PrivServer::getPermbits($serv, $u);
        $want = Dog_IRCPriv::charsToBits(substr($argv[1], 1));
        $high = Dog_IRCPriv::getHighestBit($have);
        $wigh = Dog_IRCPriv::getHighestBit($want);
        if ($wigh >= $high) {
            $plugin->rply('no2', array(Dog_IRCPriv::displayBits($wigh, ''), $user->displayName()));
        } else {
            $now = Dog_PrivServer::getPermbits($serv, $user) & ~$want;
            Dog_PrivServer::setPermbits($serv, $user, $now);
            $plugin->rply('set', array($user->displayName(), $serv->displayName(), Dog_IRCPriv::displayBits($now)));
        }
    } else {
        $plugin->rply('err_bits');
    }
} else {
예제 #29
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');
     }
 }
예제 #30
0
파일: gin_Pb.php 프로젝트: sinfocol/gwf3
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Drink some gin with %BOT% and dalfor!', 'young' => 'You are too young for gin, have no age specified, or your brain would suffer too much!'));
$plugin = Dog::getPlugin();
switch (Dog::getUser()->getName()) {
    default:
        $plugin->rply('young');
}