Page 1 of 1

Can't retrieve url from TypedCommand

Posted: Thu Aug 12, 2021 6:21 pm
by pepe
When i use TypedSayCommand i cant validate a url param because the function only receives the string until the // part
Image

Code: Select all

class Validator:
    @staticmethod
    def valid_url(value):
        regex = r"[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)"
        print(value) #   prints "https"
        is_valid = re.search(regex, value)
        if not is_valid:
            raise ValidationError("Url inválida")           
        return True

@TypedSayCommand('!trails')
def on_trails(command_info, name:str, url:Validator.valid_url):
    pass
    #print(name)
    #print(url)


i found my way around this with python but am i doing something wrong with the TypedSayCommand?

Re: Can't retrieve url from TypedCommand

Posted: Thu Aug 12, 2021 9:38 pm
by Ayuto
Hi pepe,

yes, this is a known bug caused by the engine's CCommand class. We have it on our issue list, but haven't yet implemented a fix for that.
https://github.com/Source-Python-Dev-Te ... issues/244