Example #1
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');
 }
Example #2
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);
 }
Example #3
0
 /**
  * We got triggered by !seen.
  */
 public function on_seen_Pb()
 {
     $argv = $this->argv();
     $argc = count($argv);
     if ($argc === 1) {
         if (!preg_match('/^[a-z0-9_!]+$/iD', $argv[0])) {
             return Dog::rply('err_user');
         }
         if (false === ($server = Dog::getServerBySuffix($argv[0]))) {
             return Dog::rply('err_server');
         }
         if (false === ($user = Dog_User::getByLongName($argv[0]))) {
             return Dog::rply('err_user');
         }
         if (false === ($seen = Dog_Seen::getSeen($user))) {
             return $this->rply('never', array($user->displayName()));
         }
         $channel = $seen->getChannel();
         $channam = $channel === false ? '!NOCHAN!' : $channel->displayName();
         $this->rply($seen->getEvent(), array($user->displayName(), $server->displayName(), $channam, $seen->displayDate(), $seen->displayAge(), $seen->getMessage()));
     } else {
         $this->showHelp('seen');
     }
 }
Example #4
0
 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()));
     }
 }
Example #5
0
 public static function permissionError($privchar)
 {
     Dog::rply('err_no_perm', array($privchar, self::lang('priv_' . $privchar)));
 }
Example #6
0
 public function showConfigVarNames($scope)
 {
     Dog::rply('msg_plgvars', array($this->displayName(), Dog_Var::showVarNames($this->getConfigVars(), $scope)));
 }
