Exemple #1
0
 public function setValue($value)
 {
     $key = $this->name;
     $sid = Dog::getServer()->getID();
     $uid = Dog::getUser()->getID();
     $c = Dog::getChannel();
     if ($this->module !== NULL) {
         $mod = $this->module;
         switch ($this->scope) {
             case 'g':
                 return Dog_Conf_Mod::setConf($mod, $key, $value);
             case 's':
                 return Dog_Conf_Mod_Serv::setConf($mod, $sid, $key, $value);
             case 'c':
                 if ($c !== false) {
                     return Dog_Conf_Mod_Chan::setConf($mod, $c->getID(), $key, $value);
                 }
                 return false;
             case 'u':
                 return Dog_Conf_Mod_User::setConf($mod, $uid, $key, $value);
         }
     } elseif ($this->plugin !== NULL) {
         $plg = $this->plugin;
         switch ($this->scope) {
             case 'g':
                 return Dog_Conf_Plug::setConf($plg, $key, $value);
             case 's':
                 return Dog_Conf_Plug_Serv::setConf($plg, $sid, $key, $value);
             case 'c':
                 if ($c !== false) {
                     Dog_Conf_Plug_Chan::setConf($plg, $c->getID(), $key, $value);
                 }
                 return false;
             case 'u':
                 return Dog_Conf_Plug_User::setConf($plg, $uid, $key, $value);
         }
     }
     return false;
 }
Exemple #2
0
$lang = array('en' => array('help' => 'Usage: %CMD% <expression>. Evaluate a mathematical expression and print results. Use _ and $ to referr to the last result.', '00' => '1 ... No ... 0 ... No ... UNDEFINED!', 'err_in' => 'Error in expression.', 'err_lib' => 'The "EvalMath" class by Miles Kaufmann is missing.'));
$plugin = Dog::getPlugin();
if ('' === ($message = $plugin->msg())) {
    return $plugin->showHelp();
}
if (false !== ($last = Dog_Conf_Plug_User::getConf($plugin->getName(), Dog::getUID(), 'last', false))) {
    $message = str_replace(array('_', '$'), $last, $message);
}
if ($message === '0^0') {
    return $plugin->rply('00');
}
if ($message === 'pi') {
    return $plugin->reply('4');
}
$path = GWF_PATH . 'core/inc/3p/EvalMath.php';
if (!Common::isFile($path)) {
    return $plugin->rply('err_lib');
}
require_once $path;
$eval = new EvalMath();
if (false === ($result = $eval->e($message))) {
    return $plugin->rply('err_in');
}
$result = sprintf('%.09f', $result);
if (strpos($result, '.') !== false) {
    $result = rtrim($result, '0');
    $result = rtrim($result, '.');
}
Dog_Conf_Plug_User::setConf($plugin->getName(), Dog::getUID(), 'last', $result);
Dog::reply($result);
Exemple #3
0
# Split and clean data
$message = $plugin->msg();
$data = preg_split('/(?: or | oder |\\|\\||\\|)/', $message);
$data = array_map('trim', $data);
foreach ($data as $i => $s) {
    if ($s === '') {
        unset($data[$i]);
    }
}
$data = array_unique($data);
# Same data?
$diff = 1;
if (count($last) === count($data)) {
    $t = $last;
    sort($t);
    sort($data);
    $diff = count(array_diff($t, $data));
}
# Yes, same data
if ($diff === 0) {
    return $plugin->rply('just');
}
# New choose
Dog_Conf_Plug_User::setConf($plg, Dog::getUID(), 'last', serialize($last));
# Yes/No
if (count($data) === 1) {
    $key = rand(0, 1) ? 'y' : 'n';
    return $plugin->rply($key);
}
# Random
Dog::reply($data[rand(0, count($data) - 1)]);