Help on TypedCommand

Please post any questions about developing your plugin here. Please use the search function before posting!
existenz
Senior Member
Posts: 111
Joined: Thu Feb 09, 2017 3:33 pm
Location: France
Contact:

Help on TypedCommand

Postby existenz » Sat Mar 25, 2017 2:26 pm

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.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Help on TypedCommand

Postby satoon101 » Sat Mar 25, 2017 2:43 pm

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):
Image
existenz
Senior Member
Posts: 111
Joined: Thu Feb 09, 2017 3:33 pm
Location: France
Contact:

Re: Help on TypedCommand

Postby existenz » Sat Mar 25, 2017 3:09 pm

Thanks :)
existenz
Senior Member
Posts: 111
Joined: Thu Feb 09, 2017 3:33 pm
Location: France
Contact:

Re: Help on TypedCommand

Postby existenz » Sat Mar 25, 2017 3:47 pm

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 ?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Help on TypedCommand

Postby satoon101 » Sun Apr 02, 2017 5:05 pm

https://github.com/Source-Python-Dev-Te ... ands.h#L57

This todo is there specifically for that issue.
Image
existenz
Senior Member
Posts: 111
Joined: Thu Feb 09, 2017 3:33 pm
Location: France
Contact:

Re: Help on TypedCommand

Postby existenz » Mon Apr 03, 2017 4:38 pm

Ok. I will wait :)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Help on TypedCommand

Postby Ayuto » Mon Apr 03, 2017 8:02 pm

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.
existenz
Senior Member
Posts: 111
Joined: Thu Feb 09, 2017 3:33 pm
Location: France
Contact:

Re: Help on TypedCommand

Postby existenz » Tue Apr 04, 2017 7:29 am

Ok thanks for your explain :).
I have same result.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 17 guests