Fire part/quit event before removing user from channels
Before, strong refs ensured that the user stayed "alive" but now we remove user instances when they leave the last channel. As such, fire the event before removing them from channels so the user instance is still in our overall user set.
This commit is contained in:
parent
b631f75499
commit
29d8423b25
15
src/hooks.py
15
src/hooks.py
@ -554,14 +554,13 @@ def part_chan(cli, rawnick, chan, reason=""):
|
||||
|
||||
ch = channels.add(chan, cli)
|
||||
user = users._add(cli, nick=rawnick) # FIXME
|
||||
Event("chan_part", {}).dispatch(var, ch, user, reason)
|
||||
|
||||
if user is users.Bot: # oh snap! we're no longer in the channel!
|
||||
ch._clear()
|
||||
else:
|
||||
ch.remove_user(user)
|
||||
|
||||
Event("chan_part", {}).dispatch(var, ch, user, reason)
|
||||
|
||||
### KICK handling
|
||||
|
||||
@hook("kick")
|
||||
@ -581,14 +580,13 @@ def kicked_from_chan(cli, rawnick, chan, target, reason):
|
||||
ch = channels.add(chan, cli)
|
||||
actor = users._add(cli, nick=rawnick) # FIXME
|
||||
user = users._add(cli, nick=target) # FIXME
|
||||
Event("chan_kick", {}).dispatch(var, ch, actor, user, reason)
|
||||
|
||||
if user is users.Bot:
|
||||
ch._clear()
|
||||
else:
|
||||
ch.remove_user(user)
|
||||
|
||||
Event("chan_kick", {}).dispatch(var, ch, actor, user, reason)
|
||||
|
||||
### QUIT handling
|
||||
|
||||
def quit(context, message=""):
|
||||
@ -613,15 +611,10 @@ def on_quit(cli, rawnick, reason):
|
||||
1 - The raw nick (nick!ident@host) of the user quitting
|
||||
2 - The reason for the quit (always present)
|
||||
|
||||
This fires off an event, after removing the user from all of their
|
||||
channels. If the user is not in a game, the event will hold the
|
||||
last reference for the user, and then it will be destroyed. If the
|
||||
user is playing, the game state will hold strong references to it,
|
||||
ensuring it's not deleted.
|
||||
|
||||
"""
|
||||
|
||||
user = users._add(cli, nick=rawnick) # FIXME
|
||||
Event("server_quit", {}).dispatch(var, user, reason)
|
||||
|
||||
for chan in set(user.channels):
|
||||
if user is users.Bot:
|
||||
@ -629,6 +622,4 @@ def on_quit(cli, rawnick, reason):
|
||||
else:
|
||||
chan.remove_user(user)
|
||||
|
||||
Event("server_quit", {}).dispatch(var, user, reason)
|
||||
|
||||
# vim: set sw=4 expandtab:
|
||||
|
Loading…
Reference in New Issue
Block a user