Skip to content

Commit

Permalink
Add property pressed_button
Browse files Browse the repository at this point in the history
  • Loading branch information
AlberLC committed Jun 27, 2022
1 parent afc29b5 commit 988cf2d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion multibot/models/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class ButtonsInfo(FlanaBase):
buttons: list[list[Button]] = field(default_factory=lambda: [[]])
key: Any = None

def __getitem__(self, item) -> Button:
def __getitem__(self, item) -> Button | None:
if not item:
return
if not isinstance(item, str):
raise TypeError('index has to be a string')

Expand All @@ -41,3 +43,7 @@ def checked_buttons(self) -> list[Button]:

def find_button(self, text: str) -> Button:
return self[text]

@property
def pressed_button(self) -> Button | None:
return self[self.pressed_text]

0 comments on commit 988cf2d

Please sign in to comment.