public static function getPlugins($name) { self::$PLUGIN = array(); GWF_File::filewalker(self::getPlugDir(), array(__CLASS__, 'getPlugRec'), false, true, $name); if (GWF3::getConfig('env') === 'dev') { GWF_File::filewalker(self::getPlugDirDev(), array(__CLASS__, 'getPlugRec'), false, true, $name); } GWF_File::filewalker(self::getPlugDirUser(), array(__CLASS__, 'getPlugRec'), false, true, $name); GWF_File::filewalker(self::getPlugDirSecret(), array(__CLASS__, 'getPlugRec'), false, true, $name); usort(self::$PLUGIN, array(__CLASS__, 'sort_power_descending')); return self::$PLUGIN; }
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; }
$serv = Dog::getServer(); $plugin = Dog::getPlugin(); $argv = $plugin->argv(); $argc = count($argv); if ($argc === 1) { $name = $argv[0]; if (false !== ($plug = Dog_Plugin::getPlugWithPerms($serv, $chan, $user, $name))) { $plug->showConfigVarNames('u'); } if (false !== ($mod = Dog_Module::getModuleWithPermsByTrigger($serv, $chan, $user, $name)) || false !== ($mod = Dog_Module::getByName($name))) { $mod->showConfigVarNames('u'); } } elseif ($argc === 2) { $name = $argv[0]; if (false !== ($plug = Dog_Plugin::getPlugWithPerms($serv, $chan, $user, $name))) { $plug->showConfigVar('u', $argv[1]); } if (false !== ($mod = Dog_Module::getModuleWithPermsByTrigger($serv, $chan, $user, $name)) || false !== ($mod = Dog_Module::getByName($name))) { $mod->showConfigVar('u', $argv[1]); } } elseif ($argc === 3) { $name = $argv[0]; if (false !== ($plug = Dog_Plugin::getPlugWithPerms($serv, $chan, $user, $name))) { $plug->setConfigVar('u', $argv[1], $argv[2]); } if (false !== ($mod = Dog_Module::getModuleWithPermsByTrigger($serv, $chan, $user, $name)) || false !== ($mod = Dog_Module::getByName($name))) { $mod->setConfigVar('u', $argv[1], $argv[2]); } } else { $plugin->showHelp(); }
# Log PRIVMSGs $msg = Dog::getIRCMsg()->getArg(1); if (Dog::getIRCMsg()->shouldLog()) { Dog_Log::user($user, $msg); Dog_Log::channel($chan, $msg); } # Exec Stuff if (!$user->isBot()) { if ('' !== ($trigger = Common::substrUntil($msg, ' '))) { if (Dog_Init::isTrigger($serv, $chan, $trigger[0])) { if ($user->isFlooding()) { return; } Dog::setTriggered(); $trigger = substr($trigger, 1); if (false !== ($plug = Dog_Plugin::getPlug($trigger))) { if (!$plug->isInScope($serv, $chan)) { Dog::scopeError($plug->getScope()); } elseif (!$plug->hasPermission($serv, $chan, $user)) { Dog::permissionError($plug->getPriv()); } elseif (!$plug->isEnabled($serv, $chan)) { Dog::rply('err_disabled'); } else { $plug->execute(); } } elseif (false !== ($mod = Dog_Module::getByTrigger($trigger))) { if (!$mod->hasScopeFor($trigger, $serv, $chan)) { Dog::scopeError($mod->getScope($trigger)); } if (!$mod->hasPermissionFor($trigger, $serv, $chan, $user)) { Dog::permissionError($mod->getPriv($trigger));
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)); }
if (!Dog::hasPermission($serv, false, $user, 'a')) { Dog::noPermission('a'); } elseif (false !== ($plug = Dog_Plugin::getPlug($name))) { Dog_Conf_Plug_Serv::setDisabled($plug->getName(), $sid, '1'); $plugin->rply('plg_on_serv', array($name, $serv->displayName())); } elseif (false !== ($mod = Dog_Module::getByName($name))) { Dog_Conf_Mod_Serv::setModuleDisabled($mod->getName(), $sid, '1'); $plugin->rply('mod_on_serv', array($mod->displayName(), $serv->displayName())); } elseif (false !== ($mod = Dog_Module::getByTrigger($name))) { Dog_Conf_Mod_Serv::setTriggerDisabled($mod->getName(), $sid, $name, '1'); $plugin->rply('trg_on_serv', array($name, $mod->displayName(), $serv->displayName())); } else { Dog::rply('err_command'); } } else { $cid = $chan->getID(); if (!Dog::hasPermission($serv, $chan, $user, 's')) { return Dog::noPermission('s'); } elseif (false !== ($plug = Dog_Plugin::getPlug($name))) { Dog_Conf_Plug_Chan::setDisabled($plug->getName(), $cid, '1'); $plugin->rply('plg_on_chan', array($name, $chan->displayLongName())); } elseif (false !== ($mod = Dog_Module::getByName($name))) { Dog_Conf_Mod_Chan::setModuleDisabled($mod->getName(), $cid, '1'); $plugin->rply('mod_on_chan', array($mod->displayName(), $chan->displayLongName())); } elseif (false !== ($mod = Dog_Module::getByTrigger($name))) { Dog_Conf_Mod_Chan::setTriggerDisabled($mod->getName(), $cid, $name, '1'); $plugin->rply('trg_on_chan', array($name, $mod->displayName(), $chan->displayLongName())); } else { Dog::rply('err_command'); } }
/** * @return Dog_Plugin */ public static function getPlugin() { return Dog_Plugin::getPlugin(); }