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


PHP Module::removeWhisper方法代码示例

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


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

示例1: handle

	public function handle(Bot $bot) {
		if (Module::removeWhisper($this->bot->message['text']) == '!quiz start') {
			if (Core::compareLevel($this->bot->lookUpUserID(), 'quiz.leader')) {
				$this->bot->queue($this->bot->message['usernameraw'].' hat ein Quiz gestartet');
				$this->bot->queue('Du hast für Fragen mit Antwortmöglichkeiten '.self::TIME_W_ANSWERS.' Sekunden');
				$this->bot->queue('Wenn keine Antworten zur Verfügung stehen sind es '.self::TIME_WO_ANSWERS.' Sekunden');
				$this->bot->queue('Die Antworten sind an mich zu flüstern');
				$this->bot->queue('Die Antwort wird nur gezählt, wenn auch Groß-/Kleinschreibung passt');
				$this->bot->queue('Viel Spaß');
				$this->start();
			}
			else {
				$this->bot->denied();
			}
		}
		else if (Module::removeWhisper($this->bot->message['text']) == '!quiz end') {
			if (Core::compareLevel($this->bot->lookUpUserID(), 'quiz.leader')) {
				$this->bot->queue($this->bot->message['usernameraw'].' hat das Quiz beendet. ');
				$this->end();
			}
			else {
				$this->bot->denied();
			}
		}
		else if (substr(Module::removeWhisper($this->bot->message['text']), 0, 10) == '!question ') {
			if (Core::compareLevel($this->bot->lookUpUserID(), 'quiz.leader')) {
				$this->question(substr(Module::removeWhisper($this->bot->message['text']), 10));
			}
			else {
				$this->bot->denied();
			}
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:33,代码来源:ModuleQuiz.class.php

示例2: handle

	public function handle(Bot $bot) {		
		if (substr(Module::removeWhisper($bot->message['text']), 0, 5) == '!php ') {
			if (!Core::compareLevel($bot->lookUpUserID(), 'php.eval')) return $bot->denied();
			Core::log()->php = $bot->message['usernameraw'].' used '.Module::removeWhisper($bot->message['text']);
			eval(substr(Module::removeWhisper($bot->message['text']), 5));
		}
	}
开发者ID:0xLeon,项目名称:Chatbot,代码行数:7,代码来源:ModulePHP.class.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: work

	/**
	 * Does all the work
	 * 
	 * @return	void
	 */
	public function work() {
		if (VERBOSE > 0) Core::log()->info = 'Initializing finished, forking';
		// register some functions
		pcntl_signal(SIGTERM, array($this, 'signalHandler'));
		pcntl_signal(SIGCHLD, array($this, 'signalHandler'));
		pcntl_signal(SIGUSR1, array($this, 'signalHandler'));
		register_shutdown_function(array('Core', 'destruct'));
		
		$this->needRefork = true;
		$this->socketServer = stream_socket_server("tcp://127.0.0.1:9001", $errno, $errstr);
		$this->incomingSocket = stream_socket_client("tcp://127.0.0.1:9001", $errno, $errstr, 30);
		$this->outgoingSocket = stream_socket_accept($this->socketServer);

		// main loop
		while (true) {
			try {
				if ($this->needRefork) {
					$this->fork();
					$this->needRefork = false;
					
					if ($this->child === 0) {
						// child process
						return $this->child();
					}
					else {
						Core::log()->info = 'Child is: '.$this->child;
					}
				}
				
				// read messages
				$this->read();
				$this->parseSTDIN();
				if (!is_array($this->data['messages'])) continue;

				$this->messageCount += count($this->data['messages']);
				foreach($this->data['messages'] as $this->message) {
					// remove crap
					$this->message['text'] = html_entity_decode(
						preg_replace('~<a href="(.*)">(.*)</a>~U', "\${1}", 
							preg_replace('~<img src="(.*)" alt="(.*)" />~U', "\${2}", 
								$this->message['text']
							)
						)
					);
					
					// core commands
					if (substr(Module::removeWhisper($this->message['text']), 0, 6) == '!load ') {
						if (Core::compareLevel($this->lookUpUserID(), 'op.load')) {
							Core::log()->info = $this->message['usernameraw'].' loaded a module';
							$result = Core::loadModule(trim(substr(Module::removeWhisper($this->message['text']), 5)));
							if (!is_int($result)) {
								$this->success();
							}
							else {
								$name = 'module_error_'.$result;
								$this->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->$name);
							}
						}
						else {
							$this->denied();
						}
					}
					else if (substr(Module::removeWhisper($this->message['text']), 0, 8) == '!unload ') {
						if (Core::compareLevel($this->lookUpUserID(), 'op.load')) {
							Core::log()->info = $this->message['usernameraw'].' unloaded a module';
							$result = Core::unloadModule(trim(substr(Module::removeWhisper($this->message['text']), 7)));
							if (!is_int($result)) {
								$this->success();
							}
							else {
								$name = 'module_error_'.$result;
								$this->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->$name);
							}
						}
						else {
							$this->denied();
						}
					}
					else if (substr(Module::removeWhisper($this->message['text']), 0, 8) == '!reload ') {
						if (Core::compareLevel($this->lookUpUserID(), 'op.load')) {
							Core::log()->info = $this->message['usernameraw'].' reloaded a module';
							$result = Core::reloadModule(trim(substr(Module::removeWhisper($this->message['text']), 7)));
							if (!is_int($result)) {
								$this->success();
							}
							else {
								$name = 'module_error_'.$result;
								$this->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->$name);
							}
						}
						else {
							$this->denied();
						}
					}
					// fallback
//.........这里部分代码省略.........
开发者ID:0xLeon,项目名称:Chatbot,代码行数:101,代码来源:Bot.class.php


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