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

Function buildEntityLink

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

Source from the content-addressed store, hash-verified

225}
226
227function buildEntityLink(entity: any): string | undefined {
228 if (!entity) return undefined;
229 const username = resolveEntityUsername(entity);
230 if (username) return `https://t.me/${username}`;
231
232 const cleaned = cleanEntityId(
233 entity.id ??
234 entity.peerId ??
235 entity.chatId ??
236 entity.channelId ??
237 entity.userId ??
238 entity.peer?.channelId ??
239 entity.peer?.userId ??
240 entity.peer?.chatId
241 );
242 if (cleaned) {
243 if (entity instanceof Api.User || entity?.className === "User") {
244 return `tg://user?id=${cleaned}`;
245 }
246 return `https://t.me/c/${cleaned}`;
247 }
248 return undefined;
249}
250
251function buildMessageLink(entity: any, messageId: number): string | undefined {
252 if (!entity || !messageId) return undefined;

Callers 2

sendSourceFeedbackFunction · 0.85
sendTargetFeedbackFunction · 0.85

Calls 2

resolveEntityUsernameFunction · 0.85
cleanEntityIdFunction · 0.85

Tested by

no test coverage detected