Example #7
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Restart all timers.', 'ok' => 'Timers have been successfully flushed. %BOT% is sleeping for %d milliseconds each loop.'));
$millis = Dog_Init::getSleepMillis();
Dog_Timer::flush();
Dog_Timer::init(Dog_Init::getSleepMillis());
Dog_Init::initTimers();
Dog::rply('ok', array($millis));
Example #8
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD%. Show information of the current song played at http://slayradio.org - mplayer http://relay1.slayradio.org:8000', 'np' => 'Now Playing on http://slayradio.org %s - %s (requested by %s)', 'live' => "There is probably a live show on http://slayradio.org: %s.", 'ki' => 'SlayRadio AI'));
$plugin = Dog::getPlugin();
$ki = $plugin->lang('ki');
$url = 'http://slayradio.org/now_playing.php';
if (false === ($result = GWF_HTTP::getFromURL($url))) {
    return Dog::rply('err_response');
}
# <strong>Lagerfeldt</strong><br>R-Type (Doppelganger Summer Remix)<p align="center"><small>Requested by <b><i>zeddan</i></b> <br></small>
if (preg_match('#<strong>([^<]+)</strong><br>([^<]+)<p align="center"><small>Requested by <b><i>([^<]+)</i></b> <br></small>#', $result, $matches)) {
    $plugin->rply('np', array(utf8_encode(html_entity_decode($matches[1], ENT_QUOTES)), utf8_encode(html_entity_decode($matches[2], ENT_QUOTES)), utf8_encode(html_entity_decode($matches[3], ENT_QUOTES))));
} elseif (preg_match('#<strong>([^<]+)</strong><br>([^<]+)<p align="center">#', $result, $matches)) {
    $plugin->rply('np', array(utf8_encode(html_entity_decode($matches[1], ENT_QUOTES)), utf8_encode(html_entity_decode($matches[2], ENT_QUOTES)), $ki));
} elseif (preg_match('#<strong>([^<]+)</strong><br>([^<]+)<br>#', $result, $matches) && preg_match('#<small>Requested by <b><i>([^<]+)</i></b> <br></small>#', $result, $matches2)) {
    $plugin->rply('np', array(utf8_encode(html_entity_decode($matches[1], ENT_QUOTES)), utf8_encode(html_entity_decode($matches[2], ENT_QUOTES)), utf8_encode(html_entity_decode($matches2[1], ENT_QUOTES))));
} elseif (1 === preg_match('#<strong>([^<]+)</strong><br>([^<]+)<br>#', $result, $matches)) {
    $plugin->rply('np', array(utf8_encode(html_entity_decode($matches[1], ENT_QUOTES)), utf8_encode(html_entity_decode($matches[2], ENT_QUOTES)), $ki));
} elseif (true === false) {
} elseif (1 === preg_match('#<font size="\\+1">([^<]+)</font>#', $result, $matches)) {
    $plugin->rply('live', array($matches[1]));
    Dog::reply(sprintf('', $matches[1]));
} else {
    Dog::rply('err_response');
}
Example #9
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <user[!SID]>. Remove the password for a user.', 'removed' => 'The password for %s has been removed.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc !== 1) {
    $plugin->showHelp();
} elseif (false === ($user = Dog::getOrLoadUserByArg($argv[0]))) {
    Dog::rply('err_user');
} else {
    $user->saveVar('user_pass', NULL);
    $plugin->rply('removed', array($user->displayName()));
}
Example #10
0
$plugin = Dog::getPlugin();
$message = $plugin->argv();
if (count($message) < 2) {
    return $plugin->showHelp();
}
$arg = array_shift($message);
$message = implode(' ', $message);
# Admin
if (Dog::hasPermission($serv, false, $user, 'a')) {
    if (false !== ($channel = Dog::getChannelByArg($arg))) {
        return $channel->sendAction($message);
    } elseif (false !== ($tuser = Dog::getUserByArg($arg))) {
        return $tuser->sendAction($message);
    }
} elseif (DOG::hasPermission($serv, false, $user, 's')) {
    if (false !== ($channel = $serv->getChannelByName($arg))) {
        return $channel->sendAction($message);
    } elseif (false !== ($tuser = $serv->getUserByName($arg))) {
        return $tuser->sendAction($message);
    }
} else {
    if (false !== ($channel = $serv->getChannelByName($arg))) {
        return $channel->sendAction($message);
    }
}
# Errors
if (false !== ($channel = Dog::getChannelByArg($arg)) || false !== ($tuser = Dog::getUserByArg($arg))) {
    return Dog::noPermission('a');
} else {
    return Dog::rply('err_target');
}
Example #11
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [[<server>:]<channel>] [<nickname>]'));
return;
$plug = Dog::getPlugin();
$user = Dog::getUser();
$serv = Dog::getServer();
$chan = Dog::getChannel();
$argv = $plug->argv();
$argc = count($argv);
$showhelp = false;
if ($argc === 2) {
    $nickname = array_pop($argv);
    if (!Dog_IRCRFC::isValidNickname($nickname)) {
        return Dog::rply('err_nickname');
    }
    $argc--;
}
if ($argc === 1) {
    $servchan = $argv[0];
} else {
    $showhelp = true;
}
if ($showhelp) {
    return $plug->showHelp();
}
$url = "https://widget00.mibbit.com/?server={$server}%3A%2B6666&channel={$channel}&noServerNotices=true&noServerMotd=true&nick={$nickname}&forcePrompt=true";
Example #12
0
            $out .= implode(', ', $triggers);
            $out .= '.';
        }
    }
    $user = Dog::getUser();
    $user->sendNOTICE(substr($out, 1));
    # Plugins
    $out = '';
    $plugdir = Dog_Plugin::getPlugDir();
    GWF_File::filewalker($plugdir, 'dogplug_help_all', false, true, strlen($plugdir) + 1);
    ksort($DPH_ALL);
    foreach ($DPH_ALL as $folder => $commands) {
        sort($commands);
        $out .= ' ' . chr(2) . $folder . chr(2) . ': ';
        $out .= implode(', ', $commands);
        $out .= '.';
    }
    $user->sendNOTICE(substr($out, 1));
} elseif ($argc === 1) {
    if (false !== ($plug = Dog_Plugin::getPlug($argv[0]))) {
        $scopetxt = dogplug_scopetxt($plugin, $plug->getPriv(), $plug->getScope());
        $plugin->reply($plug->getHelp() . $scopetxt);
    } elseif (false !== ($mod = Dog_Module::getByTrigger($argv[0]))) {
        $scopetxt = dogplug_scopetxt($plugin, $mod->getPriv($argv[0]), $mod->getScope($argv[0]));
        $plugin->reply($mod->getHelp($argv[0]) . $scopetxt);
    } else {
        Dog::rply('err_command');
    }
} else {
    $plugin->showHelp();
}
Example #13
0
<?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);
Example #14
0
$argc = count($argv);
if ($argc === 1) {
    $name = $argv[0];
    if (false !== ($plug = Dog_Plugin::getPlugWithPerms($serv, $chan, $user, $name))) {
        $plug->showConfigVarNames('g');
    } elseif (false !== ($mod = Dog_Module::getModuleWithPermsByTrigger($serv, $chan, $user, $name)) || false !== ($mod = Dog_Module::getByName($name))) {
        $mod->showConfigVarNames('g');
    } else {
        Dog::rply('err_command');
    }
} elseif ($argc === 2) {
    $name = $argv[0];
    if (false !== ($plug = Dog_Plugin::getPlugWithPerms($serv, $chan, $user, $name))) {
        $plug->showConfigVar('g', $argv[1]);
    } elseif (false !== ($mod = Dog_Module::getModuleWithPermsByTrigger($serv, $chan, $user, $name)) || false !== ($mod = Dog_Module::getByName($name))) {
        $mod->showConfigVar('g', $argv[1]);
    } else {
        Dog::rply('err_unk_var');
    }
} elseif ($argc === 3) {
    $name = $argv[0];
    if (false !== ($plug = Dog_Plugin::getPlugWithPerms($serv, $chan, $user, $name))) {
        $plug->setConfigVar('g', $argv[1], $argv[2]);
    } elseif (false !== ($mod = Dog_Module::getModuleWithPermsByTrigger($serv, $chan, $user, $name)) || false !== ($mod = Dog_Module::getByName($name))) {
        $mod->setConfigVar('g', $argv[1], $argv[2]);
    } else {
        Dog::rply('err_unk_var');
    }
} else {
    $plugin->showHelp();
}
Example #15
0
    $out = '';
    foreach ($vars as $var) {
        $var instanceof Dog_Var;
        $out .= sprintf(', %s', $var->getName());
    }
    return $plugin->rply('avail', array(substr($out, 2)));
} elseif ($argc === 1) {
    if (false === ($var = Dog_Var::getVar($vars, $argv[0]))) {
        return Dog::rply('err_unk_var');
    }
    $varname = $var->getName();
    $vartype = $var->displayType();
    $vardeft = $var->getDefault();
    $curvalu = Dog_Conf_Bot::getConf($varname, $vardeft);
    return $plugin->rply('show', array($varname, $vartype, $vardeft, $curvalu));
} elseif ($argc === 2) {
    if (false === ($var = Dog_Var::getVar($vars, $argv[0]))) {
        return Dog::rply('err_unk_var');
    }
    $varname = $var->getName();
    $vartype = $var->displayType();
    $vardeft = $var->getDefault();
    $curvalu = Dog_Conf_Bot::getConf($varname, $vardeft);
    if (!Dog_Var::isValid($var->getType(), $argv[1])) {
        return $plugin->rply('invalid', array($varname, $vartype));
    }
    Dog_Conf_Bot::setConf($varname, $argv[1]);
    return $plugin->rply('set', array($varname, $argv[1]));
} else {
    $plugin->showHelp();
}
Example #16
0
<?php

