Skip to content

Commit

Permalink
Cowardly refuse to ban oneself with an account extban
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Jul 19, 2024
1 parent 21a3fa0 commit cadc8f9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugins/Channel/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,10 @@ def _ban(self, irc, msg, args,
if not reason:
reason = msg.nick
capability = ircdb.makeChannelCapability(channel, 'op')

# Check (again) that they're not trying to make us kickban ourself.
self_account_extban = ircutils.accountExtban(irc, irc.nick)
for banmask in banmasks:
# TODO: check account ban too
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix):
self.log.warning('%q tried to make me kban myself.',msg.prefix)
Expand All @@ -411,6 +412,13 @@ def _ban(self, irc, msg, args,
self.log.warning('Using exact hostmask since banmask would '
'ban myself.')
banmasks = [bannedHostmask]
elif self_account_extban is not None \
and banmask.lower() == self_account_extban.lower():
self.log.warning('%q tried to make me kban myself.',msg.prefix)
irc.error(_('I cowardly refuse to ban myself.'))
return


# Now, let's actually get to it. Check to make sure they have
# #channel,op and the bannee doesn't have #channel,op; or that the
# bannee and the banner are both the same person.
Expand Down

0 comments on commit cadc8f9

Please sign in to comment.