(msg: Api.Message, args: string[])
| 1056 | } |
| 1057 | |
| 1058 | async function handleSearch(msg: Api.Message, args: string[]): Promise<void> { |
| 1059 | const replyMsg = await msg.getReplyMessage(); |
| 1060 | const { userQuestion, displayQuestion, apiQuestion } = extractQuestionFromArgs(args, replyMsg); |
| 1061 | |
| 1062 | if (!apiQuestion) { |
| 1063 | await msg.edit({ text: "❌ 请提供搜索查询或回复一条有文字内容的消息" }); |
| 1064 | return; |
| 1065 | } |
| 1066 | |
| 1067 | await msg.edit({ text: "🔍 搜索中..." }); |
| 1068 | const answer = await callGeminiChat(apiQuestion, true); |
| 1069 | const formattedText = formatResponse(displayQuestion, answer); |
| 1070 | |
| 1071 | if (replyMsg) { |
| 1072 | await msg.client?.sendMessage(msg.peerId, { |
| 1073 | message: formattedText + "\n\n<i>Powered by Gemini with Google Search</i>", |
| 1074 | linkPreview: false, |
| 1075 | parseMode: "html", |
| 1076 | replyTo: replyMsg.id |
| 1077 | }); |
| 1078 | |
| 1079 | try { |
| 1080 | await msg.delete(); |
| 1081 | } catch {} |
| 1082 | } else { |
| 1083 | await msg.edit({ |
| 1084 | text: formattedText + "\n\n<i>Powered by Gemini with Google Search</i>", |
| 1085 | linkPreview: false, |
| 1086 | parseMode: "html" |
| 1087 | }); |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | async function handleImage(msg: Api.Message, args: string[]): Promise<void> { |
| 1092 | const replyMsg = await msg.getReplyMessage(); |
no test coverage detected