(args: string[], replyMsg?: Api.Message | null)
| 1028 | } |
| 1029 | |
| 1030 | function extractQuestionFromArgs(args: string[], replyMsg?: Api.Message | null): { userQuestion: string; displayQuestion: string; apiQuestion: string } { |
| 1031 | const userQuestion = args.join(" "); |
| 1032 | |
| 1033 | if (!userQuestion && replyMsg?.text) { |
| 1034 | const replyText = Utils.removeEmoji(replyMsg.text.trim()); |
| 1035 | return { |
| 1036 | userQuestion: "", |
| 1037 | displayQuestion: replyText, |
| 1038 | apiQuestion: replyText |
| 1039 | }; |
| 1040 | } else if (userQuestion && replyMsg?.text) { |
| 1041 | const cleanUserQuestion = Utils.removeEmoji(userQuestion); |
| 1042 | const replyText = Utils.removeEmoji(replyMsg.text.trim()); |
| 1043 | return { |
| 1044 | userQuestion: cleanUserQuestion, |
| 1045 | displayQuestion: cleanUserQuestion, |
| 1046 | apiQuestion: `原消息内容: ${replyText}\n\n问题: ${cleanUserQuestion}` |
| 1047 | }; |
| 1048 | } else { |
| 1049 | const cleanUserQuestion = Utils.removeEmoji(userQuestion); |
| 1050 | return { |
| 1051 | userQuestion: cleanUserQuestion, |
| 1052 | displayQuestion: cleanUserQuestion, |
| 1053 | apiQuestion: cleanUserQuestion |
| 1054 | }; |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | async function handleSearch(msg: Api.Message, args: string[]): Promise<void> { |
| 1059 | const replyMsg = await msg.getReplyMessage(); |
no test coverage detected