core icon indicating copy to clipboard operation
core copied to clipboard

UserCommands are called on Update types with same name (PollCommand on poll Update etc.)

Open TiiFuchs opened this issue 3 years ago • 4 comments

When defining a PollCommand extends UserCommand and added via addCommandClass(),

this classes execute method is also called, when an Update of type Poll comes in.

I think on Update Types, it should check, if the registered class is extending SystemCommand.

TiiFuchs avatar Apr 11 '22 13:04 TiiFuchs

@TiiFuchs This is because of the way the commands were implemented way back when.

<UpdateType>Command classes get called when an Update comes in.

From what I recall, if you leave the $name blank, it doesn't get called. Or maybe that was only the case when a user executes it :thinking:

There are a bunch of issues open regarding the current command system, and this particular scenario has come up before I think.

noplanman avatar Apr 13 '22 08:04 noplanman

We should think about a way to solve this. I think the current behaviour as described can get pretty frustrating.

TiiFuchs avatar Apr 13 '22 09:04 TiiFuchs

Any idea?

I don't like that different Update Types call something like ...Command... It is not a Command, it should not be called that way. Maybe we can change this to ...Update or something... So when there is a new Update with type poll, it looks for a PollUpdate class, if it is an inline_query it looks for InlineQueryUpdate etc.

What do you think, @noplanman

TiiFuchs avatar Apr 14 '22 14:04 TiiFuchs

I like the idea of having dedicated <Type>Update classes to cleanly separate user commands and updates coming in from Telegram.

There are a few issues labled "code design" which are about this too.

I think we can hugely improve the whole flow of a request cycle.

noplanman avatar Apr 22 '22 07:04 noplanman