-
Notifications
You must be signed in to change notification settings - Fork 674
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
Enhance Update Class to Support Command Extraction from "callback_query" #1135
base: 3.x
Are you sure you want to change the base?
Conversation
- Replaced `getUpdate()->getMessage()->text` with `getUpdate()->getText()` to simplify text retrieval. - Improved `relevantMessageSubString` method to better handle different message formats and avoid potential errors.
- Updated `handler` method to handle `callback_query` updates. - Implemented command parsing for callback queries with format `/callback:::\w*`. - Maintained existing command parsing and execution for regular messages. - Ensured backward compatibility with previous command handling logic.
- Implemented `getText` method to retrieve text from various update types: - Returns message text for 'message', 'edited_message', 'channel_post', and 'edited_channel_post' types. - Returns formatted callback query data for 'callback_query' type. - Returns empty string for other types. - Updated docblocks to reflect the new method. - Maintained backward compatibility with deprecated methods.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 3.x #1135 +/- ##
============================================
- Coverage 41.95% 41.09% -0.87%
- Complexity 614 616 +2
============================================
Files 133 133
Lines 1797 1803 +6
============================================
- Hits 754 741 -13
- Misses 1043 1062 +19 ☔ View full report in Codecov by Sentry. |
- Implemented `getText` method to retrieve text from various update types: - Returns message text for 'message', 'edited_message', 'channel_post', and 'edited_channel_post' types. - Returns formatted callback query data for 'callback_query' type. - Returns empty string for other types. - Updated docblocks to reflect the new method. - Maintained backward compatibility with deprecated methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the requested changes
@@ -1,5 +1,5 @@ | |||
{ | |||
"name": "irazasyed/telegram-bot-sdk", | |||
"name": "miladkhodaverdi23/telegram-bot-sdk", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this change
@@ -3,6 +3,7 @@ | |||
namespace Telegram\Bot\Commands; | |||
|
|||
use Illuminate\Support\Collection; | |||
use Mockery\Exception; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong import
* @method static bool editForumTopic(array $params) | ||
* @method static bool closeForumTopic(array $params) | ||
* @method static bool reopenForumTopic(array $params) | ||
* @method static bool deleteForumTopic(array $params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these removed?
@@ -2,7 +2,6 @@ | |||
|
|||
namespace Telegram\Bot\Methods; | |||
|
|||
use Illuminate\Support\Arr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this removed? It's in use.
This pull request introduces a new feature to the Update class in the Telegram Bot SDK, allowing for the extraction of commands from
callback_query
updates. The enhancement adds agetText
method that processes and retrieves command strings fromcallback queries
, improving command handling efficiency.Changes
New
getText
Method: Added to the Update class to handle command extraction fromcallback_query
updates.Usage:
Example Keyboard
You can use inline keyboards to send callback queries:
Example Command Usage
Command class utilizing the new feature:
Please review the changes and provide any feedback or suggestions.
Thank you!