diff --git a/CHANGELOG b/CHANGELOG index ec48d368..1ebbe6a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -# TBD - BitBot v1.8.0 +# 2019-06-03 - BitBot v1.8.0 Added: - Module dependency system diff --git a/modules/line_handler/__init__.py b/modules/line_handler/__init__.py index aee4e05a..19e1902b 100644 --- a/modules/line_handler/__init__.py +++ b/modules/line_handler/__init__.py @@ -11,7 +11,7 @@ class Module(ModuleManager.BaseModule): default_event = any(default_events) kwargs = {"command": line.command, "args": line.args, "tags": line.tags, - "server": server, "prefix": line.prefix, + "server": server, "source": line.source, "direction": utils.Direction.Recv} self.events.on("raw.received").on(line.command).call_unsafe(**kwargs) diff --git a/modules/line_handler/channel.py b/modules/line_handler/channel.py index 5b877764..759fdf45 100644 --- a/modules/line_handler/channel.py +++ b/modules/line_handler/channel.py @@ -8,7 +8,7 @@ def handle_332(events, event): topic=topic) def topic(events, event): - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) channel = event["server"].channels.get(event["args"][0]) topic = event["args"].get(1) channel.set_topic(topic) @@ -69,17 +69,17 @@ def join(events, event): account = event["args"][1] realname = event["args"][2] - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) - user.username = event["prefix"].username - user.hostname = event["prefix"].hostname + user.username = event["source"].username + user.hostname = event["source"].hostname if account: user.identified_account = account user.identified_account_id = event["server"].get_user(account).get_id() if realname: user.realname = realname - is_self = event["server"].is_own_nickname(event["prefix"].nickname) + is_self = event["server"].is_own_nickname(event["source"].nickname) if is_self: channel = event["server"].channels.add(channel_name) else: @@ -101,7 +101,7 @@ def join(events, event): def part(events, event): channel = event["server"].channels.get(event["args"][0]) - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) reason = event["args"].get(1) channel.remove_user(user) @@ -109,7 +109,7 @@ def part(events, event): if not len(user.channels): event["server"].remove_user(user) - if not event["server"].is_own_nickname(event["prefix"].nickname): + if not event["server"].is_own_nickname(event["source"].nickname): events.on("received.part").call(channel=channel, reason=reason, user=user, server=event["server"]) else: @@ -137,7 +137,7 @@ def handle_477(timers, event): server_id=event["server"].id) def kick(events, event): - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) target = event["args"][1] channel = event["server"].channels.get(event["args"][0]) reason = event["args"].get(2) diff --git a/modules/line_handler/core.py b/modules/line_handler/core.py index 6d3b3129..3d656b2f 100644 --- a/modules/line_handler/core.py +++ b/modules/line_handler/core.py @@ -8,7 +8,7 @@ def ping(event): def handle_001(event): event["server"].socket.enable_write_throttle() - event["server"].name = event["prefix"].hostmask + event["server"].name = event["source"].hostmask event["server"].set_own_nickname(event["args"][0]) event["server"].send_whois(event["server"].nickname) event["server"].connected = True @@ -65,7 +65,7 @@ def motd_line(event): event["server"].motd_lines.append(event["args"][1]) def mode(events, event): - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) target = event["args"][0] is_channel = target[0] in event["server"].channel_types if is_channel: @@ -98,7 +98,7 @@ def mode(events, event): def invite(events, event): target_channel = event["args"][1] - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) target_user = event["server"].get_user(event["args"][0]) events.on("received.invite").call(user=user, target_channel=target_channel, server=event["server"], target_user=target_user) diff --git a/modules/line_handler/message.py b/modules/line_handler/message.py index e7f3e2e9..38585a74 100644 --- a/modules/line_handler/message.py +++ b/modules/line_handler/message.py @@ -1,20 +1,20 @@ from src import utils -def _from_self(server, direction, prefix): +def _from_self(server, direction, source): if direction == utils.Direction.Send: if server.has_capability_str("echo-message"): return None else: return True else: - if prefix: - return server.is_own_nickname(prefix.nickname) + if source: + return server.is_own_nickname(source.nickname) else: return False def message(events, event): from_self = _from_self(event["server"], event["direction"], - event.get("prefix", None)) + event.get("source", None)) if from_self == None: return @@ -25,12 +25,12 @@ def message(events, event): message = event["args"][1] if not from_self and ( - not event["prefix"] or + not event["source"] or not event["server"].name or - event["prefix"].hostmask == event["server"].name or + event["source"].hostmask == event["server"].name or target_str == "*"): - if event["prefix"]: - event["server"].name = event["prefix"].hostmask + if event["source"]: + event["server"].name = event["source"].hostmask events.on("received.server-notice").call(message=message, message_split=message.split(" "), server=event["server"]) @@ -39,7 +39,7 @@ def message(events, event): if from_self: user = event["server"].get_user(event["server"].nickname) else: - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) # strip prefix_symbols from the start of target, for when people use # e.g. 'PRIVMSG +#channel :hi' which would send a message to only diff --git a/modules/line_handler/user.py b/modules/line_handler/user.py index f95ce4f4..c31a3b52 100644 --- a/modules/line_handler/user.py +++ b/modules/line_handler/user.py @@ -19,13 +19,13 @@ def handle_311(event): def quit(events, event): nickname = None if event["direction"] == utils.Direction.Recv: - nickname = event["prefix"].nickname + nickname = event["source"].nickname reason = event["args"].get(0) if event["direction"] == utils.Direction.Recv: - nickname = event["prefix"].nickname + nickname = event["source"].nickname if (not event["server"].is_own_nickname(nickname) and - not event["prefix"].hostmask == "*"): + not event["source"].hostmask == "*"): user = event["server"].get_user(nickname) event["server"].remove_user(user) events.on("received.quit").call(reason=reason, user=user, @@ -37,10 +37,10 @@ def quit(events, event): def nick(events, event): new_nickname = event["args"].get(0) - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) old_nickname = user.nickname - if not event["server"].is_own_nickname(event["prefix"].nickname): + if not event["server"].is_own_nickname(event["source"].nickname): events.on("received.nick").call(new_nickname=new_nickname, old_nickname=old_nickname, user=user, server=event["server"]) else: @@ -52,7 +52,7 @@ def nick(events, event): event["server"].change_user_nickname(old_nickname, new_nickname) def away(events, event): - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) message = event["args"].get(0) if message: user.away = True @@ -65,7 +65,7 @@ def away(events, event): events.on("received.away.off").call(user=user, server=event["server"]) def chghost(event): - nickname = event["prefix"].nickname + nickname = event["source"].nickname username = event["args"][0] hostname = event["args"][1] @@ -78,7 +78,7 @@ def chghost(event): target.hostname = hostname def setname(event): - nickname = event["prefix"].nickname + nickname = event["source"].nickname realname = event["args"][0] user = event["server"].get_user(nickname) @@ -88,7 +88,7 @@ def setname(event): event["server"].realname = realname def account(events, event): - user = event["server"].get_user(event["prefix"].nickname) + user = event["server"].get_user(event["source"].nickname) if not event["args"][0] == "*": user.identified_account = event["args"][0] diff --git a/src/IRCBot.py b/src/IRCBot.py index 37559d95..f5407e59 100644 --- a/src/IRCBot.py +++ b/src/IRCBot.py @@ -2,7 +2,7 @@ import enum, queue, os, select, socket, threading, time, traceback, typing, uuid from src import EventManager, Exports, IRCServer, Logging, ModuleManager from src import Socket, utils -VERSION = "v1.7.1" +VERSION = "v1.8.0" SOURCE = "https://git.io/bitbot" class TriggerResult(enum.Enum): diff --git a/src/IRCLine.py b/src/IRCLine.py index 9a545479..a612c0ad 100644 --- a/src/IRCLine.py +++ b/src/IRCLine.py @@ -39,12 +39,12 @@ class Hostmask(object): class ParsedLine(object): def __init__(self, command: str, args: typing.List[str], - prefix: Hostmask=None, + source: Hostmask=None, tags: typing.Dict[str, str]=None): self.command = command self._args = args self.args = IRCArgs(args) - self.prefix = prefix + self.source = source self.tags = {} if tags == None else tags def __repr__(self): @@ -69,8 +69,8 @@ class ParsedLine(object): if self.tags: pieces.append(self._tag_str(self.tags)) - if self.prefix: - pieces.append(str(self.prefix)) + if self.source: + pieces.append(str(self.source)) pieces.append(self.command.upper()) diff --git a/src/utils/irc/__init__.py b/src/utils/irc/__init__.py index 5a6fb69b..9577bcc1 100644 --- a/src/utils/irc/__init__.py +++ b/src/utils/irc/__init__.py @@ -45,7 +45,7 @@ def message_tag_unescape(s): def parse_line(line: str) -> IRCLine.ParsedLine: tags = {} # type: typing.Dict[str, typing.Any] - prefix = None # type: typing.Optional[IRCLine.Hostmask] + source = None # type: typing.Optional[IRCLine.Hostmask] command = None if line[0] == "@": @@ -65,8 +65,8 @@ def parse_line(line: str) -> IRCLine.ParsedLine: trailing = trailing_split if line[0] == ":": - prefix_str, line = line[1:].split(" ", 1) - prefix = seperate_hostmask(prefix_str) + source_str, line = line[1:].split(" ", 1) + source = seperate_hostmask(source_str) command, sep, line = line.partition(" ") args = [] # type: typing.List[str] @@ -77,7 +77,7 @@ def parse_line(line: str) -> IRCLine.ParsedLine: if not trailing == None: args.append(typing.cast(str, trailing)) - return IRCLine.ParsedLine(command, args, prefix, tags) + return IRCLine.ParsedLine(command, args, source, tags) REGEX_COLOR = re.compile("%s(?:(\d{1,2})(?:,(\d{1,2}))?)?" % utils.consts.COLOR)