@@ -66,9 +66,13 @@ def __init__(
6666 raise ValueError (
6767 "Discord bot token is required. Pass token= or set DISCORD_BOT_TOKEN env var."
6868 )
69- self ._channel_id = channel_id or ""
69+ self ._channel_id = channel_id or os . environ . get ( "DISCORD_CHANNEL_ID" , "" )
7070 self ._timeout = timeout
7171 self ._poll_interval = poll_interval
72+ # Optional: set PRAISONAI_DISCORD_SSL_VERIFY=false to skip SSL verify
73+ # (e.g. corporate proxy / CA issues)
74+ _v = os .environ .get ("PRAISONAI_DISCORD_SSL_VERIFY" , "true" ).lower ()
75+ self ._ssl_verify = _v not in ("false" , "0" , "no" )
7276
7377 def __repr__ (self ) -> str :
7478 masked = f"...{ self ._token [- 4 :]} " if len (self ._token ) > 4 else "***"
@@ -109,7 +113,9 @@ async def _do_request(s):
109113 if session is not None :
110114 return await _do_request (session )
111115 else :
112- async with aiohttp .ClientSession () as _session :
116+ async with aiohttp .ClientSession (
117+ connector = aiohttp .TCPConnector (ssl = self ._ssl_verify ),
118+ ) as _session :
113119 return await _do_request (_session )
114120
115121 # ── ApprovalProtocol implementation ─────────────────────────────────
@@ -126,7 +132,9 @@ async def request_approval(self, request) -> Any:
126132 reason = "No Discord channel_id configured" ,
127133 )
128134
129- async with aiohttp .ClientSession () as session :
135+ async with aiohttp .ClientSession (
136+ connector = aiohttp .TCPConnector (ssl = self ._ssl_verify ),
137+ ) as session :
130138 # 1. Post approval embed
131139 embed = self ._build_embed (request )
132140 content = self ._build_fallback_text (request )
@@ -349,7 +357,9 @@ async def _update_message(
349357 ) as resp :
350358 data = await resp .json ()
351359 else :
352- async with aiohttp .ClientSession () as _session :
360+ async with aiohttp .ClientSession (
361+ connector = aiohttp .TCPConnector (ssl = self ._ssl_verify ),
362+ ) as _session :
353363 async with _session .patch (
354364 url , headers = headers , json = payload ,
355365 timeout = aiohttp .ClientTimeout (total = 10 ),
0 commit comments