Skip to content
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

<update> object and message is wrong for CustomCommand #1383

Closed
uspilot opened this issue Feb 18, 2023 · 4 comments
Closed

<update> object and message is wrong for CustomCommand #1383

uspilot opened this issue Feb 18, 2023 · 4 comments
Labels

Comments

@uspilot
Copy link
Contributor

uspilot commented Feb 18, 2023

🐞 Bug Report

<--
❗ NEVER put your Telegram API key or any other private details here. (like passwords, user IDs, etc.)
Substitute them like <API_KEY> or <USER_ID> etc.
-->

Required Information

? !
Operating system Name and version
PHP Telegram Bot version 0.80.0
PHP version 8.1.7
MySQL version 5.5.52
Update Method getUpdates
Self-signed certificate no
RAW update (if available) {...}

Summary

CustomCommand doesn't get new Update. CustomCommand always use the first update that has been received

Current behaviour

How to reproduce

Use any CustomCommand and check object

Expected behaviour

object must be current

@uspilot uspilot added the bug label Feb 18, 2023
@uspilot
Copy link
Contributor Author

uspilot commented Feb 18, 2023

The solution I used for me is:

telegram.php -> executeCommand function

        $this->last_command_response = $command_obj->setUpdate($this->update)->preExecute();

@noplanman
Copy link
Member

Thanks for bringing this up @uspilot

This is definitely a breaking change, as it changes the way the Update object may have been used in users' projects.

Would you be able to share more about your use-case for this?

@uspilot
Copy link
Contributor Author

uspilot commented Feb 21, 2023

I did some censor bot which should delete messages from group chats according to defined rules.

So, the GeneralmessageCommand class is used by default to deal with messages. Once this class is created at the first time it receives an Update object. On any later use of this class the pointer to this class has been returned without updating an Update object inside this class. So in fact you have a pointer to the class with Update object which has been sent to this class at the first use of it. So, you have a command class without any information about Update object you have to work with.

This bug is “not visible” with webhook (because usually you have just one instance of some command class for each update ), but is essential for getUpdate connection to telegram when you use the same instance of class (in my case GeneralmessageClass) for several updates

@TiiFuchs
Copy link
Member

This is solved by #1384, hopefully there will be a release soon... Stay tuned.

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

No branches or pull requests

3 participants