Page 1 of 1

Help on TypedCommand

Posted: Sat Mar 25, 2017 2:26 pm
by existenz
Hey !

I have some problem on TypedCommand, i don't know why it's not working.
No doubt I use it badly so i need your help xD

Working example :

Syntax: Select all

@TypedSayCommand('!say', None)
def on_add(command_info, msg:str):
SayText2('Test: {}'.format(msg)).send()


Not working example :

Syntax: Select all

@TypedSayCommand(['!say', '/say'], None)
def on_add(command_info, msg:str):
SayText2('Test: {}'.format(msg)).send()

!say Test
Show : Sub command "Test" not found.


And how can i allow space in command.

Syntax: Select all

@TypedSayCommand('!say', None)
def on_add(command_info, msg:str):
SayText2('Test: {}'.format(msg)).send()

!say Test test
Show : Too many arguments: !say<msg:str>


Sincerly Existenz.

Re: Help on TypedCommand

Posted: Sat Mar 25, 2017 2:43 pm
by satoon101
For all examples, I will say there is no need to pass in None for permissions, as that is the default value.

For your first issue, passing a list creates sub-commands. So, you are basically registering the command !say with a sub-command of /say. What you need to do is use 2 different decorators:

Syntax: Select all

@TypedSayCommand('!say')
@TypedSayCommand('/say')
def on_add(command_info):


The 2nd issue is because msg is a single argument. If you want it to encompass the rest of the string, you need to use:

Syntax: Select all

@TypedSayCommand('!say')
@TypedSayCommand('/say')
def on_add(command_info, *msg:str):

Re: Help on TypedCommand

Posted: Sat Mar 25, 2017 3:09 pm
by existenz
Thanks :)

Re: Help on TypedCommand

Posted: Sat Mar 25, 2017 3:47 pm
by existenz
I have just another problem all special character is deleter. Like : àéè.
I want to be allow to use all special character.

How i can do this ?

Re: Help on TypedCommand

Posted: Sun Apr 02, 2017 5:05 pm
by satoon101
https://github.com/Source-Python-Dev-Te ... ands.h#L57

This todo is there specifically for that issue.

Re: Help on TypedCommand

Posted: Mon Apr 03, 2017 4:38 pm
by existenz
Ok. I will wait :)

Re: Help on TypedCommand

Posted: Mon Apr 03, 2017 8:02 pm
by Ayuto
This is only one part of the issue. The main problem is that CCommand::Tokenize doesn't parse multibyte characters correctly. Somehow it splits those characters, which result in invalid bytes.

Syntax: Select all

from commands import Command

cmd = Command()
cmd.tokenize('ä 123 ä asd')
print(tuple(cmd))
print(cmd.command_string)
# ('', '', '123', '', '', 'asd')
# ä 123 ä asd

To fix this issue, we will need to implement our own parsing mechanism that has the same behaviour like the original one, but fixes this specific issue.

Re: Help on TypedCommand

Posted: Tue Apr 04, 2017 7:29 am
by existenz
Ok thanks for your explain :).
I have same result.