def __init__( self, title: TextObject, text: TextObject, confirm: TextObject, deny: TextObject, style: str = "primary", ): super().__init__(btype=None) # validate input title.validate_text_block( max_length=100, required_type=TextObject.BTYPE_PLAINTEXT ) self.title = title text.validate_text_block(max_length=300) self.text = text confirm.validate_text_block( max_length=30, required_type=TextObject.BTYPE_PLAINTEXT ) self.confirm = confirm deny.validate_text_block( max_length=30, required_type=TextObject.BTYPE_PLAINTEXT ) self.deny = deny self.style = get_validated_input( style, str, equality_fields=["danger", "primary"] )
def __init__(self, btype: str, action_id: str = None): # validate the action id self.action_id = get_validated_input(action_id, str, min_length=0, max_length=255) super().__init__(btype=btype)
def __init__( self, text: TextObject, value: str, description: TextObject = None, url: str = None, ): # validate input text.validate_text_block( max_length=self.TEXT_MAX_LENGTH, required_type=TextObject.BTYPE_PLAINTEXT ) super().__init__(btype=None) self.text = text if description: description.validate_text_block( max_length=self.TEXT_MAX_LENGTH, required_type=TextObject.BTYPE_PLAINTEXT, ) self.description = description self.value = get_validated_input(value, str, max_length=self.VALUE_MAX_LENGTH) self.url = get_validated_input(url, str, max_length=self.URL_MAX_LENGTH)
def __init__( self, btype: str, text: str, emoji: bool = False, verbatim: bool = False ): # validate that the type is correct self.btype = get_validated_input( btype, str, equality_fields=[self.BTYPE_PLAINTEXT, self.BTYPE_MARKDOWN] ) self.text = text # emoji field is only usable if the type is plain text if btype == self.BTYPE_PLAINTEXT: self.emoji = emoji # verbatim field is only usable if the type is markdown else: self.verbatim = verbatim super().__init__(btype=btype)