Support IRCv3's userhost-in-names

This commit is contained in:
jesopo 2018-09-04 07:11:02 +01:00
parent 3ca0230733
commit dcba6d2c6e

View file

@ -8,7 +8,8 @@ RE_CHANTYPES = re.compile(r"\bCHANTYPES=(\W+)(?:\b|$)")
RE_MODES = re.compile(r"[-+]\w+") RE_MODES = re.compile(r"[-+]\w+")
CAPABILITIES = {"message-tags", "multi-prefix", "chghost", "invite-notify", CAPABILITIES = {"message-tags", "multi-prefix", "chghost", "invite-notify",
"account-tag", "account-notify", "extended-join", "away-notify"} "account-tag", "account-notify", "extended-join", "away-notify",
"userhost-in-names"}
class LineHandler(object): class LineHandler(object):
def __init__(self, bot, events): def __init__(self, bot, events):
@ -173,12 +174,17 @@ class LineHandler(object):
).call(channel=channel, setter=nickname, set_at=topic_time, ).call(channel=channel, setter=nickname, set_at=topic_time,
server=event["server"]) server=event["server"])
# on-join user list with status symbols # /names response, also on-join user list
def handle_353(self, event): def handle_353(self, event):
channel = event["server"].get_channel(event["args"][2]) channel = event["server"].get_channel(event["args"][2])
nicknames = event["arbitrary"].split() nicknames = event["arbitrary"].split()
for nickname in nicknames: for nickname in nicknames:
if nickname.strip(): username = None
hostname = None
if "userhost-in-names" in event["server"].capabilities:
nickname, username, hostname = Utils.seperate_hostmask(
event["prefix"])
modes = set([]) modes = set([])
while nickname[0] in event["server"].mode_prefixes: while nickname[0] in event["server"].mode_prefixes:
@ -186,8 +192,12 @@ class LineHandler(object):
nickname = nickname[1:] nickname = nickname[1:]
user = event["server"].get_user(nickname) user = event["server"].get_user(nickname)
if username and hostname:
user.username = username
user.hostname = hostname
user.join_channel(channel) user.join_channel(channel)
channel.add_user(user) channel.add_user(user)
for mode in modes: for mode in modes:
channel.add_mode(mode, nickname) channel.add_mode(mode, nickname)