forked from platypush/platypush
[irc] Fixed Python 3.12 compatibility.
`ssl.wrap_socket()` has been removed in Python 3.12 - see https://docs.python.org/3.12/whatsnew/3.12.html#ssl. Instead, the integration should create its own `SSLContext` and use the `wrap_socket()` from that object.
This commit is contained in:
parent
66a585e653
commit
61b2afce91
1 changed files with 6 additions and 3 deletions
|
@ -70,8 +70,11 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
||||||
dcc_max_connections: Optional[int] = None,
|
dcc_max_connections: Optional[int] = None,
|
||||||
):
|
):
|
||||||
connection_factory = ConnectionFactory()
|
connection_factory = ConnectionFactory()
|
||||||
|
self._ssl_ctx = None
|
||||||
|
|
||||||
if ssl:
|
if ssl:
|
||||||
connection_factory.wrapper = _ssl.wrap_socket
|
self._ssl_ctx = _ssl.create_default_context()
|
||||||
|
connection_factory.wrapper = self._ssl_ctx.wrap_socket
|
||||||
if ipv6:
|
if ipv6:
|
||||||
connection_factory.family = socket.AF_INET6
|
connection_factory.family = socket.AF_INET6
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
||||||
self.port = port
|
self.port = port
|
||||||
self.alias = alias
|
self.alias = alias
|
||||||
self._password = password
|
self._password = password
|
||||||
self.channels.update({channel: None for channel in channels})
|
self.channels.update(dict.fromkeys(channels))
|
||||||
self._stop_message = stop_message
|
self._stop_message = stop_message
|
||||||
self.dcc_ip_whitelist = set(dcc_ip_whitelist or [])
|
self.dcc_ip_whitelist = set(dcc_ip_whitelist or [])
|
||||||
self.dcc_ip_blacklist = set(dcc_ip_blacklist or [])
|
self.dcc_ip_blacklist = set(dcc_ip_blacklist or [])
|
||||||
|
@ -455,7 +458,7 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
||||||
def on_disconnect(self, connection: Connection, event: _IRCEvent):
|
def on_disconnect(self, connection: Connection, event: _IRCEvent):
|
||||||
self._post_event(connection, IRCDisconnectEvent)
|
self._post_event(connection, IRCDisconnectEvent)
|
||||||
# Cache channels for reconnect logic
|
# Cache channels for reconnect logic
|
||||||
channels = {ch: None for ch in self.channels.keys()}
|
channels = dict.fromkeys(self.channels)
|
||||||
super()._on_disconnect(connection, event)
|
super()._on_disconnect(connection, event)
|
||||||
self.channels.update(channels)
|
self.channels.update(channels)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue