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

Function getPeerId

im/im.ts:82–100  ·  view source on GitHub ↗
(client: TelegramClient, msg: Api.Message, chatIdStr?: string)

Source from the content-addressed store, hash-verified

80 return null;
81 }
82
83 const peer = chatIdStr;
84 const resolved = await client.getInputEntity(peer);
85 if (resolved instanceof Api.InputPeerChannel) {
86 return `-100${resolved.channelId}`;
87 }
88 if (resolved instanceof Api.InputPeerChat) {
89 return `-${resolved.chatId}`;
90 }
91 if (resolved instanceof Api.InputPeerUser) {
92 return `${resolved.userId}`;
93 }
94 return null;
95 } catch (e) {
96 console.error(`[${PLUGIN_NAME}] Could not resolve peer:`, e);
97 return null;
98 }
99}
100
101// ==================== Timer tracking for safe cleanup ====================
102const pendingTimers = new Set<ReturnType<typeof setTimeout>>();
103

Callers 4

ImageMonitorPluginClass · 0.85
handleConfigCommandMethod · 0.85
handleNewMessageMethod · 0.85
handleEditedMessageMethod · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected