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

Function getEntityDisplayName

bs/bs.ts:310–335  ·  view source on GitHub ↗
(entity: any)

Source from the content-addressed store, hash-verified

308}
309
310function getEntityDisplayName(entity: any): string | undefined {
311 if (!entity) return undefined;
312 if (typeof entity.title === "string" && entity.title.trim()) {
313 return entity.title.trim();
314 }
315 const names = [entity.firstName, entity.lastName]
316 .filter((item) => typeof item === "string" && item.trim())
317 .join(" ");
318 if (names.trim()) return names.trim();
319 if (typeof entity.username === "string" && entity.username.trim()) {
320 return `@${entity.username.trim()}`;
321 }
322 const idCandidate =
323 entity.id ??
324 entity.peerId ??
325 entity.chatId ??
326 entity.channelId ??
327 entity.userId ??
328 entity.peer?.channelId ??
329 entity.peer?.userId ??
330 entity.peer?.chatId;
331 if (typeof idCandidate !== "undefined") {
332 return String(idCandidate);
333 }
334 return undefined;
335}
336
337function buildReplyToForMessage(
338 message: Api.Message

Callers 2

sendSourceFeedbackFunction · 0.85
sendTargetFeedbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected