Skip to content

Commit

Permalink
[TASK] Ignore some commands like /serverlogin.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvlk committed Jun 4, 2017
1 parent 85675e5 commit 00487bb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pyplanet/contrib/command/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ class CommandManager(CoreContrib):
"""
The Command Manager contributed extension is a manager that controls all chat-commands in the game.
Your app needs to use this manager to register any custom commands you want to provide.
.. todo::
Write introduction.
.. warning::
Don't initiate this class yourself.
"""

def __init__(self, instance):
"""
Init manager.
:param instance: Controller Instance
:type instance: pyplanet.core.instance.Instance
"""
Expand All @@ -43,8 +43,8 @@ async def on_start(self, **kwargs):
async def register(self, *commands):
"""
Register your command.
:param commands: Command instance.
:param commands: Command instance.
:type commands: pyplanet.contrib.command.command.Command
"""
self._commands.extend(commands)
Expand All @@ -62,6 +62,10 @@ async def _on_chat(self, player, text, cmd, **kwargs):
# Replace the / in the first part.
argv[0] = argv[0][1:]

# Check if we need to ignore the command.
if len(argv) > 0 and argv[0] in ['serverlogin']:
return

# Try to match the command prefix by one of the registered commands.
command = None
for cmd in self._commands:
Expand Down

0 comments on commit 00487bb

Please sign in to comment.