Skip to content

Commit

Permalink
v1.8.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jesopo committed Jun 3, 2019
1 parent 248772f commit ef221f4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TBD - BitBot v1.8.0
# 2019-06-03 - BitBot v1.8.0

Added:
- Module dependency system
Expand Down
2 changes: 1 addition & 1 deletion modules/line_handler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def _handle(self, server, line):
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)
Expand Down
16 changes: 8 additions & 8 deletions modules/line_handler/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -101,15 +101,15 @@ 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)
user.part_channel(channel)
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:
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions modules/line_handler/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions modules/line_handler/message.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"])
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions modules/line_handler/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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]

Expand All @@ -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)
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/IRCBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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):
Expand Down
8 changes: 4 additions & 4 deletions src/IRCLine.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def __str__(self):

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):
Expand All @@ -69,8 +69,8 @@ def format(self) -> str:
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())

Expand Down
8 changes: 4 additions & 4 deletions src/utils/irc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] == "@":
Expand All @@ -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]
Expand All @@ -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)
Expand Down

0 comments on commit ef221f4

Please sign in to comment.