Fix devoicing and unquieting on connect
This wasn't working before, because the mode checking was wrong. Furthermore, there may have been some race conditions; this was mitigated by an earlier commit, which allowed delaying some channel handling operations.
This commit is contained in:
parent
c6864dd7e7
commit
dbb8a1fc82
@ -160,10 +160,10 @@ def connect_callback():
|
|||||||
var.ACCOUNTS_ONLY = False
|
var.ACCOUNTS_ONLY = False
|
||||||
|
|
||||||
# Devoice all on connect
|
# Devoice all on connect
|
||||||
prefix = "-" + hooks.Features["PREFIX"]["+"]
|
mode = hooks.Features["PREFIX"]["+"]
|
||||||
pending = []
|
pending = []
|
||||||
for user in channels.Main.modes.get(prefix, ()):
|
for user in channels.Main.modes.get(mode, ()):
|
||||||
pending.append((prefix, user.nick))
|
pending.append(("-" + mode, user.nick))
|
||||||
accumulator.send(pending)
|
accumulator.send(pending)
|
||||||
next(accumulator, None)
|
next(accumulator, None)
|
||||||
|
|
||||||
@ -189,8 +189,16 @@ def connect_callback():
|
|||||||
|
|
||||||
events.remove_listener("end_listmode", end_listmode)
|
events.remove_listener("end_listmode", end_listmode)
|
||||||
|
|
||||||
|
def mode_change(event, var, actor, target):
|
||||||
|
if target is channels.Main: # we may or may not be opped; assume we are
|
||||||
|
accumulator.send([])
|
||||||
|
next(accumulator, None)
|
||||||
|
|
||||||
|
events.remove_listener("mode_change", mode_change)
|
||||||
|
|
||||||
events.add_listener("who_end", who_end)
|
events.add_listener("who_end", who_end)
|
||||||
events.add_listener("end_listmode", end_listmode)
|
events.add_listener("end_listmode", end_listmode)
|
||||||
|
events.add_listener("mode_change", mode_change)
|
||||||
|
|
||||||
def accumulate_cmodes(count):
|
def accumulate_cmodes(count):
|
||||||
modes = []
|
modes = []
|
||||||
@ -199,9 +207,10 @@ def connect_callback():
|
|||||||
modes.extend(item)
|
modes.extend(item)
|
||||||
yield i
|
yield i
|
||||||
|
|
||||||
channels.Main.mode(*modes)
|
if modes:
|
||||||
|
channels.Main.mode(*modes)
|
||||||
|
|
||||||
accumulator = accumulate_cmodes(2)
|
accumulator = accumulate_cmodes(3)
|
||||||
accumulator.send(None)
|
accumulator.send(None)
|
||||||
|
|
||||||
@hook("mode") # XXX Get rid of this when the user/channel refactor is done
|
@hook("mode") # XXX Get rid of this when the user/channel refactor is done
|
||||||
|
Loading…
Reference in New Issue
Block a user