File tree Expand file tree Collapse file tree 8 files changed +20
-36
lines changed Expand file tree Collapse file tree 8 files changed +20
-36
lines changed Original file line number Diff line number Diff line change @@ -8,10 +8,12 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
8
8
- [ :ledger : View file changes] [ Unreleased ]
9
9
### Added
10
10
### Changed
11
+ - Small readme and code fixes / simplifications.
11
12
### Deprecated
12
13
### Removed
13
14
### Fixed
14
15
- Boolean value for Polls gets saved correctly in MySQL DB.
16
+ - Correctly use ` Request::answerInlineQuery ` in ` InlineQuery::answer ` .
15
17
### Security
16
18
17
19
## [ 0.60.0] - 2019-08-16
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ Telegram announced official support for a [Bot API](https://telegram.org/blog/bo
73
73
This Bot aims to provide a platform where one can simply write a bot and have interactions in a matter of minutes.
74
74
75
75
The Bot can:
76
- - Retrieve updates with [ webhook] [ #webhook-installation ] and [ getUpdates] [ #getupdates-installation ] methods.
76
+ - Retrieve updates with [ webhook] ( #webhook-installation ) and [ getUpdates] ( #getupdates-installation ) methods.
77
77
- Supports all types and methods according to Telegram API 4.4 (July 2019).
78
78
- Supports supergroups.
79
79
- Handle commands in chat with other bots.
Original file line number Diff line number Diff line change @@ -197,16 +197,7 @@ abstract public function execute();
197
197
*/
198
198
public function executeNoDb ()
199
199
{
200
- //Preparing message
201
- $ message = $ this ->getMessage ();
202
- $ chat_id = $ message ->getChat ()->getId ();
203
-
204
- $ data = [
205
- 'chat_id ' => $ chat_id ,
206
- 'text ' => 'Sorry no database connection, unable to execute " ' . $ this ->name . '" command. ' ,
207
- ];
208
-
209
- return Request::sendMessage ($ data );
200
+ return $ this ->replyToChat ('Sorry no database connection, unable to execute " ' . $ this ->name . '" command. ' );
210
201
}
211
202
212
203
/**
Original file line number Diff line number Diff line change 11
11
namespace Longman \TelegramBot \Commands \SystemCommands ;
12
12
13
13
use Longman \TelegramBot \Commands \SystemCommand ;
14
- use Longman \TelegramBot \Request ;
14
+ use Longman \TelegramBot \Entities \ ServerResponse ;
15
15
16
16
/**
17
17
* Callback query command
@@ -41,21 +41,24 @@ class CallbackqueryCommand extends SystemCommand
41
41
/**
42
42
* Command execute method
43
43
*
44
- * @return mixed
44
+ * @return ServerResponse
45
45
*/
46
46
public function execute ()
47
47
{
48
- //$callback_query = $this->getUpdate()-> getCallbackQuery();
48
+ //$callback_query = $this->getCallbackQuery();
49
49
//$user_id = $callback_query->getFrom()->getId();
50
50
//$query_id = $callback_query->getId();
51
51
//$query_data = $callback_query->getData();
52
52
53
+ $ answer = null ;
54
+ $ callback_query = $ this ->getCallbackQuery ();
55
+
53
56
// Call all registered callbacks.
54
57
foreach (self ::$ callbacks as $ callback ) {
55
- $ callback ($ this -> getUpdate ()-> getCallbackQuery () );
58
+ $ answer = $ callback ($ callback_query );
56
59
}
57
60
58
- return Request:: answerCallbackQuery ([ ' callback_query_id ' => $ this -> getUpdate ()-> getCallbackQuery ()-> getId ()] );
61
+ return ( $ answer instanceof ServerResponse) ? $ answer : $ callback_query -> answer ( );
59
62
}
60
63
61
64
/**
Original file line number Diff line number Diff line change 11
11
namespace Longman \TelegramBot \Commands \SystemCommands ;
12
12
13
13
use Longman \TelegramBot \Commands \SystemCommand ;
14
- use Longman \TelegramBot \Request ;
15
14
16
15
/**
17
16
* Inline query command
@@ -31,7 +30,7 @@ class InlinequeryCommand extends SystemCommand
31
30
/**
32
31
* @var string
33
32
*/
34
- protected $ version = '1.0.0 ' ;
33
+ protected $ version = '1.0.1 ' ;
35
34
36
35
/**
37
36
* Command execute method
@@ -40,10 +39,10 @@ class InlinequeryCommand extends SystemCommand
40
39
*/
41
40
public function execute ()
42
41
{
43
- //$inline_query = $this->getUpdate()-> getInlineQuery();
42
+ //$inline_query = $this->getInlineQuery();
44
43
//$user_id = $inline_query->getFrom()->getId();
45
44
//$query = $inline_query->getQuery();
46
45
47
- return Request:: answerInlineQuery ([ ' inline_query_id ' => $ this ->getUpdate ()-> getInlineQuery ()->getId () ]);
46
+ return $ this ->getInlineQuery ()->answer ([ ]);
48
47
}
49
48
}
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ protected function subEntities()
47
47
*/
48
48
public function answer (array $ results , array $ data = [])
49
49
{
50
- return Request::answerCallbackQuery (array_merge ([
50
+ return Request::answerInlineQuery (array_merge ([
51
51
'callback_query_id ' => $ this ->getId (),
52
52
'results ' => $ results ,
53
53
], $ data ));
Original file line number Diff line number Diff line change @@ -58,18 +58,7 @@ protected function subEntities()
58
58
*/
59
59
public function getUpdateType ()
60
60
{
61
- $ types = [
62
- 'message ' ,
63
- 'edited_message ' ,
64
- 'channel_post ' ,
65
- 'edited_channel_post ' ,
66
- 'inline_query ' ,
67
- 'chosen_inline_result ' ,
68
- 'callback_query ' ,
69
- 'shipping_query ' ,
70
- 'pre_checkout_query ' ,
71
- 'poll ' ,
72
- ];
61
+ $ types = array_keys ($ this ->subEntities ());
73
62
foreach ($ types as $ type ) {
74
63
if ($ this ->getProperty ($ type )) {
75
64
return $ type ;
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ class Telegram
91
91
/**
92
92
* MySQL integration
93
93
*
94
- * @var boolean
94
+ * @var bool
95
95
*/
96
96
protected $ mysql_enabled = false ;
97
97
@@ -126,7 +126,7 @@ class Telegram
126
126
/**
127
127
* Check if runCommands() is running in this session
128
128
*
129
- * @var boolean
129
+ * @var bool
130
130
*/
131
131
protected $ run_commands = false ;
132
132
@@ -494,7 +494,7 @@ public function processUpdate(Update $update)
494
494
*
495
495
* @param string $command
496
496
*
497
- * @return mixed
497
+ * @return ServerResponse
498
498
* @throws TelegramException
499
499
*/
500
500
public function executeCommand ($ command )
You can’t perform that action at this time.
0 commit comments