public function getConfUser($key, $def) { return Dog_Conf_Plug_User::getConf($this->name, Dog::getUser()->getID(), $key, $def); }
public function getValue() { $key = $this->name; $def = $this->default; $sid = Dog::getServer()->getID(); $c = Dog::getChannel(); if ($this->module !== NULL) { $mod = $this->module; switch ($this->scope) { case 'g': return Dog_Conf_Mod::getConf($mod, $key, $def); case 's': return Dog_Conf_Mod_Serv::getConf($mod, $sid, $key, $def); case 'c': return $c === false ? $def : Dog_Conf_Mod_Chan::getConf($mod, $c->getID(), $key, $def); case 'u': return Dog_Conf_Mod_User::getConf($mod, Dog::getUID(), $key, $def); } } elseif ($this->plugin !== NULL) { $plg = $this->plugin; switch ($this->scope) { case 'g': return Dog_Conf_Plug::getConf($plg, $key, $def); case 's': return Dog_Conf_Plug_Serv::getConf($plg, $sid, $key, $def); case 'c': return $c === false ? $def : Dog_Conf_Plug_Chan::getConf($plg, $c->getID(), $key, $def); case 'u': return Dog_Conf_Plug_User::getConf($plg, Dog::getUID(), $key, $def); } } return $def; }
<?php $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);
<?php $lang = array('en' => array('help' => 'Usage: %CMD% <option1>[ or <optionN> ... ]. Let %BOT% choose from a set of options for you.', 'just' => 'I just told you!', 'y' => 'Yes!', 'n' => 'No.')); $plugin = Dog::getPlugin(); $plg = $plugin->getName(); # Last input if (NULL !== ($last = Dog_Conf_Plug_User::getConf($plg, Dog::getUID(), 'last', NULL))) { $last = unserialize($last); } else { $last = array(); } # 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) {