fix: auto-normalize http(s) URLs to ws(s) in bot plugins
Users behind reverse proxies naturally configure https:// URLs. The websocket-client library requires ws:// or wss:// schemes. Both plugins now auto-convert before connecting. Made-with: Cursor
This commit is contained in:
@@ -143,6 +143,10 @@ class NtrPlaylist(callbacks.Plugin):
|
|||||||
|
|
||||||
while not self._ws_stop.is_set():
|
while not self._ws_stop.is_set():
|
||||||
ws_url = self.registryValue("wsUrl")
|
ws_url = self.registryValue("wsUrl")
|
||||||
|
if ws_url.startswith("https://"):
|
||||||
|
ws_url = "wss://" + ws_url[8:]
|
||||||
|
elif ws_url.startswith("http://"):
|
||||||
|
ws_url = "ws://" + ws_url[7:]
|
||||||
token = self.registryValue("adminToken")
|
token = self.registryValue("adminToken")
|
||||||
channel = self.registryValue("announceChannel")
|
channel = self.registryValue("announceChannel")
|
||||||
client_id = self.registryValue("clientId") or "limnoria"
|
client_id = self.registryValue("clientId") or "limnoria"
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ def _ws_listener(bot):
|
|||||||
|
|
||||||
while not _ws_stop.is_set():
|
while not _ws_stop.is_set():
|
||||||
ws_url = bot.settings.ntr_playlist.ws_url
|
ws_url = bot.settings.ntr_playlist.ws_url
|
||||||
|
if ws_url.startswith("https://"):
|
||||||
|
ws_url = "wss://" + ws_url[8:]
|
||||||
|
elif ws_url.startswith("http://"):
|
||||||
|
ws_url = "ws://" + ws_url[7:]
|
||||||
token = bot.settings.ntr_playlist.admin_token
|
token = bot.settings.ntr_playlist.admin_token
|
||||||
channel = bot.settings.ntr_playlist.announce_channel
|
channel = bot.settings.ntr_playlist.announce_channel
|
||||||
client_id = bot.settings.ntr_playlist.client_id or "sopel"
|
client_id = bot.settings.ntr_playlist.client_id or "sopel"
|
||||||
|
|||||||
Reference in New Issue
Block a user