only query missing list modes on MODE when we're seen ENDOFWHO

This commit is contained in:
jesopo 2020-01-23 12:09:45 +00:00
parent 9ac2fe96fe
commit cded6b6877
4 changed files with 26 additions and 13 deletions

View file

@ -22,6 +22,7 @@ class Channel(IRCObject.Object):
self.user_modes = {} # type: typing.Dict[IRCUser.User, typing.Set] self.user_modes = {} # type: typing.Dict[IRCUser.User, typing.Set]
self.created_timestamp = None self.created_timestamp = None
self.buffer = IRCBuffer.Buffer(bot, server) self.buffer = IRCBuffer.Buffer(bot, server)
self.seen_who = False
self._setting_cache_prefix = "channelsetting%s-" % self.id self._setting_cache_prefix = "channelsetting%s-" % self.id

View file

@ -216,15 +216,20 @@ class Module(ModuleManager.BaseModule):
user.account(self.events, event) user.account(self.events, event)
# response to a WHO command for user information # response to a WHO command for user information
@utils.hook("raw.received.352", default_event=True) @utils.hook("raw.received.352")
def handle_352(self, event): def handle_352(self, event):
core.handle_352(self.events, event) core.handle_352(self.events, event)
# response to a WHOX command for user information, including account name # response to a WHOX command for user information, including account name
@utils.hook("raw.received.354", default_event=True) @utils.hook("raw.received.354")
def handle_354(self, event): def handle_354(self, event):
core.handle_354(self.events, event) core.handle_354(self.events, event)
# RPLENDOFWHO
@utils.hook("raw.received.315")
def handle_315(self, event):
core.handle_315(self.events, event)
# response to an empty mode command # response to an empty mode command
@utils.hook("raw.received.324") @utils.hook("raw.received.324")
def handle_324(self, event): def handle_324(self, event):

View file

@ -150,6 +150,14 @@ def handle_354(events, event):
events.on("received.whox").call(server=event["server"], events.on("received.whox").call(server=event["server"],
user=target) user=target)
def handle_315(events, event):
target = event["line"].args[1]
if target in event["server"].channels:
channel = event["server"].channels.get(target)
events.on("received.endofwho").call(server=event["server"],
channel=channel)
channel.seen_who = True
def _nick_in_use(server): def _nick_in_use(server):
new_nick = "%s|" % server.connection_params.nickname new_nick = "%s|" % server.connection_params.nickname
server.send_nick(new_nick) server.send_nick(new_nick)

View file

@ -75,19 +75,18 @@ class Module(ModuleManager.BaseModule):
self._mask_add(event["channel"], mode[1], arg) self._mask_add(event["channel"], mode[1], arg)
else: else:
self._mask_remove(event["channel"], mode[1], arg) self._mask_remove(event["channel"], mode[1], arg)
elif mode[1] in dict(event["server"].prefix_modes):
if (event["server"].irc_equals(event["server"].nickname, arg)
and event["channel"].seen_who):
self._query_lists(event["server"], event["channel"])
@utils.hook("received.315")
def who_end(self, event):
channel = self._channel(event)
if channel: def _query_lists(self, server, channel):
missed = set(event["server"].channel_list_modes)-set( seen = set(k.lstrip("~") for k in channel.mode_lists.keys())
channel.mode_lists.keys()) missing = set(server.channel_list_modes)-seen
if missed: if missing:
channel.send_mode("+%s" % "".join(missed)) channel.send_mode("+%s" % "".join(missing))
@utils.hook("self.join") @utils.hook("self.join")
def self_join(self, event): def self_join(self, event):
event["channel"].send_mode("+%s" % self._query_lists(event["server"], event["channel"])
"".join(event["server"].channel_list_modes))