Ask for our own modes when we get a 001

This commit is contained in:
jesopo 2019-06-06 11:16:47 +01:00
parent eb7d90bb00
commit 4c6a398f53
2 changed files with 16 additions and 5 deletions

View file

@ -149,6 +149,10 @@ class Module(ModuleManager.BaseModule):
@utils.hook("raw.received.mode")
def mode(self, event):
core.mode(self.events, event)
# server telling us our own modes
@utils.hook("raw.received.221")
def umodeis(self, event):
core.handle_221(event)
# someone (maybe me!) has been invited somewhere
@utils.hook("raw.received.invite")

View file

@ -11,6 +11,7 @@ def handle_001(event):
event["server"].name = event["source"].hostmask
event["server"].set_own_nickname(event["args"][0])
event["server"].send_whois(event["server"].nickname)
event["server"].send_mode(event["server"].nickname)
event["server"].connected = True
def handle_005(events, event):
@ -64,6 +65,13 @@ def motd_start(event):
def motd_line(event):
event["server"].motd_lines.append(event["args"][1])
def _own_modes(server, modes):
mode_chunks = RE_MODES.findall(modes)
for chunk in mode_chunks:
remove = chunk[0] == "-"
for mode in chunk[1:]:
server.change_own_mode(remove, mode)
def mode(events, event):
user = event["server"].get_user(event["source"].nickname)
target = event["args"][0]
@ -88,14 +96,13 @@ def mode(events, event):
events.on("received.mode.channel").call(modes=modes, mode_args=_args,
channel=channel, server=event["server"], user=user)
elif event["server"].is_own_nickname(target):
modes = RE_MODES.findall(event["args"][1])
for chunk in modes:
remove = chunk[0] == "-"
for mode in chunk[1:]:
event["server"].change_own_mode(remove, mode)
_own_modes(event["server"], event["args"][1])
events.on("self.mode").call(modes=modes, server=event["server"])
event["server"].send_who(event["server"].nickname)
def handle_221(event):
_own_modes(event["server"], event["args"][1])
def invite(events, event):
target_channel = event["args"][1]
user = event["server"].get_user(event["source"].nickname)