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

Method discoverLinkedGroup

search/search.ts:83–119  ·  view source on GitHub ↗
(channel: Api.Channel)

Source from the content-addressed store, hash-verified

81 }
82
83 private async discoverLinkedGroup(channel: Api.Channel): Promise<string | undefined> {
84 try {
85 const fullChannel = await this.client.invoke(
86 new Api.channels.GetFullChannel({
87 channel: channel,
88 })
89 );
90
91 if (fullChannel.fullChat.linkedChatId) {
92 const linkedChatId = fullChannel.fullChat.linkedChatId;
93 const linkedGroup = await this.client.getEntity(linkedChatId);
94 if (linkedGroup instanceof Api.Channel && linkedGroup.megagroup) {
95 if (linkedGroup.username) {
96 return `@${linkedGroup.username}`;
97 } else {
98 try {
99 const inviteLink = await this.client.invoke(
100 new Api.messages.ExportChatInvite({
101 peer: linkedGroup
102 })
103 );
104 if (inviteLink instanceof Api.ChatInviteExported) {
105 return inviteLink.link;
106 }
107 } catch (linkError: any) {
108 console.log(`获取邀请链接失败: ${linkError.message}`);
109 }
110 return undefined;
111 }
112 }
113 }
114 return undefined;
115 } catch (error: any) {
116 console.log(`获取频道关联讨论组失败: ${error.message}`);
117 return undefined;
118 }
119 }
120
121 private async searchInChannelWithLinkedGroup(
122 channelInfo: { title: string; handle: string; linkedGroup?: string },

Callers 1

handleAddMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected