예제 #1
0
 def __init__(
     cls,
     label: str = None,
     payload: str = None,
     link: str = None,
     hash: str = None,
     app_id: int = None,
     owner_id: int = None,
 ):
     for k, v in except_none_self(locals()).items():
         if not hasattr(cls, k):
             raise KeyboardError("Action {} cannot assign {}".format(
                 cls.__class__.__name__, k))
         setattr(cls, k, v)
     cls.type = getattr(cls, "type")
예제 #2
0
 def add_button(self, action: typing.Union[Text], color: str = None):
     if not len(self.buttons):
         raise KeyboardError("Firstly add row with keyboard.add_row()")
     button = KeyboardButton(action, color)
     self.buttons[-1].append(button)
     return button
예제 #3
0
 def add_row(self):
     if len(self.buttons) and not len(self.buttons[-1]):
         raise KeyboardError("Last row is empty!")
     self.buttons.append([])