1- import { RTMClient , LogLevel } from "@slack/rtm-api" ;
1+ import { RTMClient , LogLevel , RTMClientOptions } from "@slack/rtm-api" ;
22import { Main , ISlackTeam } from "./Main" ;
33import { SlackEventHandler } from "./SlackEventHandler" ;
44import { Logger } from "matrix-appservice-bridge" ;
@@ -10,6 +10,7 @@ import { BridgedRoom } from "./BridgedRoom";
1010import { SlackGhost } from "./SlackGhost" ;
1111import { DenyReason } from "./AllowDenyList" ;
1212import { createDM } from "./RoomCreation" ;
13+ import { HttpsProxyAgent } from 'https-proxy-agent' ;
1314
1415const log = new Logger ( "SlackRTMHandler" ) ;
1516
@@ -200,7 +201,7 @@ export class SlackRTMHandler extends SlackEventHandler {
200201 const LOG_LEVELS = [ "debug" , "info" , "warn" , "error" , "silent" ] ;
201202 const connLog = new Logger ( `RTM-${ logLabel . slice ( 0 , LOG_TEAM_LEN ) } ` ) ;
202203 const logLevel = LOG_LEVELS . indexOf ( this . main . config . rtm ?. log_level || "silent" ) ;
203- const rtm = new RTMClient ( token , {
204+ const rtmOpts = {
204205 logLevel : LogLevel . DEBUG , // We will filter this ourselves.
205206 logger : {
206207 getLevel : ( ) => LogLevel . DEBUG ,
@@ -211,7 +212,13 @@ export class SlackRTMHandler extends SlackEventHandler {
211212 info : logLevel <= 2 ? connLog . info . bind ( connLog ) : ( ) => { } ,
212213 error : logLevel <= 3 ? connLog . error . bind ( connLog ) : ( ) => { } ,
213214 } as SlackLogger ,
214- } ) ;
215+ } as RTMClientOptions ;
216+
217+ if ( this . main . config . slack_proxy ) {
218+ rtmOpts . agent = new HttpsProxyAgent ( this . main . config . slack_proxy ) ;
219+ }
220+
221+ const rtm = new RTMClient ( token , rtmOpts ) ;
215222
216223 rtm . on ( "error" , ( error ) => {
217224 // We must handle this lest the process be killed.
0 commit comments