MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / handleIncomingMessage

Method handleIncomingMessage

src/runtime/adapters/feishu.ts:208–326  ·  view source on GitHub ↗
(message: NormalizedMessage)

Source from the content-addressed store, hash-verified

206 }
207 }
208
209 private async handleIncomingMessage(message: NormalizedMessage): Promise<void> {
210 if (!this.channel || !this.agent) {
211 return;
212 }
213
214 const decision = normalizeFeishuMessage(message);
215 if (decision.action === "ignore") {
216 return;
217 }
218
219 await this.tryAckReaction(message.messageId);
220
221 const channelId = `feishu-${message.chatId}`;
222 if (decision.action === "unsupported") {
223 await this.sendSafe(message.chatId, UNSUPPORTED_MESSAGE_REPLY, message.messageId);
224 return;
225 }
226
227 const userText = decision.text;
228 const attachments = await this.extractResourceAttachments(message, channelId);
229 if (
230 userText === ATTACHMENT_MESSAGE_TEXT &&
231 this.hasSupportedResources(message) &&
232 attachments.length === 0
233 ) {
234 await this.sendSafe(message.chatId, ATTACHMENT_DOWNLOAD_FAILED_REPLY, message.messageId);
235 return;
236 }
237
238 this.ipcBroadcaster?.broadcastInbound(
239 channelId,
240 "feishu",
241 {
242 id: message.senderId,
243 username: message.senderName || message.senderId,
244 },
245 userText,
246 );
247
248 const command = this.resolveCommand(userText);
249 if (command) {
250 const result = await this.agent.handleCommand(command, channelId);
251 await this.sendSafe(
252 message.chatId,
253 result.message || `/${command} executed.`,
254 message.messageId,
255 );
256 return;
257 }
258
259 let finalText = "";
260 let hasError = false;
261 let errorMessage = "";
262 const pendingFiles: Array<{ filePath: string; caption?: string }> = [];
263
264 const onEvent = (event: AgentEvent) => {
265 switch (event.type) {

Callers 2

startMethod · 0.95

Calls 11

tryAckReactionMethod · 0.95
sendSafeMethod · 0.95
hasSupportedResourcesMethod · 0.95
resolveCommandMethod · 0.95
sendLongMessageMethod · 0.95
sendFileSafeMethod · 0.95
normalizeFeishuMessageFunction · 0.85
broadcastInboundMethod · 0.65
handleCommandMethod · 0.65
handleMessageMethod · 0.65

Tested by

no test coverage detected