####conf retries,s,i,i,20,,,timeout,s,i,i,5,,,throttle,s,i,i,3,,,ircoppass,s,i,s,""
$lang = array('en' => array('help' => 'Usage: %CMD% [<server>]. Show the available servers and their throttle, connected servers have a bold ID, or show connection details for a specified server.', 'conf_retries' => 'Number of reconnect attempts.', 'conf_timeout' => 'Timeout of a single connection attempt.', 'conf_throttle' => 'Messages per .33 seconds. 3 equals 1 msg/s.', 'server' => '%s has set the throttle to %s and a connect timeout of %s seconds with %s retries. URI: %s', 'servers' => '%d/%d servers: %s.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    $out = '';
    $active = 0;
    $total = 0;
    foreach (Dog::getServers() as $server) {
        $server instanceof Dog_Server;
        $t = $server->getThrottle();
        $bt = $t == 0 ? chr(2) : '';
        $out .= sprintf(', %s%s(T%s)%s', $server->displayLongName(), $bt, $t, $bt);
        $active += $server->isConnected() ? 1 : 0;
        $total++;
    }
    $plugin->rply('servers', array($active, $total, substr($out, 2)));
} elseif ($argc === 1) {
    if (false === ($server = Dog::getServerByArg($argv[0]))) {
        Dog::rply('err_server');
    } else {
        $url = $server->isSSL() ? 'ircs://' : 'irc://';
        $url .= $server->getURL();
        $plugin->rply('server', array($server->displayLongName(), $server->getThrottle(), $server->getTimeout(), $server->getRetries(), $url));
    }
} else {
    $plugin->showHelp();
}
Example #17
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<server>]. Command %BOT% to quit a server.', 'ok' => 'Disconnecting from %s...', 'msg' => '%s executed %CMD%!'));
$plugin = Dog::getPlugin();
$user = Dog::getUser();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    $server = Dog::getServer();
} elseif ($argc === 1) {
    if (false === ($server = Dog::getServerByArg($argv[0]))) {
        return Dog::rply('err_server');
    }
} else {
    return $plugin->showHelp();
}
$server->saveOption(Dog_Server::ACTIVE, false);
$plugin->rply('ok', array($server->displayLongName()));
$server->disconnect($plugin->lang('msg', array($user->displayName())));
if (!$server->hasConnectedOnce()) {
    Dog::removeServer($server);
    $server->delete();
}
Example #18
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<user>]. Show the irc modes for a user for debugging purposes.', 'priv' => '%s has the %s irc modes in this channel, according to my memory.'));
$plug = Dog::getPlugin();
$chan = Dog::getChannel();
$argv = $plug->argv();
$argc = count($argv);
if ($argc === 0) {
    $user = Dog::getUser();
} else {
    if ($argc === 1) {
        if (false === ($user = Dog::getUserByArg($argv[0]))) {
            return Dog::rply('err_user');
        }
    } else {
        return $plug->showHelp();
    }
}
$priv = $chan->getPriv($user);
$plug->rply('priv', array($user->getName(), $priv));
Example #19
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <module> [<flush>]. Will (re)install and init a module.', 'install' => 'Triggering install for %s.', 'install_flush' => 'Dropping all tables and triggering install for %s.'), 'de' => array('help' => 'Nutze: %CMD% <Modul> [<flush>]. (Re)-Installiert und Initialisiert ein Modul.', 'install' => 'Führe die Installationsroutinen für %s aus.', 'install_flush' => 'Lösche und initialisiere Modul %s.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
$flush = false;
if ($argc === 2) {
    $flush = $argv[1] === 'flush';
    $argc = 1;
}
if ($flush) {
    return Dog::reply('NO FLUSH!');
}
if ($argc !== 1) {
    return $plugin->showHelp();
}
if (false === ($module = Dog_Module::getModule($argv[0]))) {
    return Dog::rply('err_module');
}
$plugin->rply($flush ? 'install_flush' : 'install', array($module->displayName()));
Dog_Init::installModule($module, $flush);
Example #20
0
<?php

