Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ convention = "pep257"
[tool.ruff.lint.pylint]
max-args = 10
max-nested-blocks = 4
max-returns = 8
17 changes: 14 additions & 3 deletions xpartamupp/modbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from simplemma.strategies.dictionaries import TrieDictionaryFactory
from slixmpp import ClientXMPP, Message
from slixmpp.exceptions import IqError
from slixmpp.jid import JID
from slixmpp.jid import JID, InvalidJID
from slixmpp.plugins.xep_0045 import MUCPresence
from sqlalchemy import create_engine, func, select, text
from sqlalchemy.dialects.sqlite.base import SQLiteDialect
Expand Down Expand Up @@ -584,7 +584,7 @@ async def _muc_check_profanity(self, msg: Message) -> None:
offending_content=msg_body,
)

async def _muc_command_message(self, msg: Message) -> None:
async def _muc_command_message(self, msg: Message) -> None: # noqa: C901
"""Process messages in the command MUC room.

Detect commands posted in the command MUC room and act on them.
Expand Down Expand Up @@ -626,7 +626,18 @@ async def _muc_command_message(self, msg: Message) -> None:
await self.send_profanity_term_list(args.lang)
return

user = JID(args.user + "@" + self.boundjid.domain)
try:
user = JID(
"".join([c for c in args.user if c.isprintable()]) + "@" + self.boundjid.domain
)
except InvalidJID:
self.send_message(
mto=self.command_room,
mbody=f'"{args.user}" is an invalid nickname.',
mtype="groupchat",
)
return

moderator = JID(moderator)
reason = " ".join(args.reason)

Expand Down
Loading