当前位置: 首页>>代码示例>>PHP>>正文


PHP Core::language方法代码示例

本文整理汇总了PHP中Core::language方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::language方法的具体用法?PHP Core::language怎么用?PHP Core::language使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Core的用法示例。


在下文中一共展示了Core::language方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: caps

	protected function caps(Bot $bot) {
		if (!isset($this->caps[$bot->message['usernameraw']])) {
			$this->caps[$bot->message['usernameraw']] = array('kills' => 0, 'counter' => 0, 'lastreset' => 0);
		}
		if ($this->caps[$bot->message['usernameraw']]['lastreset'] < (time() - 3600)) {
			if ($this->caps[$bot->message['usernameraw']]['kills'] > 0) $this->caps[$bot->message['usernameraw']]['kills']--;
		}
		if ($this->caps[$bot->message['usernameraw']]['lastreset'] < (time() - 120)) {
			if ($this->caps[$bot->message['usernameraw']]['counter'] > 0) $this->caps[$bot->message['usernameraw']]['counter']--;
			$this->caps[$bot->message['usernameraw']]['lastreset'] = time();
		}
		
		$capscount = 0;
		// don't count whitespace
		$message = preg_replace('~[\s!?\.]~', '', $bot->message['text']);
		$charcount = strlen($message);
		$chars = str_split($bot->message['text']);
		foreach ($chars as $char) {
			if (preg_match('~[A-Z]~', $char)) $capscount++;
		}

		if (strlen($message) < 6 || ($capscount / $charcount * 100) < $this->config->config['capspercent']) return;
		
		$this->caps[$bot->message['usernameraw']]['counter']++;
		$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->antispam_no_caps);
		if ($this->caps[$bot->message['usernameraw']]['counter'] > 2) {
			$this->caps[$bot->message['usernameraw']]['counter'] = 0;
			$bot->queue('/tmute '.$bot->message['usernameraw'].' '.pow(2, $this->caps[$bot->message['usernameraw']]['kills']++));
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:30,代码来源:ModuleAntiSpam.class.php

示例2: __construct

	private function __construct() {
		self::init();
		self::$log = new Log();
		self::log()->info = 'Starting, PID is '.getmypid();
		if (VERBOSE > 5) {
			self::log()->info = '         (__) ';
			self::log()->info = '         (oo) ';
			self::log()->info = '   /------\/ ';
			self::log()->info = '  / |    ||   ';
			self::log()->info = ' *  /\---/\ ';
			self::log()->info = '    ~~   ~~   ';
			self::log()->info = '...."Have you mooed today?"...';
		}
		self::$config = new Config();
		self::$permission = new Permission();
		self::$language = new Language(LANGUAGE);
		if (VERBOSE > 0) self::log()->info = 'Loaded Config';
		self::$bot = new Bot();
		
		$modules = self::config()->config['modules'];
		// load default modules
		if (VERBOSE > 0) self::log()->info = 'Loading Modules';
		foreach ($modules as $module) {
			self::loadModule($module);
		}
		self::bot()->work();
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:27,代码来源:Core.class.php

示例3: handle

	public function handle(Bot $bot) {
		if ($bot->message['id'] % 500 == 0) $this->cache = array();
		if ($bot->message['usernameraw'] == NAME) return;
		if (substr($bot->message['text'], 0, 8) == '!google ') {
			$data = $this->search(substr($bot->message['text'], 8));
			$bot->queue('Google ['.substr($bot->message['text'], 8).']: http://google.de/search?q='.rawurlencode(substr($bot->message['text'], 8)).' '.Core::language()->get('google_number', array('{number}' => number_format($data['responseData']['cursor']['estimatedResultCount'], 0, Core::language()->decimal_point, Core::language()->thousand_separator))));
			$bot->queue('#1: '.strip_tags($data['responseData']['results'][0]['title']).': '.$data['responseData']['results'][0]['unescapedUrl']);
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:9,代码来源:ModuleGoogle.class.php

示例4: handle

	public function handle(Bot $bot) {
		if ($bot->message['id'] % 500 == 0) $this->config->write();
		if ($bot->message['type'] == Bot::JOIN) {
			
			$userID = $bot->lookUpUserID();
			if (isset($this->config->config[$userID]) && (!isset($this->coolDown[$userID]) || ($this->coolDown[$userID] + 5 * 60) < time())) {
				$bot->queue('['.$bot->message['usernameraw'].'] '.substr($this->config->config[$userID], 0, 250));
				$this->coolDown[$userID] = time();
			}
		}
		else if (substr(Module::removeWhisper($bot->message['text']), 0, 7) == '!quote ') {
			$username = substr(Module::removeWhisper($bot->message['text']), 7);
			$userID = $bot->lookUpUserID($username);
			if ($userID) {
				if (isset($this->config->config[$userID])) {
					$bot->queue('/whisper "'.$bot->message['usernameraw'].'" ['.$username.'] '.$this->config->config[$userID]);
				}
				else {
					$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->quotes_noquote);
				}
			}
			else {
				$bot->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->get('user_not_found', array('{user}' => $username)));
			}
		}
		else if (substr(Module::removeWhisper($bot->message['text']), 0, 10) == '!setquote ') {
			$this->config->config[$bot->lookUpUserID()] = substr(Module::removeWhisper($bot->message['text']), 10);
			$bot->success();
		}
		else if (Module::removeWhisper($bot->message['text']) == '!delquote') {
			unset($this->config->config[$bot->lookUpUserID()]);
			$bot->success();
		}
		else if (substr(Module::removeWhisper($bot->message['text']), 0, 11) == '!wipequote ') {
			if (Core::compareLevel($bot->lookUpUserID(), 'quote.wipe')) {
				$username = substr(Module::removeWhisper($bot->message['text']), 11);
				$userID = $bot->lookUpUserID($username);
				if ($userID > 0) {
					unset($this->config->config[$userID]);
					$bot->success();
				}
				else {
					$bot->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->get('user_not_found', array('{user}' => $username)));
				}
			}
			else {
				$bot->denied();
			}
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:50,代码来源:ModuleQuotes.class.php

示例5: handle

	public function handle(Bot $bot) {
		if (substr($bot->message['text'], 0, 7) != 'apt-get') return;
		$text = explode(' ', substr($bot->message['text'], 8), 2);

		switch ($text[0]) {
			case 'moo':
				$bot->queue('...."Have you mooed today?"...');
			break;
			case 'install':
				if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied();
				if (stripos($text[1], '--reinstall') !== -1) {
					$text[1] = str_replace('--reinstall', '', $text[1]);
					Core::log()->info = $bot->message['usernameraw'].' reloaded a module';
					$result = Core::reloadModule(trim($text[1]));
				}
				else {
					Core::log()->info = $bot->message['usernameraw'].' loaded a module';
					$result = Core::loadModule(trim($text[1]));
				}
				
				if (!is_int($result)) {
					$bot->success();
				}
				else {
					$name = 'module_error_'.$result;
					$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->$name);
				}
			break;
			case 'remove':
			case 'purge':
				$text[1] = str_replace('--purge', '', $text[1]);
				if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied();
				Core::log()->info = $bot->message['usernameraw'].' unloaded a module';
				$result = Core::unloadModule(trim($text[1]));
				if (!is_int($result)) {
					$bot->success();
				}
				else {
					$name = 'module_error_'.$result;
					$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->$name);
				}
			break;
			case 'upgrade':
				if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied();
				$modules = Core::getModules();
				foreach ($modules as $module => $tmp) Core::reloadModule($module);
			break;
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:49,代码来源:ModuleApt.class.php

示例6: handle

	public function handle(Bot $bot) {
		if (Module::removeWhisper($bot->message['text']) == '!mycolor') {
			preg_match_all('/color: #[0-9a-fA-F]{6}/', $bot->message['username'], $matches);
			$bot->queue('/whisper "'.$bot->message['usernameraw'].'" /color '.substr($matches[0][0], 7).' '.substr($matches[0][count($matches[0])-1], 7));
		}
		else if ($bot->message['text'] == '!info') {
			if (Core::compareLevel($bot->lookUpUserID(), 'util.info')) {
				$bot->queue(Core::language()->util_information.':');
				$bot->queue(Core::language()->util_since.": ".date('d.m.Y H:i:s', TIME));
				$bot->queue(Core::language()->util_got.": ".$bot->messageCount.' ('.round($bot->messageCount / (time() - TIME) * 60, 4).'/m)');
				$bot->queue(Core::language()->util_sent.": ".$bot->sendCount.' ('.round($bot->sendCount / (time() - TIME) * 60, 4).'/m)');
			}
			else {
				$bot->denied();
			}
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:17,代码来源:ModuleUtil.class.php

示例7: handle

	public function handle(Bot $bot) {
		if (Module::removeWhisper($bot->message['text']) == '!shutdown') {
			if (!Core::compareLevel($bot->lookUpUserID(), 'op.shutdown')) return $bot->denied();
			Core::log()->info = $bot->message['usernameraw'].' shutted the bot down';
			$bot->shutdown();
		}
		else if (Module::removeWhisper($bot->message['text']) == '!restart') {
			if (!Core::compareLevel($bot->lookUpUserID(), 'op.shutdown')) return $bot->denied();
                        Core::log()->info = $bot->message['usernameraw'].' restarted the bot';
                        $bot->shutdown(SIGUSR1);
		}
		else if (substr(Module::removeWhisper($bot->message['text']), 0, 5) == '!say ') {
			if (!Core::compareLevel($bot->lookUpUserID(), 500)) return $bot->denied();
			$bot->queue(substr(Module::removeWhisper($bot->message['text']), 5));
		}
		else if (Module::removeWhisper($bot->message['text']) == '!loaded') {
			if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied();
			$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->op_loaded.': '.implode(', ', array_keys(Core::getModules())));
		}
		else if (substr(Module::removeWhisper($bot->message['text']), 0, 6) == '!join ') {
			if (!Core::compareLevel($bot->lookUpUserID(), 'op.join')) return $bot->denied();
			$bot->getConnection()->join(substr(Module::removeWhisper($bot->message['text']), 6));
			$bot->success();
		}
		else if (Module::removeWhisper($bot->message['text']) == '!perms') {
			if (!Core::compareLevel($bot->lookUpUserID(), 500)) return $bot->denied();
			$perms = Core::permission()->getNodes();
			ksort($perms);
			$permString = array();
			foreach ($perms as $name => $level) {
				$permString[] = $name.': '.$level;
			}
			$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->op_perms.': '.implode(', ', $permString));
		}
		else if (Module::removeWhisper($bot->message['text']) == '!rooms') {
			if (!Core::compareLevel($bot->lookUpUserID(), 'op.join')) return $bot->denied();
			$rooms = $bot->getConnection()->getRooms();
			$roomString = array();
			foreach ($rooms as $id => $name) {
				$roomString[] = $name.': '.$id;
			}
			$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->op_rooms.': '.implode(', ', $roomString));
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:44,代码来源:ModuleOp.class.php

示例8: handle

	public function handle(Bot $bot) {
		if ($bot->message['id'] % 500 == 0) $this->config->write();
		if (substr($bot->message['text'], 0, 1) == '-') {
			if (isset($this->config->config[substr($bot->message['text'], 1)])) {
				$bot->queue($this->config->config[substr($bot->message['text'], 1)]);
			}
		}
		else if (substr(Module::removeWhisper($bot->message['text']), 0, 5) == '!dic ') {
			if (Core::compareLevel($bot->lookUpUserID(), 'dic.add')) {
				$data = explode(' ', substr(Module::removeWhisper($bot->message['text']), 5), 2);
				if (substr($data[1], 0, 1) == '!') return $bot->denied();
				$this->config->config[$data[0]] = $data[1];
				Core::log()->info = $bot->message['usernameraw'].' added '.$data[0].' to dictionary';
				$bot->success();
			}
			else {
				$bot->denied();
			}
		}
		else if (substr(Module::removeWhisper($bot->message['text']), 0, 8) == '!deldic ') {
			if (Core::compareLevel($bot->lookUpUserID(), 'dic.add')) {
				$data = substr(Module::removeWhisper($bot->message['text']), 8);
				unset($this->config->config[$data]);
				$bot->success();
			}
			else {
				$bot->denied();
			}
		}
		else if (Module::removeWhisper($bot->message['text']) == '!listdic') {
			if (Core::compareLevel($bot->lookUpUserID(), 'dic.list')) {
				$entries = array_keys($this->config->config);
				sort($entries);
				$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->dic_listdic.': '.implode(', ', $entries));
			}
			else {
				$bot->denied();
			}
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:40,代码来源:ModuleDictionary.class.php

示例9: init

 /**
  * Core::init()
  *
  * Our initialization function. This is called on all page requests to initialize the Core
  * object. Since it's also used during installation (when the databas and/or plugins haven't been
  * installed), the optional parameter controls whether or not the database object and plugins should
  * be initialized.
  *
  * @access public
  * @static
  * @param string $runtimeContext This determines the context in which the Core is being initialized. This
  *          info is used to let plugins instantiate themselves differently, as well as prevent the loading
  *          of incomplete parts of the script.<br />
  *          <b>installation</b>:          a fresh installation, DB not installed yet<br />
  *          <b>installation_db_ready</b>: during installation after the DB has been installed<br />
  *          <b>ui</b>:                    (default) for the main generator page<br />
  *          <b>generation</b>:            when we're in the process of creating actual data
  */
 public static function init($runtimeContext = "ui")
 {
     self::loadSettingsFile();
     error_reporting(self::$errorReporting);
     self::$translations = new Translations();
     self::$language = new Language(self::$defaultLanguageFile);
     self::initSmarty();
     // the order is significant, here
     if ($runtimeContext != "installation" || $runtimeContext != "installation_db_ready") {
         self::initDatabase();
     }
     if ($runtimeContext == "generation") {
         self::initGeoData();
     }
     if ($runtimeContext == "ui" || $runtimeContext == "generation") {
         self::initCountries();
         self::initExportTypes($runtimeContext);
         self::initDataTypes($runtimeContext);
         self::initSessions();
         self::initUser();
     }
 }
开发者ID:GrimDerp,项目名称:vagrant-synthetic-data-machine,代码行数:40,代码来源:Core.class.php

示例10: content

 /**
  *	Gets a value defined in the Content array.
  *
  *	@param	$key	mixed	Key value.
  *	@param	$class	string	Class name.
  **/
 public static function content($key = false, $error = _error, $class = _class)
 {
     //	make sure Content is loaded
     if (!($class = self::class_get($class, $error))) {
         return false;
     }
     if (!($cont = self::contents($error))) {
         return false;
     }
     if (!($lang = Core::language(false, false, $error))) {
         return false;
     }
     //	return the whole array if no key is specified;
     if (!$key && !is_string($key)) {
         return $cont[$lang][$class];
     }
     if (is_string($key) || is_numeric($key)) {
         return self::_content($key, $class, $cont[$lang]);
     } elseif (is_array($key)) {
         //	the array must have at least two elements and all of them must be string or number'.
         if (count($key) < 2) {
             return self::error(array('array_number', 'content', '2+'), false, $error, $class);
         }
         foreach ($key as $k => $v) {
             if (!is_string($v) && !is_numeric($v)) {
                 $key[$k] = (string) $v;
             }
             //return self::error('invalid_type', false, $error, $class);
         }
         // the first element of the array will always be the source string
         $src = self::_content((string) array_shift($key), $class, $cont[$lang]);
         // do the replacement
         return vsprintf($src, $key);
     }
     // This would only happen if true is sent as key
     return self::error('invalid_argument', false, $error, null);
 }
开发者ID:hectormenendez,项目名称:giro,代码行数:43,代码来源:library.php

示例11: init

 /**
  * Core::init()
  *
  * Our initialization function. This is called on all page requests to initialize the Core
  * object. Since it's also used during installation (when the database and/or plugins haven't been
  * installed), the optional parameter controls whether or not the database object, plugins, sessions and user
  * should be initialized. Different call contexts require different initialization.
  *
  * @access public
  * @static
  * @param string $runtimeContext This determines the context in which the Core is being initialized. This
  *          info is used to let plugins instantiate themselves differently, as well as prevent the loading
  *          of incomplete parts of the script.<br />
  *          <b>installation</b>:              a fresh installation, DB not installed yet<br />
  *          <b>installationDatabaseReady</b>: during installation after the DB has been installed<br />
  *          <b>ui</b>:                        (default) for the main generator page<br />
  *          <b>generation</b>:                when we're in the process of creating actual data
  *          <b>resetPlugins</b>:              initialized everything except the plugins, which may be safely reset
  */
 public static function init($runtimeContext = "ui")
 {
     self::loadSettingsFile();
     error_reporting(self::$errorReporting);
     // ensure the timezone is set. This is an arbitrary value (well, I live in Vancouver!) but it prevents warnings
     if (ini_get("date.timezone") == "") {
         ini_set("date.timezone", "Canada/Vancouver");
     }
     self::$translations = new Translations();
     // the order is significant in all of this
     if ($runtimeContext != "installation") {
         self::initDatabase();
         if (in_array($runtimeContext, array("installationDatabaseReady", "ui", "generation", "resetPlugins"))) {
             self::initSessions();
         }
         $dbDefaultLanguage = Settings::getSetting("defaultLanguage");
         if (!empty($dbDefaultLanguage)) {
             self::$defaultLanguageFile = $dbDefaultLanguage;
         }
     }
     self::$language = new Language(self::$defaultLanguageFile);
     self::initSmarty();
     if ($runtimeContext == "generation") {
         self::initGeoData();
     }
     if ($runtimeContext == "ui" || $runtimeContext == "generation") {
         self::initCountries();
         self::initExportTypes($runtimeContext);
         self::initDataTypes($runtimeContext);
     }
     if (in_array($runtimeContext, array("ui", "generation", "resetPlugins"))) {
         self::initUser();
     }
     set_time_limit(self::$timeout);
 }
开发者ID:balmychan,项目名称:generatedata,代码行数:54,代码来源:Core.class.php

示例12: getPage

 public function getPage($uri)
 {
     $match = '';
     $parts = explode("/", $uri);
     $pages = $this->nav;
     $counter = 0;
     if (in_array($parts[1], $this->languages)) {
         self::$language = $parts[1];
         array_shift($parts);
         array_shift($parts);
         $newuri = '/' . implode('/', $parts);
     } else {
         self::$language = 'en';
         $newuri = $uri;
     }
     if ($uri == '/' && file_exists(self::getRootPath() . 'pages' . DS . self::$language . DS . 'index.md')) {
         $mainpage = array('title' => '', 'url' => "/", 'order' => 0, 'active' => 0, 'file' => DS . 'index.md');
         return $mainpage;
     }
     foreach ($pages as $key => $subpages) {
         if ($newuri == $pages[$key]['url']) {
             $match = $pages[$key];
             $this->nav[$key]['active'] = true;
             return $match;
         }
         if ($match == '' && is_array($subpages)) {
             $i = 0;
             if (array_key_exists('submenu', $subpages) && is_array($subpages['submenu'])) {
                 foreach ($subpages['submenu'] as $key2 => $page) {
                     if ($newuri == $page['url']) {
                         $match = $page;
                         $this->nav[$key]['submenu'][$key2]['active'] = true;
                         $this->nav[$key]['active'] = true;
                         return $match;
                     }
                     $i++;
                 }
             }
         }
     }
     if (file_exists(self::getRootPath() . 'pages' . DS . self::$language . DS . 'index.md')) {
         $notfound = array('title' => '', 'url' => "/404", 'order' => 0, 'active' => 0, 'file' => '/404.md');
         return $notfound;
     } else {
         reset($pages);
         $first_key = key($pages);
         $match = $pages[$first_key];
         return $match;
     }
 }
开发者ID:n00dles,项目名称:ogma-docs,代码行数:50,代码来源:core.php

示例13: handle

	public function handle(Bot $bot) {
		if ($bot->message['id'] % 500 == 0) $this->config->write();
		if ($bot->message['type'] == Bot::JOIN) {
			$userID = $bot->lookUpUserID();
			if (!isset($this->config->config[$userID])) {
				$this->config->config[$userID] = array('got' => 0, 'has' => 3, 'lastjoin' => 0, 'joins' => 0);
			}
			if ($this->config->config[$userID]['lastjoin'] + 86400 < time()) {
				$this->config->config[$userID]['lastjoin'] = time();
				$this->config->config[$userID]['joins']++;
				if ($this->config->config[$userID]['joins'] >= 3) {
					$this->config->config[$userID]['joins'] = 0;
					$this->config->config[$userID]['has']++;
					$bot->queue('/whisper "'.$bot->message['usernameraw'].'" Du kannst jetzt '.$this->config->config[$userID]['has'].' Rosen verteilen: !rose Benutzername');
				}
			}
		}
		if (substr($t = Module::removeWhisper($bot->message['text']), 0, 6) == '!roses') {
			if ($t == '!roses') {
				$userID = $bot->lookUpUserID();
				$username = $bot->message['usernameraw'];
			}
			else {
				$username = substr($t, 7);
				$userID = $bot->lookUpUserID($username);
			}
			if (!isset($this->config->config[$userID])) {
				$this->config->config[$userID] = array('got' => 0, 'has' => 3, 'lastjoin' => 0, 'joins' => 0);
			}
			$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.$username.' hat bisher '.$this->config->config[$userID]['got']. ' Rosen erhalten und kann noch '.$this->config->config[$userID]['has'].' Stück verteilen.');
		}
		else if (substr($bot->message['text'], 0, 6) == '!rose ') {
			$userID = $bot->lookUpUserID();
			if (!isset($this->config->config[$userID])) {
				$this->config->config[$userID] = array('got' => 0, 'has' => 3, 'lastjoin' => 0, 'joins' => 0);
			}
			if ($this->config->config[$userID]['has'] > 0) {
				$username = substr($bot->message['text'], 6);
				$to = $bot->lookUpUserID($username);
				
				if ($to) {
					if ($to != $userID) {
						if (!isset($this->config->config[$to])) {
							$this->config->config[$to] = array('got' => 0, 'has' => 3, 'lastjoin' => 0, 'joins' => 0);
						}
						$this->config->config[$to]['got']++;
						$this->config->config[$userID]['has']--;
						$bot->queue('['.$bot->message['usernameraw'].'] hat eine Rose an '.$username.' gegeben');
					}
					else {
						$bot->queue('/whisper "'.$bot->message['usernameraw'].'" Du kannst dir nicht selber eine Rose geben');
					}
				}
				else {
					$bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->get('user_not_found', array('{user}' => $username)));
				}
			}
			else {
				$bot->queue('/whisper "'.$bot->message['usernameraw'].'" Du hast keine Rosen');
			}
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:62,代码来源:ModuleRose.class.php

示例14: handle

	public function handle(Bot $bot) {
		if ($this->rouletteBullet == 0) $this->rouletteBullet = rand(1,6);
		if (preg_match('~^\.\.\.+$~', $bot->message['text'])) {
			$bot->queue('/me '.Core::language()->toys_pacman);
		}

		if (Module::removeWhisper($bot->message['text']) == '!ping') {
			$bot->queue('/whisper "'.$bot->message['usernameraw'].'" !pong');
		}
		else if (substr($bot->message['text'], 0, 5) == '!dice') {
			$command = substr($bot->message['text'], 5);
			$command = explode('d', $command, 2);
			$command[0] = min(10, $command[0]);
			if (count($command) > 1) {
				while ($command[0]--) {
					$results[] = rand(1, $command[1]);
				}
			}
			else {
				 $results[] = rand(1,6);
			}
			sort($results);
			$bot->queue(implode(', ', $results).' wurde von '.$bot->message['usernameraw'].' gewuerfelt');
		}
		else if ($bot->message['text'] == '!kuschel') {
			$bot->queue('/me kuschelt sich an '.$bot->message['usernameraw']);
		}
		else if (substr($bot->message['text'], 0, 2) == '!8') {
			$data = str_split(substr(strtolower($bot->message['text']), 2));
			$sum = 0;
			foreach($data as $char) $sum += ord($char);
			$send = 'toys_eight_'.($sum % self::$eight);
			$bot->queue('['.$bot->message['usernameraw'].'] '.Core::language()->$send);
		}
		else if (substr($bot->message['text'], 0, 5) == '!user') {
			$text = str_split(substr(strtolower($bot->message['text']), 5));
			$sum = 0;
			foreach($text as $char) $sum += ord($char);
			$send = $bot->data['users'][$sum % count($bot->data['users'])]['usernameraw'];
			$bot->queue('['.$bot->message['usernameraw'].'] '.$send);
		}
		else if ($bot->message['type'] == Bot::MODERATE && preg_match('~bis [0-3][0-9].[01][0-9].([0-9]+)~', $bot->message['text'], $matches)) {
			if ($matches[1] > (date('Y') + 9000)) {
				$bot->queue('Its over ninethousand!');
			}
		}
		else if ($bot->message['text'] == '!shot' || $bot->message['text'] == '!spin') {
			if ($bot->message['text'] == '!spin') {
				$this->rouletteBullet = rand(1,6);
				$cost = 4;
				$message = '['.$bot->message['usernameraw'].'] dreht den Zylinder und drückt ab…';
			}
			else {
				$cost = 1;
				$message = '['.$bot->message['usernameraw'].'] drückt ab…';
			}
			if (!isset($this->rouletteStatus[$bot->message['usernameraw']])) $this->rouletteStatus[$bot->message['usernameraw']] = 0;
			$this->rouletteBullet--;
			if ($this->rouletteBullet == 0) {
				$this->rouletteStatus[$bot->message['usernameraw']] += $cost;
				$bot->queue($message.'Boooom');
				$bot->queue('/tmute '.$bot->message['usernameraw'].' '.($this->rouletteStatus[$bot->message['usernameraw']]));
				
				$this->rouletteBullet = rand(1,6);
			}
			else $bot->queue($message.'Klack, nichts passiert');
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:68,代码来源:ModuleToys.class.php

示例15: denied

	/**
	 * Prints out a permissionDenied message and logs the command
	 *
	 * @return	void
	 */
	public function denied() {
		$this->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->access_denied);
		Core::log()->permission = $this->message['usernameraw'].' tried to use '.$this->message['text'];
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:9,代码来源:Bot.class.php


注:本文中的Core::language方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。