Can't retrieve url from TypedCommand

Please post any questions about developing your plugin here. Please use the search function before posting!
pepe
Junior Member
Posts: 3
Joined: Thu Aug 12, 2021 6:03 pm

Can't retrieve url from TypedCommand

Postby pepe » Thu Aug 12, 2021 6:21 pm

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?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Can't retrieve url from TypedCommand

Postby Ayuto » Thu Aug 12, 2021 9:38 pm

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

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 37 guests