|
14 | 14 |
|
15 | 15 | logger = logging.getLogger("cloudbot") |
16 | 16 |
|
17 | | -irc_prefix_re = re.compile(r":([^ ]*) ([^ ]*) (.*)") |
18 | | -irc_noprefix_re = re.compile(r"([^ ]*) (.*)") |
19 | | -irc_netmask_re = re.compile(r"([^!@]*)!([^@]*)@(.*)") |
20 | | -irc_param_re = re.compile(r"(?:^|(?<= ))(:.*|[^ ]+)") |
21 | | - |
22 | 17 | irc_nick_re = re.compile(r'[A-Za-z0-9^{\}\[\]\-`_|\\]+') |
23 | 18 |
|
24 | 19 | irc_bad_chars = ''.join([chr(x) for x in list(range(0, 1)) + list(range(4, 32)) + list(range(127, 160))]) |
@@ -61,27 +56,26 @@ class IrcClient(Client): |
61 | 56 | :type _ignore_cert_errors: bool |
62 | 57 | """ |
63 | 58 |
|
64 | | - def __init__(self, bot, name, nick, *, channels=None, config=None, |
65 | | - server, port=6667, use_ssl=False, ignore_cert_errors=True, timeout=300, local_bind=False): |
| 59 | + def __init__(self, bot, name, nick, *, channels=None, config=None): |
66 | 60 | """ |
67 | 61 | :type bot: cloudbot.bot.CloudBot |
68 | 62 | :type name: str |
69 | 63 | :type nick: str |
70 | 64 | :type channels: list[str] |
71 | 65 | :type config: dict[str, unknown] |
72 | | - :type server: str |
73 | | - :type port: int |
74 | | - :type use_ssl: bool |
75 | | - :type ignore_cert_errors: bool |
76 | | - :type timeout: int |
77 | 66 | """ |
78 | 67 | super().__init__(bot, name, nick, channels=channels, config=config) |
79 | 68 |
|
80 | | - self.use_ssl = use_ssl |
81 | | - self._ignore_cert_errors = ignore_cert_errors |
82 | | - self._timeout = timeout |
83 | | - self.server = server |
84 | | - self.port = port |
| 69 | + self.use_ssl = config['connection'].get('ssl', False) |
| 70 | + self._ignore_cert_errors = config['connection']['ignore_cert'] |
| 71 | + self._timeout = config['connection']['timeout'] |
| 72 | + self.server = config['connection']['server'] |
| 73 | + self.port = config['connection'].get('port', 6667) |
| 74 | + |
| 75 | + local_bind = (config['connection'].get('bind_addr', False), config['connection'].get('bind_port', 0)) |
| 76 | + if local_bind[0] is False: |
| 77 | + local_bind = False |
| 78 | + |
85 | 79 | self.local_bind = local_bind |
86 | 80 | # create SSL context |
87 | 81 | if self.use_ssl: |
|
0 commit comments