-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLAT-10893 Check for duplicate slash commands #195
PLAT-10893 Check for duplicate slash commands #195
Conversation
Goal of this implementation is to check when registering a new slash command that is not equal to any of the already existing ones. A slash command is considered equal when both name value and mention_bot boolean are the same.
@@ -81,3 +80,12 @@ def matches(self, context: CommandContext) -> bool: | |||
|
|||
async def on_activity(self, context: CommandContext): | |||
await self._callback(context) | |||
|
|||
def __eq__(self, o: object) -> bool: | |||
if isinstance(o, SlashCommandActivity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to check if "o" is None ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just left one comment to avoid errors when comparing None object to a command.
tests/core/activity/registry_test.py
Outdated
mention_bot = True | ||
command_name = "/command" | ||
|
||
activity_registry.slash(command_name, mention_bot)(listener) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider having two different listener instances to check we do not blindly make a reference equality check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, I missed that. Done in cd17c57
* PLAT-10782: Support of multiple bot instances (#194) * Updated poetry deps * PLAT-10782: Implemented proper handling of ackId in DatafeedLoopV2 to support multiple bot instances * Fixed pylint issues * PLAT-10893 Check for duplicate slash commands (#195) * PLAT-10893 Check for duplicate slash commands Goal of this implementation is to check when registering a new slash command that is not equal to any of the already existing ones. A slash command is considered equal when both name value and mention_bot boolean are the same. * Fixed documentation (#198) * PLAT-10868 Remove certificates and private keys credentials (#200) * PLAT-10868 Remove certificates and private keys credentials * PLAT-10895-Implement built-in help command (#197) * PLAT-10895-Implement built-in help command Goal of this PR is to provide the implementation of a build-in help command with lists all the activity registered in the ActivityRegistry. For each command found the following format will be used " - command_name - description (mention required/mention not required)" (example "/hello - command to say hello (mention required)") This help command can also be overriden by manually implementing a new SlashCommandActivity, the code will make sure that any duplicates will be removed. * PLAT-10944: passed bot service account info in RealTimeEventListener.is_accepting_event (#201) * Bumped version to 2.0b4 Co-authored-by: Mariacristina De Dominicis <65179248+symphony-mariacristina@users.noreply.github.com> Co-authored-by: symphony-youness <76746033+symphony-youness@users.noreply.github.com>
Ticket
PLAT-10893
Description
Goal of this implementation is to check when registering a new slash command that is not equal to any of the already existing ones. A slash command is considered equal when both name value and mention_bot boolean are the same.
Dependencies
List the other pull requests that should be merged before/along this one.
Checklist