Skip to content

Conversation

Bibo-Joshi
Copy link
Member

@Bibo-Joshi Bibo-Joshi commented Apr 20, 2020

Proposal implementation for a feature as discussed in #1856
Tests can be simplified, once #1724 is merged.

Closes #1859

Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

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

LGTM

@Bibo-Joshi Bibo-Joshi added this to the 13.0 milestone Jun 15, 2020
@lucasmezencio
Copy link

Hey @Bibo-Joshi could you fix the conflicts? Let's try to push this to be merged. 🙂

super(CommandHandler, self).__init__(
callback,
pass_update_queue=pass_update_queue,
pass_job_queue=pass_job_queue,
pass_user_data=pass_user_data,
pass_chat_data=pass_chat_data)

self.description = description
if self.description is not None and not 3 <= len(self.description) <= 256:
raise ValueError('Command description is not valid.')
Copy link
Member Author

Choose a reason for hiding this comment

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

I should remove this. We don't usually perform such checks as TG will just return BadRequest if invalid and more importantly, the limitations might change

command. Defaults to :obj:`True`.
skip_empty (:obj:`bool`, optional): Whether to skip
:class:`telegram.ext.CommandHandler` s with an empty description. If :obj:`False`,
empty descriptions will be replaced by ``Command "<command>"``.
Copy link
Member Author

Choose a reason for hiding this comment

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

Defaults to :obj:False

:class:`telegram.ext.CommandHandler` s with an empty description. If :obj:`False`,
empty descriptions will be replaced by ``Command "<command>"``.
alphabetical (:obj:`bool`, optional): Whether to sort commands by alphabetical order.
If :obj:`False`, commands are sorted in the same order, in with :meth:`add_handler`
Copy link
Member Author

Choose a reason for hiding this comment

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

with -> which

Copy link
Member Author

@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.

Need to check what happens if a command is set twice, which can quickly be the case e.g. with CommandHandler('cancel', …) as fallback for conversations

dp_bot_commands = []
for group in self.handlers:
for handler in self.handlers[group]:
if hasattr(handler, 'command') and hasattr(handler, 'description'):
Copy link
Member Author

Choose a reason for hiding this comment

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

Rather just do isinstance(handler, CommandHandler). Also we should check ConversationHandlers for CommandHandlers

@Bibo-Joshi
Copy link
Member Author

By now I'm not really confident anymore, that this is a good addition. It doesn't really save too many code lines and it probably covers only some use cases. Maybe it's better suited for an eventual contrib repo, see #1912. I'll remove from the v13 milestone for now

@Bibo-Joshi Bibo-Joshi removed this from the 13.0 milestone Aug 9, 2020
@Bibo-Joshi Bibo-Joshi closed this Sep 13, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2020
@JosXa
Copy link
Contributor

JosXa commented Sep 25, 2020

tl;dr Reasoning?

@Bibo-Joshi
Copy link
Member Author

tl;dr Reasoning?

this

@JosXa
Copy link
Contributor

JosXa commented Sep 26, 2020

tl;dr Reasoning?

this

I only see

It doesn't really save too many code lines and it probably covers only some use cases

but I would have merged that :P

@Bibo-Joshi
Copy link
Member Author

My reasoning is basically the same as why #854 got closed: There are valid use cases for this feature, but it can only ever cover a subset of the use cases. So we can merge and find ourselfes adding more and more as users want more use cases - or we don't and save the work of maintaining a very specific feature. And at least currently I prefere the latter … Mind you, I'm still very open for #1912! :)

@Bibo-Joshi Bibo-Joshi deleted the set-commands branch September 27, 2020 12:12
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 enhancement pr description: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Infere bot commands from CommandHandler and set them automatically
4 participants