$command = 'echo "`whoami`@`hostname`';
$whoami = $command . ' # %s';
$lang = array('en' => array('help' => 'Usage: %CMD%. Shows the output of the following linux command: ' . $command, 'whomi' => $whoami), 'en' => array('help' => 'Nutze: %CMD%. Führt diesen linux Befehl aus: echo "`whoami`@`hostname`', 'whomi' => $whoami));
if (!function_exists('exec')) {
    return Dog::rply('err_exec');
}
$plugin = Dog::getPlugin();
$user = Dog::getUser();
$output = array();
exec($command, $output);
$plugin->reply(implode("\t ", $output));
Example #21
0
                 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));
             } elseif (!$mod->isTriggerEnabled($serv, $chan, $trigger)) {
                 Dog::rply('err_disabled');
             } else {
                 $mod->execute($trigger);
             }
         } else {
             // 				Dog::rply('err_command');
         }
     }
 } elseif (Common::startsWith($msg, "") && Common::endsWith($msg, "")) {
     require 'CTCP.php';
 } else {
     $msg = preg_replace('[^a-z]', '', $msg);
     if ($msg === 'wechallnetISUP') {
         Dog::reply('Yay \\o/');
     } elseif ($msg === 'wechallnetISUP') {
         Dog::reply('NO! :(');
Example #22
0
 public function on_link_Pb()
 {
     if ('' === ($message = $this->msgarg())) {
         if (false === ($link = $this->getRandomLink())) {
             return Dog::rply('err_no_results');
         } else {
             return $this->displayLinkObject($link);
         }
     }
     if (is_numeric($message)) {
         return $this->displayLink($message);
     }
     $ids = Dog_Link::searchLinks($message);
     $count = count($ids);
     if ($count === 0) {
         return $this->rply('err_no_match');
     }
     if ($count === 1) {
         return $this->displayLink($ids[0]);
     }
     if ($count > self::MAX_COUNT) {
         $more = $count - self::MAX_COUNT;
         $ids = array_slice($ids, 0, self::MAX_COUNT);
     } else {
         $more = 0;
     }
     $key = $more === 0 ? 'matches' : 'match_more';
     $this->rply($key, array($count, implode(', ', $ids), $more));
 }
Example #23
0
<?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);
Example #24
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% <host>. Use the ping command to ping a host.', 'err_host' => 'The host looks invalid.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc !== 1) {
    return $plugin->showHelp();
}
$host = $argv[0];
if (!preg_match('/^[a-z0-9\\.\\-:]+$/iD', $host)) {
    $plugin->rply('err_host');
} elseif (!function_exists('exec')) {
    Dog::rply('err_exec');
} else {
    $ehost = escapeshellarg($host);
    exec("ping -c 3 {$ehost}", $output);
    foreach ($output as $line) {
        Dog::reply($line);
    }
}
Example #25
0
<?php

$lang = array('en' => array('help' => 'Usage: %CMD% [<server>]. List the channels where %BOT% is online.', 'none' => 'I am not connected to any channel on %s.', 'out' => 'I am in %d channels on %s: %s.'));
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
if ($argc === 0) {
    $server = Dog::getServer();
} elseif ($argc !== 1) {
    return $plugin->showHelp();
} else {
    if (false === ($server = Dog::getServerByArg($argv[0]))) {
        return Dog::rply('err_server');
    }
}
if (!$server->isConnected()) {
    return Dog::rply('err_connection');
}
$out = '';
$channels = $server->getChannels();
foreach ($channels as $channel) {
    $channel instanceof Lamb_Channel;
    $out .= sprintf(', %s(%d)', $channel->getName(), count($channel->getUsers()));
}
if ($out === '') {
    return $plugin->rply('none', array($server->displayName()));
}
$plugin->rply('out', array(count($channels), $server->displayName(), substr($out, 2)));
Example #26
0
<?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();
}