8000 Initial commit by david-shiko · Pull Request #119 · python-telegram-bot/ptbcontrib · GitHub
[go: up one dir, main page]

Skip to content

Initial commit #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

david-shiko
Copy link
Contributor
@david-shiko david-shiko comment 8000 ed Jan 31, 2025

This module contains extended keyboard classes with extra functionality for PTB keyboards.

This is the first basic implementation, next releases will contain more advantage features.

Copy link
Member
@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thanks for the PR!
I went through the additions and left some comments and questions :)

Comment on lines 3 to 5
### This module contains extended keyboard classes with extra functionality for PTB keyboards.

### Methods is self-descriptive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### This module contains extended keyboard classes with extra functionality for PTB keyboards.
### Methods is self-descriptive.
This module contains extended keyboard classes with extra functionality for PTB keyboards.
Methods are self-descriptive.

These are no headlines :)

Comment on lines 29 to 30
if TYPE_CHECKING:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if TYPE_CHECKING:
pass

Comment on lines 33 to 35
class IExtendedInlineKeyboardMarkup(
ABC,
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class IExtendedInlineKeyboardMarkup(
ABC,
):
class IExtendedInlineKeyboardMarkup(ABC):

what does the leading "I" stand for? Can't be "inline" b/c that's already included later on :D

Also what's the purpose of providing this abstract base class? You provide exactly one implementation so you could just drop the base class. Note that you don't even make this class public as it's not declared in __init__

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"I" - Interface.
The interface is here just in case, some maintainers sometimes require them, depend on the ptbcontrlib policy :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. This reminds me of C++ style. I personally don't see much benefit of it...

):
"""Popular keyboard actions"""

class Exceptions:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the benefit of grouping the exceptions NotEnoughButtons and EmptyRowsDisallowed in the class Exceptions? and why are they defined only within the namespace of ExtendedInlineKeyboardMarkup? This makes it hard for a user to write somthing like

try:
    # foo
except NotEnoughButtons:
    # handle the exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will put it outside.

if strict:
condition = cbk == self.inline_keyboard[row_index][column_index].callback_data
else: # "in" to keep ability to match by prefix and some cbk key if need it
condition = cbk in self.inline_keyboard[row_index][column_index].callback_data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will throw an exception in case callback_data is not a string, which can be the case if arbitrary callback_data is used. Please consider handling that case or at least documenting this limitation.

"Result num of rows less that original num of rows in the keyboard."
)

def to_list(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def to_list(
def to_nested_list(

?

Comment on lines 159 to 160
keep_empty_rows: bool - keep empty rows in final keyboard if not enough buttons.
# Please create feature issue if you need it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be surprised if TG would accept this as input


### Methods is self-descriptive.

```python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you copy-pasted the abstract base class from keyboards.py. However this doesn't tell a user how to use your contribution. Please remove this snippet and instead provide examples of how you envision this contribution to be applied in an PTB-based bot. Have a look at the other contributions for inspiration.

@Bibo-Joshi Bibo-Joshi mentioned this pull request Mar 6, 2025
david-shiko added a commit to david-shiko/ptbcontrib that referenced this pull request Mar 6, 2025
@Bibo-Joshi
Copy link
Member

@david-shiko are you still interested in working on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0