From d63115440dbf426063e0f5d813255295dc910837 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 5 Nov 2018 18:30:14 +0000 Subject: [PATCH] Fix the order of some connection params, add `alias` as a seperate argument to IRCServer.Server --- modules/perform.py | 2 +- src/IRCBot.py | 2 +- src/IRCServer.py | 6 ++++-- src/utils/irc.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/perform.py b/modules/perform.py index 7bd1432f..cfae1d47 100644 --- a/modules/perform.py +++ b/modules/perform.py @@ -8,6 +8,6 @@ class Module(ModuleManager.BaseModule): command = command.split("%%") for j, part in enumerate(command[:]): command[j] = part.replace("%nick%", event["server" - ].original_nickname) + ].nickname) command = "%".join(command) event["server"].send(command) diff --git a/src/IRCBot.py b/src/IRCBot.py index 69bb3abb..10197509 100644 --- a/src/IRCBot.py +++ b/src/IRCBot.py @@ -44,7 +44,7 @@ class Bot(object): *self.database.servers.get(server_id)) new_server = IRCServer.Server(self, self._events, - connection_params.id, connection_params) + connection_params.id, connection_params.alias, connection_params) self._events.on("new.server").call(server=new_server) if not connect or not new_server.get_setting("connect", True): diff --git a/src/IRCServer.py b/src/IRCServer.py index b2e1607f..62efbc8f 100644 --- a/src/IRCServer.py +++ b/src/IRCServer.py @@ -11,11 +11,13 @@ class Server(IRCObject.Object): bot: "IRCBot.Bot", events: EventManager.EventHook, id: int, + alias: typing.Optional[str], connection_params: utils.irc.IRCConnectionParameters): self.connected = False self.bot = bot self.events = events self.id = id + self.alias = alias self.connection_params = connection_params self.name = None # type: typing.Optional[str] @@ -87,7 +89,7 @@ class Server(IRCObject.Object): self.socket.settimeout(5.0) if self.connection_params.bindhost: - self.socket.bind((self.bindhost, 0)) + self.socket.bind((self.connection_params.bindhost, 0)) if self.connection_params.tls: self.tls_wrap() @@ -95,7 +97,7 @@ class Server(IRCObject.Object): self.connection_params.port)) self.send_capibility_ls() - if self.password: + if self.connection_params.password: self.send_pass(self.connection_params.password) self.send_user(self.connection_params.username, diff --git a/src/utils/irc.py b/src/utils/irc.py index c78dd179..a7604b4b 100644 --- a/src/utils/irc.py +++ b/src/utils/irc.py @@ -145,7 +145,7 @@ def strip_font(s: str) -> str: OPT_STR = typing.Optional[str] class IRCConnectionParameters(object): def __init__(self, id: int, alias: OPT_STR, hostname: str, port: int, - tls: bool, ipv4: bool, password: OPT_STR, bindhost: OPT_STR, + password: OPT_STR, tls: bool, ipv4: bool, bindhost: OPT_STR, nickname: str, username: OPT_STR, realname: OPT_STR): self.id = id self.alias = alias