summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Yu <andrew@andrewyu.org>2022-08-11 22:55:54 +0800
committerAndrew Yu <andrew@andrewyu.org>2022-08-11 22:55:54 +0800
commit5d4355bf5423a5bf4afe64659e92243f852caab2 (patch)
tree135b3386731da782e1aebd99a82a0a010d895676
parent10d757ec85a5913c4f1e2e16d332c5c7a2309960 (diff)
downloadirc-mod-bot-5d4355bf5423a5bf4afe64659e92243f852caab2.tar.gz
irc-mod-bot-5d4355bf5423a5bf4afe64659e92243f852caab2.zip
Fix some bugs in kickban
-rw-r--r--bot.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/bot.py b/bot.py
index 1f7c626..442623a 100644
--- a/bot.py
+++ b/bot.py
@@ -504,7 +504,7 @@ def handle_privmsg(
print(repr(users))
reply(s, msg, b"I dumped my channel and user database to standard output.")
return
- elif chat_command[0] == b"kb":
+ elif chat_command[0] == b"BAN":
if not channel:
reply(s, msg, b"You may only do this in a channel.")
return
@@ -534,7 +534,7 @@ def handle_privmsg(
send(s, b"MODE", channel.name, b"+b", kickban_string)
i: int = 0
for potential_target in channel.users:
- assert potential_target.nick and potential_target.ident and potential_target.host
+ if not (potential_target.nick and potential_target.ident and potential_target.host): continue
if match_hostmask(potential_target.nick + b"!" + potential_target.ident + b"@" + potential_target.host, kickban_string):
send(s, b"KICK", channel.name, potential_target.nick)
i += 1
@@ -550,6 +550,31 @@ def handle_privmsg(
except KeyError:
reply(s, msg, b"You didn't provide a hostmask for me to kickban, so I assumed it's a nickname, but I don't know %s." % kickban_string)
return
+ elif chat_command[0] == b"FAKEOP":
+ if not channel:
+ reply(s, msg, b"You may only do this in a channel.")
+ return
+ elif msg.source not in channel.users:
+ reply(
+ s,
+ msg,
+ b"You are not on the channel, and you're haxsending messages to it. This isn't nice.",
+ )
+ return
+ priv = is_admin(msg.source)
+ if not priv:
+ reply(s, msg, b"Access denied.")
+ return
+ elif not me in channel.ops:
+ channel.ops.append(me)
+ reply(
+ s,
+ msg,
+ b"I didn't think that I was a channel operator before, now I assume so.",
+ )
+ return
+ else:
+ reply(s, msg, b"No need!")
elif chat_command[0] == b"OP":
if not channel:
reply(s, msg, b"You may only do this in a channel.")