<commit_before><?php
require_once dirname(__FILE__) . '/WeChatCallBack.php';
/**
 * 核心类，用来加载其他的由关键字触发的功能类。
 * @author homker
 * @version 1.0.0
 */

class WeChatCallBackKeyWord extends WeChatCallBack{
	public function init($postObj) {
		// 获取参数
		$this->_postObject = $postObj;
		if ($this->_postObject == false) {
			return false;
		}
		$this->_fromUserName = ( string ) trim ( $this->_postObject->FromUserName );//openID
		$this->_toUserName = ( string ) trim ( $this->_postObject->ToUserName );//公众号名字
		$this->_msgType = ( string ) trim ( $this->_postObject->MsgType );
		$this->_createTime = ( int ) trim ( $this->_postObject->CreateTime );
		$this->_msgId = ( int ) trim ( $this->_postObject->MsgId );
		$this->_time = time ();
		if(!($this->_fromUserName && $this->_toUserName && $this->_msgType)) {
			return false;
		}
		return true;
	}
	
	public function process(){
		try {
			$db = DbFactory::getInstance('DB');
			$sql = "SELECT * FROM keyword";
			//$sql = "insert into userinput (userId, input) values(\"" . $this->_fromUserName . "\", \"" . $this->_postObject->Content . "\")";
			interface_log(DEBUG, 0, "sql:" . $sql);			
			$rs = $db->query($sql);
			
		} catch (DB_Exception $e) {
			interface_log(ERROR, EC_DB_OP_EXCEPTION, "query db error" . $e->getMessage());
		}
			while($row = $db->fetch($rs)){
				if(strstr($this->_postObject->Content, $row['key']))
				{
					$model = $row['content'];
					interface_log(DEBUG, 0, "所属关键字".$rowp['key']."匹配模式".$row['content']);
					break;
				}
			}
			if (!isset($model)) {
				interface_log(lDEBUG, 0, "内容不属于关键字，内容是：".$this->_postObject->Content);
				return $this->makeHint($this->_fromUSerName);
			}
			if(strstr($model, 'model')){
				$queryObj = $this->modelMatch($model);
				if(!is_object($queryobj)){
					if($StudentID = $this->getSID($this->_fromUserName)){
						$queryObj = $this ->modelMatch_xh($model);
					}else{
						interface_log('ERROR', 0,"未获取到学号。");
					}
				}

			}<commit_msg>fix the problem of return null<commit_after><?php
require_once dirname(__FILE__) . '/WeChatCallBack.php';
/**
 * 核心类，用来加载其他的由关键字触发的功能类。
 * @author homker
 * @version 1.0.0
 */

class WeChatCallBackKeyWord extends WeChatCallBack{
	public function init($postObj) {
		// 获取参数
		$this->_postObject = $postObj;
		if ($this->_postObject == false) {
			return false;
		}
		$this->_fromUserName = ( string ) trim ( $this->_postObject->FromUserName );//openID
		$this->_toUserName = ( string ) trim ( $this->_postObject->ToUserName );//公众号名字
		$this->_msgType = ( string ) trim ( $this->_postObject->MsgType );
		$this->_createTime = ( int ) trim ( $this->_postObject->CreateTime );
		$this->_msgId = ( int ) trim ( $this->_postObject->MsgId );
		$this->_time = time ();
		if(!($this->_fromUserName && $this->_toUserName && $this->_msgType)) {
			return false;
		}
		return true;
	}
	
	public function process(){
		try {
			$db = DbFactory::getInstance('DB');
			$sql = "SELECT * FROM keyword";
			//$sql = "insert into userinput (userId, input) values(\"" . $this->_fromUserName . "\", \"" . $this->_postObject->Content . "\")";
			interface_log(DEBUG, 0, "sql:" . $sql);			
			$rs = $db->query($sql);
			
		} catch (DB_Exception $e) {
			interface_log(ERROR, EC_DB_OP_EXCEPTION, "query db error" . $e->getMessage());
		}
			while($row = $db->fetch($rs)){
				if(strstr($this->_postObject->Content, $row['key']))
				{
					$model = $row['content'];
					interface_log(DEBUG, 0, "所属关键字".$rowp['key']."匹配模式".$row['content']);
					break;
				}
			}
			if (!isset($model)) {
				interface_log(lDEBUG, 0, "内容不属于关键字，内容是：".$this->_postObject->Content);
				return $this->makeHint("");
			}
			if(strstr($model, 'model')){
				$queryObj = $this->modelMatch($model);
				if(!is_object($queryobj)){
					if($StudentID = $this->getSID($this->_fromUserName)){
						$queryObj = $this ->modelMatch_xh($model);
					}else{
						interface_log('ERROR', 0,"未获取到学号。");
					}
				}

			}
{'fraction_non_alphanumeric': 0.2043777042504454, 'fraction_numerical': 0.003563247645711377, 'mean_word_length': 3.618096357226792, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6948470', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1464, 'n_words': 243}