1
+ import multiprocessing as mp
1
2
import ssl
3
+ from typing import Any , Dict
4
+
2
5
import irc .bot
3
6
import irc .connection
4
- import multiprocessing as mp
7
+ from irc import schedule
5
8
from irc .client import Event , ServerConnection , ip_numstr_to_quad
6
9
from irc .client_aio import AioReactor
7
- from irc import schedule
8
- from typing import Any , Dict
9
10
10
11
11
12
class AioReactorWithScheduler (AioReactor ):
@@ -32,7 +33,7 @@ def __init__(
32
33
nickserv_password : str = "" ,
33
34
port : int = 6667 ,
34
35
use_ssl : bool = True ,
35
- ssl_connection_factory : irc .connection .Factory = None
36
+ ssl_connection_factory : irc .connection .Factory = None ,
36
37
) -> None :
37
38
self .channel = channel # type: irc.bot.Channel
38
39
self .zulip_client = zulip_client
@@ -47,17 +48,21 @@ def __init__(
47
48
if ssl_connection_factory :
48
49
self .connection_factory = ssl_connection_factory
49
50
else :
50
- self .connection_factory = irc .connection .AioFactory (ssl = ssl .create_default_context ())
51
+ self .connection_factory = irc .connection .AioFactory (
52
+ ssl = ssl .create_default_context ()
53
+ )
51
54
else :
52
55
self .connection_factory = irc .connection .AioFactory ()
53
56
54
57
connect_params = {}
55
- connect_params [' connect_factory' ] = self .connection_factory
58
+ connect_params [" connect_factory" ] = self .connection_factory
56
59
57
60
# Make sure the bot is subscribed to the stream
58
61
self .check_subscription_or_die ()
59
62
# Initialize IRC bot after proper connection to Zulip server has been confirmed.
60
- irc .bot .SingleServerIRCBot .__init__ (self , [irc .bot .ServerSpec (server , port )], nickname , nickname , ** connect_params )
63
+ irc .bot .SingleServerIRCBot .__init__ (
64
+ self , [irc .bot .ServerSpec (server , port )], nickname , nickname , ** connect_params
65
+ )
61
66
62
67
def zulip_sender (self , sender_string : str ) -> str :
63
68
nick = sender_string .split ("!" )[0 ]
@@ -67,7 +72,7 @@ def connect(self, *args: Any, **kwargs: Any) -> None:
67
72
# Taken from
68
73
# https://github.com/jaraco/irc/blob/main/irc/client_aio.py,
69
74
# in particular the method of AioSimpleIRCClient
70
- kwargs [' connect_factory' ] = self .connection_factory
75
+ kwargs [" connect_factory" ] = self .connection_factory
71
76
self .c = self .reactor .loop .run_until_complete (self .connection .connect (* args , ** kwargs ))
72
77
print ("Listening now. Please send an IRC message to verify operation" )
73
78
0 commit comments