Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
d7cf9dd3
Unverified
Commit
d7cf9dd3
authored
Jun 19, 2017
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Callbacks can be added to be executed when callback queries are called.
parent
e50dc960
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
CallbackqueryCommand.php
src/Commands/SystemCommands/CallbackqueryCommand.php
+20
-0
No files found.
CHANGELOG.md
View file @
d7cf9dd3
...
...
@@ -5,6 +5,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
## [Unreleased]
### Added
-
Callbacks can be added to be executed when callback queries are called.
### Changed
### Deprecated
### Removed
...
...
src/Commands/SystemCommands/CallbackqueryCommand.php
View file @
d7cf9dd3
...
...
@@ -18,6 +18,11 @@ use Longman\TelegramBot\Request;
*/
class
CallbackqueryCommand
extends
SystemCommand
{
/**
* @var callable[]
*/
protected
static
$callbacks
=
[];
/**
* @var string
*/
...
...
@@ -46,6 +51,21 @@ class CallbackqueryCommand extends SystemCommand
//$query_id = $callback_query->getId();
//$query_data = $callback_query->getData();
// Call all registered callbacks.
foreach
(
self
::
$callbacks
as
$callback
)
{
$callback
(
$this
->
getUpdate
()
->
getCallbackQuery
());
}
return
Request
::
answerCallbackQuery
([
'callback_query_id'
=>
$this
->
getUpdate
()
->
getCallbackQuery
()
->
getId
()]);
}
/**
* Add a new callback handler for callback queries.
*
* @param $callback
*/
public
static
function
addCallbackHandler
(
$callback
)
{
self
::
$callbacks
[]
=
$callback
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment