|
|
@@ -137,40 +137,50 @@ class Message extends BaseModel
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if ($sendInterval) {
|
|
|
Cache::set('send_' . $uid, time(), $sendInterval);
|
|
|
}
|
|
|
- $data = self::sendMsg($param,$is_group);
|
|
|
+ $data = self::sendMsg($param,$is_group, 0, $uid);
|
|
|
|
|
|
// 机器人自动回复问题推送给用户
|
|
|
if ($is_robot && $param['type'] == 'text') {
|
|
|
//获取关键词匹配
|
|
|
$keyword_ids = KeywordLanguages::getKeywordByContent($param['content']);
|
|
|
$question = QuestionLanguages::getQuestion($keyword_ids, $param['content']);
|
|
|
+ $data['question'] = $question;
|
|
|
if ($question) {
|
|
|
$param['type'] = 'list';
|
|
|
- $param['content'] = $question;
|
|
|
+ $content = [
|
|
|
+ 'title' => Config::where('field','reply_keyword')->value('val'),
|
|
|
+ 'list' => $question,
|
|
|
+ ];
|
|
|
+ $param['content'] = json_encode($content);
|
|
|
} else {
|
|
|
$param['type'] = 'text';
|
|
|
$param['content'] = Config::where('field','reply_keyword_math_fail')->value('val');
|
|
|
}
|
|
|
-
|
|
|
- $param['toContactId'] = $uid;
|
|
|
+
|
|
|
+ $fromUserId = $param['toContactId'];
|
|
|
+ $param['toContactId'] = $param['fromUser']['id'];
|
|
|
+ $param['user_id'] = $fromUserId;
|
|
|
$param['fromUser'] = [
|
|
|
- 'id' => $data['contactInfo']['id'],
|
|
|
- 'displayName' => $data['contactInfo']['displayName'],
|
|
|
- 'avatar' => $data['contactInfo']['avatar'],
|
|
|
- 'account' => '',
|
|
|
+ 'id' => $fromUserId,
|
|
|
+ 'displayName' => '88888',
|
|
|
+ 'avatar' => '',
|
|
|
+ 'account' => 'admin',
|
|
|
];
|
|
|
- self::sendMsg($param,$is_group);
|
|
|
+ $param['content'] = Config::where('field','reply_keyword_math_fail')->value('val');
|
|
|
+ //$data2 = self::sendMsg($param,$is_group, 0, $param['user_id']);
|
|
|
+
|
|
|
+ //机器人自动回复消息
|
|
|
+ event('AutoReplyMessage', [$param, $globalConfig]);
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
//实际发送消息
|
|
|
- public static function sendMsg($param,$is_group=0,$is_sys=0){
|
|
|
- $uid=self::$uid ?: ($param['user_id'] ?? 1);
|
|
|
+ public static function sendMsg($param,$is_group=0,$is_sys=0, $uid=0){
|
|
|
+ $uid = $uid ?: ($param['user_id'] ?? 1);
|
|
|
$toContactId=$param['toContactId'];
|
|
|
$manage=[];
|
|
|
// 重新建立会话,更新会话删除记录
|
|
|
@@ -208,7 +218,7 @@ class Message extends BaseModel
|
|
|
'from_user'=>$param['user_id'],
|
|
|
'to_user'=>$toContactId,
|
|
|
'id'=>$param['id'],
|
|
|
- 'content'=>str_encipher($param['content'],true),
|
|
|
+ 'content'=>$param['type'] != 'list' ? str_encipher($param['content'],true) : $param['content'],
|
|
|
'chat_identify'=>$chat_identify,
|
|
|
'create_time'=>time(),
|
|
|
'type'=>$param['type'],
|
|
|
@@ -242,7 +252,7 @@ class Message extends BaseModel
|
|
|
// 将团队所有成员的未读状态+1
|
|
|
GroupUser::editGroupUser([['group_id','=',$toContactId],['user_id','<>',$uid]],['unread'=>Db::raw('unread+1')]);
|
|
|
}else{
|
|
|
- $sendData['toContactId']=$uid;
|
|
|
+ $sendData['toContactId']=$toContactId;//$uid;
|
|
|
}
|
|
|
$sendData['fromUser']['id']=(int)$sendData['fromUser']['id'];
|
|
|
$sendData['fileSize']=$fileSzie;
|
|
|
@@ -265,6 +275,7 @@ class Message extends BaseModel
|
|
|
if($is_group==0){
|
|
|
$toContactId=[$toContactId,$param['user_id']];
|
|
|
}
|
|
|
+
|
|
|
$sendData['toUser']=$param['toContactId'];
|
|
|
$user=new User();
|
|
|
// 将聊天窗口的联系人信息带上,方便临时会话
|