@@ -57,18 +57,38 @@ function installGatewayRuntime(params?: { probeOk?: boolean; botUsername?: strin
5757 const probeTelegram = vi . fn ( async ( ) =>
5858 params ?. probeOk ? { ok : true , bot : { username : params . botUsername ?? "bot" } } : { ok : false } ,
5959 ) ;
60+ const collectUnmentionedGroupIds = vi . fn ( ( ) => ( {
61+ groupIds : [ ] as string [ ] ,
62+ unresolvedGroups : 0 ,
63+ hasWildcardUnmentionedGroups : false ,
64+ } ) ) ;
65+ const auditGroupMembership = vi . fn ( async ( ) => ( {
66+ ok : true ,
67+ checkedGroups : 0 ,
68+ unresolvedGroups : 0 ,
69+ hasWildcardUnmentionedGroups : false ,
70+ groups : [ ] ,
71+ elapsedMs : 0 ,
72+ } ) ) ;
6073 setTelegramRuntime ( {
6174 channel : {
6275 telegram : {
6376 monitorTelegramProvider,
6477 probeTelegram,
78+ collectUnmentionedGroupIds,
79+ auditGroupMembership,
6580 } ,
6681 } ,
6782 logging : {
6883 shouldLogVerbose : ( ) => false ,
6984 } ,
7085 } as unknown as PluginRuntime ) ;
71- return { monitorTelegramProvider, probeTelegram } ;
86+ return {
87+ monitorTelegramProvider,
88+ probeTelegram,
89+ collectUnmentionedGroupIds,
90+ auditGroupMembership,
91+ } ;
7292}
7393
7494describe ( "telegramPlugin duplicate token guard" , ( ) => {
@@ -149,6 +169,85 @@ describe("telegramPlugin duplicate token guard", () => {
149169 ) ;
150170 } ) ;
151171
172+ it ( "passes account proxy and network settings into Telegram probes" , async ( ) => {
173+ const { probeTelegram } = installGatewayRuntime ( {
174+ probeOk : true ,
175+ botUsername : "opsbot" ,
176+ } ) ;
177+
178+ const cfg = createCfg ( ) ;
179+ cfg . channels ! . telegram ! . accounts ! . ops = {
180+ ...cfg . channels ! . telegram ! . accounts ! . ops ,
181+ proxy : "http://127.0.0.1:8888" ,
182+ network : {
183+ autoSelectFamily : false ,
184+ dnsResultOrder : "ipv4first" ,
185+ } ,
186+ } ;
187+ const account = telegramPlugin . config . resolveAccount ( cfg , "ops" ) ;
188+
189+ await telegramPlugin . status ! . probeAccount ! ( {
190+ account,
191+ timeoutMs : 5000 ,
192+ cfg,
193+ } ) ;
194+
195+ expect ( probeTelegram ) . toHaveBeenCalledWith ( "token-ops" , 5000 , {
196+ accountId : "ops" ,
197+ proxyUrl : "http://127.0.0.1:8888" ,
198+ network : {
199+ autoSelectFamily : false ,
200+ dnsResultOrder : "ipv4first" ,
201+ } ,
202+ } ) ;
203+ } ) ;
204+
205+ it ( "passes account proxy and network settings into Telegram membership audits" , async ( ) => {
206+ const { collectUnmentionedGroupIds, auditGroupMembership } = installGatewayRuntime ( {
207+ probeOk : true ,
208+ botUsername : "opsbot" ,
209+ } ) ;
210+
211+ collectUnmentionedGroupIds . mockReturnValue ( {
212+ groupIds : [ "-100123" ] ,
213+ unresolvedGroups : 0 ,
214+ hasWildcardUnmentionedGroups : false ,
215+ } ) ;
216+
217+ const cfg = createCfg ( ) ;
218+ cfg . channels ! . telegram ! . accounts ! . ops = {
219+ ...cfg . channels ! . telegram ! . accounts ! . ops ,
220+ proxy : "http://127.0.0.1:8888" ,
221+ network : {
222+ autoSelectFamily : false ,
223+ dnsResultOrder : "ipv4first" ,
224+ } ,
225+ groups : {
226+ "-100123" : { requireMention : false } ,
227+ } ,
228+ } ;
229+ const account = telegramPlugin . config . resolveAccount ( cfg , "ops" ) ;
230+
231+ await telegramPlugin . status ! . auditAccount ! ( {
232+ account,
233+ timeoutMs : 5000 ,
234+ probe : { ok : true , bot : { id : 123 } , elapsedMs : 1 } ,
235+ cfg,
236+ } ) ;
237+
238+ expect ( auditGroupMembership ) . toHaveBeenCalledWith ( {
239+ token : "token-ops" ,
240+ botId : 123 ,
241+ groupIds : [ "-100123" ] ,
242+ proxyUrl : "http://127.0.0.1:8888" ,
243+ network : {
244+ autoSelectFamily : false ,
245+ dnsResultOrder : "ipv4first" ,
246+ } ,
247+ timeoutMs : 5000 ,
248+ } ) ;
249+ } ) ;
250+
152251 it ( "forwards mediaLocalRoots to sendMessageTelegram for outbound media sends" , async ( ) => {
153252 const sendMessageTelegram = vi . fn ( async ( ) => ( { messageId : "tg-1" } ) ) ;
154253 setTelegramRuntime ( {
0 commit comments