Skip to content

Commit 695068b

Browse files
committed
Leave a channel when it is unregistered
1 parent e645932 commit 695068b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

plugins/core_misc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ def check_mode(irc_paramlist, conn, message):
3636
conn.send(out)
3737

3838

39+
@hook.irc_raw('MODE')
40+
def on_mode_change(conn, irc_paramlist, message):
41+
require_reg = conn.config.get('require_registered_channels', False)
42+
chan = irc_paramlist[0]
43+
modes = irc_paramlist[1]
44+
new_modes = {}
45+
adding = True
46+
for c in modes:
47+
if c == '+':
48+
adding = True
49+
elif c == '-':
50+
adding = False
51+
else:
52+
new_modes[c] = adding
53+
54+
if chan[0] == '#' and require_reg and not new_modes.get("r", True):
55+
message("I do not stay in unregistered channels", chan)
56+
conn.part(chan)
57+
58+
3959
# Identify to NickServ (or other service)
4060
@asyncio.coroutine
4161
@hook.irc_raw('004')

0 commit comments

Comments
 (0)