(entity: any)
| 225 | } |
| 226 | |
| 227 | function 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 | |
| 251 | function buildMessageLink(entity: any, messageId: number): string | undefined { |
| 252 | if (!entity || !messageId) return undefined; |
no test coverage detected