aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-04-15 14:41:09 +0100
committerGravatar jesopo2019-04-15 14:41:09 +0100
commite12ad21c1a0197bea8368e9d193e07b3ef4425b6 (patch)
tree98f7d8480d0d80f49d317cb70e4aafe988984848 /modules
parentSupport continuous alias arg replacements (e.g. "index 1 onwards" using "$1-") (diff)
signature
Add/remove people from channels before received.join/received.part events
Diffstat (limited to 'modules')
-rw-r--r--modules/line_handler/channel.py27
-rw-r--r--modules/permissions/__init__.py2
2 files changed, 17 insertions, 12 deletions
diff --git a/modules/line_handler/channel.py b/modules/line_handler/channel.py
index 6bb031f0..0feedf74 100644
--- a/modules/line_handler/channel.py
+++ b/modules/line_handler/channel.py
@@ -74,38 +74,43 @@ def join(events, event):
if realname:
user.realname = realname
- if event["server"].is_own_nickname(event["prefix"].nickname):
+ is_self = event["server"].is_own_nickname(event["prefix"].nickname)
+ if is_self:
channel = event["server"].channels.add(channel_name)
+ else:
+ channel = event["server"].channels.get(channel_name)
+
+
+ channel.add_user(user)
+ user.join_channel(channel)
+
+ if is_self:
if channel.name in event["server"].attempted_join:
del event["server"].attempted_join[channel.name]
events.on("self.join").call(channel=channel, server=event["server"],
account=account, realname=realname)
channel.send_mode()
else:
- channel = event["server"].channels.get(channel_name)
events.on("received.join").call(channel=channel, user=user,
server=event["server"], account=account, realname=realname)
- channel.add_user(user)
- user.join_channel(channel)
-
def part(events, event):
channel = event["server"].channels.get(event["args"][0])
user = event["server"].get_user(event["prefix"].nickname)
reason = event["args"].get(1)
+ channel.remove_user(user)
+ user.part_channel(channel)
+ if not len(user.channels):
+ event["server"].remove_user(user)
+
if not event["server"].is_own_nickname(event["prefix"].nickname):
events.on("received.part").call(channel=channel, reason=reason,
user=user, server=event["server"])
else:
+ event["server"].channels.remove(channel)
events.on("self.part").call(channel=channel, reason=reason,
server=event["server"])
- event["server"].channels.remove(channel)
-
- channel.remove_user(user)
- user.part_channel(channel)
- if not len(user.channels):
- event["server"].remove_user(user)
def handle_324(event):
channel = event["server"].channels.get(event["args"][1])
diff --git a/modules/permissions/__init__.py b/modules/permissions/__init__.py
index e620f46f..788b44fb 100644
--- a/modules/permissions/__init__.py
+++ b/modules/permissions/__init__.py
@@ -14,7 +14,7 @@ class Module(ModuleManager.BaseModule):
@utils.hook("received.part")
def on_part(self, event):
- if len(event["user"].channels) == 1 and event["user"
+ if len(event["user"].channels) == 0 and event["user"
].identified_account_override:
event["user"].send_notice("You no longer share any channels "
"with me so you have been signed out")