mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
commit
2f972488a1
@ -1280,6 +1280,9 @@ class DialogController extends AbstractController
|
||||
if ($model_name) {
|
||||
$msgData['model_name'] = $model_name;
|
||||
}
|
||||
if (User::isBot($user->userid)) {
|
||||
$msgData['force_webhook'] = true; // 强制使用webhook发送
|
||||
}
|
||||
$result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'text', $msgData, $user->userid, false, false, $silence, $key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ class BotReceiveMsgTask extends AbstractTask
|
||||
}
|
||||
|
||||
// 判断消息是否存在
|
||||
$msg = WebSocketDialogMsg::with(['user'])->find($this->msgId);
|
||||
$msg = WebSocketDialogMsg::with(['user', 'webSocketDialog'])->find($this->msgId);
|
||||
if (empty($msg)) {
|
||||
return;
|
||||
}
|
||||
@ -75,7 +75,11 @@ class BotReceiveMsgTask extends AbstractTask
|
||||
$msg->readSuccess($botUser->userid);
|
||||
|
||||
// 判断消息是否是机器人发送的则不处理,避免循环
|
||||
if (!$msg->user || $msg->user->bot) {
|
||||
if ((!$msg->user || $msg->user->bot)) {
|
||||
$msgData = Base::json2array($msg->msg);
|
||||
if (Base::val($msgData, 'force_webhook') && $msg->webSocketDialog) {
|
||||
$this->handleWebhookRequest($msgData['text'], null, $msg, $msg->webSocketDialog, $botUser);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -138,11 +138,11 @@ class WebSocketDialogMsgTask extends AbstractTask
|
||||
'dot' => $dot,
|
||||
'updated' => $updated,
|
||||
];
|
||||
// 机器人收到消处理
|
||||
$botUser = User::whereUserid($userid)->whereBot(1)->first();
|
||||
if ($botUser) {
|
||||
$this->endArray[] = new BotReceiveMsgTask($botUser->userid, $msg->id, $mentions, $this->client);
|
||||
}
|
||||
}
|
||||
// 机器人收到消处理
|
||||
$botUser = User::whereUserid($userid)->whereBot(1)->first();
|
||||
if ($botUser) { // 避免机器人处理自己发送的消息
|
||||
$this->endArray[] = new BotReceiveMsgTask($botUser->userid, $msg->id, $mentions, $this->client);
|
||||
}
|
||||
}
|
||||
// 更新已发送数量
|
||||
|
||||
@ -69,9 +69,72 @@ export default {
|
||||
"| `mention` | {{是否被@到}} | boolean |",
|
||||
"| `bot_uid` | {{机器人ID}} | string |",
|
||||
"| `version` | {{系统版本}} | string |",
|
||||
"### 3. {{打开会话 消息推送}}",
|
||||
"",
|
||||
"{{打开机器人会话后会自动POST推送到配置的Webhook地址,请求超时为30秒。}}",
|
||||
"",
|
||||
"#### {{推送参数}}",
|
||||
"",
|
||||
"| {{参数名}} | {{说明}} | {{类型}} |",
|
||||
"|--------|------|------|",
|
||||
"| `event` | {{推送事件}} | string |",
|
||||
"| `timestamp` | {{推送时间戳}} | string |",
|
||||
"| `dialog_id` | {{对话ID}} | string |",
|
||||
"| `dialog_type` | {{对话类型}} | string |",
|
||||
"| `bot_uid` | {{机器人ID}} | string |",
|
||||
"| `owner_uid` | {{机器人所属用户ID}} | string |",
|
||||
"| `user` | {{机器人所属用户信息}} | object |",
|
||||
"| `user.userid` | {{用户ID}} | string |",
|
||||
"| `user.email` | {{用户邮箱}} | string |",
|
||||
"| `user.nickname` | {{用户昵称}} | string |",
|
||||
"### 4. {{成员加入 消息推送}}",
|
||||
"",
|
||||
"{{成员加入群组后会自动POST推送到配置的Webhook地址,请求超时为30秒。}}",
|
||||
"",
|
||||
"#### {{推送参数}}",
|
||||
"",
|
||||
"| {{参数名}} | {{说明}} | {{类型}} |",
|
||||
"|--------|------|------|",
|
||||
"| `event` | {{推送事件}} | string |",
|
||||
"| `timestamp` | {{推送时间戳}} | string |",
|
||||
"| `dialog_id` | {{对话ID}} | string |",
|
||||
"| `dialog_type` | {{对话类型}} | string |",
|
||||
"| `bot_uid` | {{机器人ID}} | string |",
|
||||
"| `owner_uid` | {{机器人所属用户ID}} | string |",
|
||||
"| `user` | {{机器人所属用户信息}} | object |",
|
||||
"| `user.userid` | {{用户ID}} | string |",
|
||||
"| `user.email` | {{用户邮箱}} | string |",
|
||||
"| `user.nickname` | {{用户昵称}} | string |",
|
||||
"### 5. {{成员退出 消息推送}}",
|
||||
"",
|
||||
"{{成员退出群组后会自动POST推送到配置的Webhook地址,请求超时为30秒。}}",
|
||||
"",
|
||||
"#### {{推送参数}}",
|
||||
"",
|
||||
"| {{参数名}} | {{说明}} | {{类型}} |",
|
||||
"|--------|------|------|",
|
||||
"| `event` | {{推送事件}} | string |",
|
||||
"| `timestamp` | {{推送时间戳}} | string |",
|
||||
"| `dialog_id` | {{对话ID}} | string |",
|
||||
"| `dialog_type` | {{对话类型}} | string |",
|
||||
"| `dialog_name` | {{对话名称}} | string |",
|
||||
"| `group_type` | {{群组类型}} | string |",
|
||||
"| `bot_uid` | {{机器人ID}} | string |",
|
||||
"| `owner_uid` | {{机器人所属用户ID}} | string |",
|
||||
"| `action` | {{动作}} | string |",
|
||||
"| `actor` | {{操作人信息}} | object |",
|
||||
"| `actor.userid` | {{用户ID}} | string |",
|
||||
"| `actor.email` | {{用户邮箱}} | string |",
|
||||
"| `actor.nickname` | {{用户昵称}} | string |",
|
||||
"| `actor.is_bot` | {{是否机器人}} | boolean |",
|
||||
"| `members` | {{成员信息}} | array |",
|
||||
"| `members.userid` | {{用户ID}} | string |",
|
||||
"| `members.email` | {{用户邮箱}} | string |",
|
||||
"| `members.nickname` | {{用户昵称}} | string |",
|
||||
"| `members.is_bot` | {{是否机器人}} | boolean |",
|
||||
].map(item => item.replace(/\{\{([^}]+)\}\}/g, (_, v1) => this.$L(v1))).join("\n");
|
||||
},
|
||||
},
|
||||
methods: {},
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
@ -463,7 +463,7 @@
|
||||
<Input v-model="modifyData.webhook_url" :maxlength="255" />
|
||||
</FormItem>
|
||||
<FormItem v-if="typeof modifyData.webhook_events !== 'undefined'" prop="webhook_events" :label="$L('Webhook事件')">
|
||||
<CheckboxGroup v-model="modifyData.webhook_events">
|
||||
<CheckboxGroup v-model="webhookEvents">
|
||||
<Checkbox v-for="option in webhookEventOptions" :key="option.value" :label="option.value">
|
||||
{{$L(option.label)}}
|
||||
</Checkbox>
|
||||
@ -781,6 +781,7 @@ export default {
|
||||
{value: 'member_join', label: '成员加入'},
|
||||
{value: 'member_leave', label: '成员退出'},
|
||||
],
|
||||
webhookEvents: [],
|
||||
|
||||
openId: 0,
|
||||
errorId: 0,
|
||||
@ -2762,8 +2763,9 @@ export default {
|
||||
clear_day: 0,
|
||||
webhook_url: '',
|
||||
system_name: '',
|
||||
webhook_events: this.prepareWebhookEvents([], true),
|
||||
webhook_events: [],
|
||||
})
|
||||
this.webhookEvents = this.prepareWebhookEvents([], true)
|
||||
this.modifyLoad++;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'users/bot/info',
|
||||
@ -2774,7 +2776,7 @@ export default {
|
||||
this.modifyData.clear_day = data.clear_day
|
||||
this.modifyData.webhook_url = data.webhook_url
|
||||
this.modifyData.system_name = data.system_name
|
||||
this.modifyData.webhook_events = this.prepareWebhookEvents(data.webhook_events, true)
|
||||
this.webhookEvents = this.prepareWebhookEvents(data.webhook_events, true)
|
||||
}).finally(() => {
|
||||
this.modifyLoad--;
|
||||
})
|
||||
@ -2929,7 +2931,7 @@ export default {
|
||||
name: this.modifyData.name,
|
||||
clear_day: this.modifyData.clear_day,
|
||||
webhook_url: this.modifyData.webhook_url,
|
||||
webhook_events: this.normalizeWebhookEvents(this.modifyData.webhook_events, false),
|
||||
webhook_events: this.normalizeWebhookEvents(this.webhookEvents),
|
||||
dialog_id: this.modifyData.dialog_id
|
||||
}).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
|
||||
2
resources/assets/js/store/actions.js
vendored
2
resources/assets/js/store/actions.js
vendored
@ -3399,7 +3399,7 @@ export default {
|
||||
}
|
||||
return item.dialog_user.userid === userid
|
||||
});
|
||||
if (dialog) {
|
||||
if (dialog && dialog.bot !== 1) {
|
||||
return dispatch("openDialog", dialog.id).then(resolve).catch(reject)
|
||||
}
|
||||
dispatch("call", {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user