MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / handleSearch

Function handleSearch

outdated/gemini/gemini.ts:1058–1089  ·  view source on GitHub ↗
(msg: Api.Message, args: string[])

Source from the content-addressed store, hash-verified

1056}
1057
1058async 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
1091async function handleImage(msg: Api.Message, args: string[]): Promise<void> {
1092 const replyMsg = await msg.getReplyMessage();

Callers 1

handleGeminiRequestFunction · 0.85

Calls 5

extractQuestionFromArgsFunction · 0.85
callGeminiChatFunction · 0.85
formatResponseFunction · 0.70
editMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected