Skip to content

Commit 4ed9660

Browse files
committed
ALL commands now return a ServerResponse object instead of a bool.
1 parent 4fbb6a5 commit 4ed9660

23 files changed

+59
-113
lines changed

src/Commands/AdminCommands/ChatsCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ class ChatsCommand extends AdminCommand
3131
/**#@-*/
3232

3333
/**
34-
* Execute command
35-
*
36-
* @return boolean
34+
* {@inheritdoc}
3735
*/
3836
public function execute()
3937
{
@@ -85,6 +83,6 @@ public function execute()
8583
'text' => $text,
8684
];
8785

88-
return Request::sendMessage($data)->isOk();
86+
return Request::sendMessage($data);
8987
}
9088
}

src/Commands/AdminCommands/SendtoallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ public function execute()
9595
'text' => $text,
9696
];
9797

98-
return Request::sendMessage($data)->isOk();
98+
return Request::sendMessage($data);
9999
}
100100
}

src/Commands/AdminCommands/SendtochannelCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public function execute()
5252
'text' => $text,
5353
];
5454

55-
$result = Request::sendMessage($data);
56-
if ($result->isOk()) {
55+
if (Request::sendMessage($data)->isOk()) {
5756
$text_back = 'Message sent succesfully to: ' . $your_channel;
5857
} else {
5958
$text_back = 'Sorry message not sent to: ' . $your_channel;
@@ -65,6 +64,6 @@ public function execute()
6564
'text' => $text_back,
6665
];
6766

68-
return Request::sendMessage($data)->isOk();
67+
return Request::sendMessage($data);
6968
}
7069
}

src/Commands/Command.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function setUpdate(Update $update = null)
122122
/**
123123
* Pre-execute command
124124
*
125-
* @return mixed
125+
* @return Entities\ServerResponse
126126
*/
127127
public function preExecute()
128128
{
@@ -134,13 +134,15 @@ public function preExecute()
134134

135135
/**
136136
* Execute command
137+
*
138+
* @return Entities\ServerResponse
137139
*/
138140
abstract public function execute();
139141

140142
/**
141143
* Execution if MySQL is required but not available
142144
*
143-
* @return boolean
145+
* @return Entities\ServerResponse
144146
*/
145147
public function executeNoDB()
146148
{
@@ -153,7 +155,7 @@ public function executeNoDB()
153155
'text' => 'Sorry no database connection, unable to execute "' . $this->name . '" command.',
154156
];
155157

156-
return Request::sendMessage($data)->isOk();
158+
return Request::sendMessage($data);
157159
}
158160

159161

src/Commands/SystemCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace Longman\TelegramBot\Commands;
1212

13+
use Longman\TelegramBot\Entities\ServerResponse;
14+
1315
/**
1416
* Abstract System Command Class
1517
*/
@@ -18,14 +20,14 @@ abstract class SystemCommand extends Command
1820
/**
1921
* A system command just executes
2022
*
21-
* Although system commands should just work and return 'true',
23+
* Although system commands should just work and return a successful ServerResponse,
2224
* each system command can override this method to add custom functionality.
2325
*
24-
* @return bool
26+
* @return Entities\ServerResponse
2527
*/
2628
public function execute()
2729
{
28-
//System command, do nothing
29-
return true;
30+
//System command, return successful ServerResponse
31+
return new ServerResponse(['ok' => true, 'result' => true], null);
3032
}
3133
}

src/Commands/SystemCommands/ChannelchatcreatedCommand.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ class ChannelchatcreatedCommand extends SystemCommand
2626
/**#@-*/
2727

2828
/**
29-
* Execute command
30-
*
31-
* @return boolean
29+
* {@inheritdoc}
3230
*/
33-
public function execute()
31+
/*public function execute()
3432
{
3533
//$message = $this->getMessage();
3634
//$channel_chat_created = $message->getChannelChatCreated();
37-
38-
//System command, do nothing
39-
return true;
40-
}
35+
}*/
4136
}

src/Commands/SystemCommands/ChoseninlineresultCommand.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@ class ChoseninlineresultCommand extends SystemCommand
2626
/**#@-*/
2727

2828
/**
29-
* Execute command
30-
*
31-
* @return boolean
29+
* {@inheritdoc}
3230
*/
33-
public function execute()
31+
/*public function execute()
3432
{
3533
//Information about chosen result is returned
3634
//$update = $this->getUpdate();
3735
//$inline_query = $update->getChosenInlineResult();
3836
//$query = $inline_query->getQuery();
39-
40-
//System command, do nothing
41-
return true;
42-
}
37+
}*/
4338
}

src/Commands/SystemCommands/DeletechatphotoCommand.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ class DeletechatphotoCommand extends SystemCommand
2626
/**#@-*/
2727

2828
/**
29-
* Execute command
30-
*
31-
* @return boolean
29+
* {@inheritdoc}
3230
*/
33-
public function execute()
31+
/*public function execute()
3432
{
3533
//$message = $this->getMessage();
3634
//$delete_chat_photo = $message->getDeleteChatPhoto();
37-
38-
//System command, do nothing
39-
return true;
40-
}
35+
}*/
4136
}

src/Commands/SystemCommands/GenericCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ class GenericCommand extends SystemCommand
2727
/**#@-*/
2828

2929
/**
30-
* Execute command
31-
*
32-
* @return boolean
30+
* {@inheritdoc}
3331
*/
3432
public function execute()
3533
{
@@ -44,6 +42,6 @@ public function execute()
4442
'text' => 'Command /' . $command . ' not found.. :(',
4543
];
4644

47-
return Request::sendMessage($data)->isOk();
45+
return Request::sendMessage($data);
4846
}
4947
}

src/Commands/SystemCommands/GenericmessageCommand.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@ class GenericmessageCommand extends SystemCommand
2626
/**#@-*/
2727

2828
/**
29-
* Execute command
30-
*
31-
* @return boolean
29+
* {@inheritdoc}
3230
*/
33-
public function execute()
31+
/*public function execute()
3432
{
35-
//System command, do nothing
36-
return true;
37-
}
33+
34+
}*/
3835
}

src/Commands/SystemCommands/GroupchatcreatedCommand.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ class GroupchatcreatedCommand extends SystemCommand
2626
/**#@-*/
2727

2828
/**
29-
* Execute command
30-
*
31-
* @return boolean
29+
* {@inheritdoc}
3230
*/
33-
public function execute()
31+
/*public function execute()
3432
{
3533
//$message = $this->getMessage();
3634
//$group_chat_created = $message->getGroupChatCreated();
37-
38-
//System command, do nothing
39-
return true;
40-
}
35+
}*/
4136
}

src/Commands/SystemCommands/InlinequeryCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class InlinequeryCommand extends SystemCommand
2828
/**#@-*/
2929

3030
/**
31-
* Execute command
32-
*
33-
* @return boolean
31+
* {@inheritdoc}
3432
*/
3533
public function execute()
3634
{
@@ -52,6 +50,6 @@ public function execute()
5250
}
5351
$data['results'] = '[' . implode(',', $array_article) . ']';
5452

55-
return Request::answerInlineQuery($data)->isOk();
53+
return Request::answerInlineQuery($data);
5654
}
5755
}

src/Commands/SystemCommands/LeftchatparticipantCommand.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ class LeftchatparticipantCommand extends SystemCommand
2626
/**#@-*/
2727

2828
/**
29-
* Execute command
30-
*
31-
* @return boolean
29+
* {@inheritdoc}
3230
*/
33-
public function execute()
31+
/*public function execute()
3432
{
3533
//$message = $this->getMessage();
3634
//$participant = $message->getLeftChatParticipant();
37-
38-
//System command, do nothing
39-
return true;
40-
}
35+
}*/
4136
}

src/Commands/SystemCommands/NewchatparticipantCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ class NewchatparticipantCommand extends SystemCommand
2727
/**#@-*/
2828

2929
/**
30-
* Execute command
31-
*
32-
* @return boolean
30+
* {@inheritdoc}
3331
*/
3432
public function execute()
3533
{
@@ -49,6 +47,6 @@ public function execute()
4947
'text' => $text,
5048
];
5149

52-
return Request::sendMessage($data)->isOk();
50+
return Request::sendMessage($data);
5351
}
5452
}

src/Commands/SystemCommands/NewchattitleCommand.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ class NewchattitleCommand extends SystemCommand
2626
/**#@-*/
2727

2828
/**
29-
* Execute command
30-
*
31-
* @return boolean
29+
* {@inheritdoc}
3230
*/
33-
public function execute()
31+
/*public function execute()
3432
{
3533
//$message = $this->getMessage();
3634
//$new_chat_title = $message->getNewChatTitle();
37-
38-
//System command, do nothing
39-
return true;
40-
}
35+
}*/
4136
}

src/Commands/SystemCommands/StartCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class StartCommand extends SystemCommand
2828
/**#@-*/
2929

3030
/**
31-
* Execute command
32-
*
33-
* @return boolean
31+
* {@inheritdoc}
3432
*/
3533
public function execute()
3634
{
@@ -44,6 +42,6 @@ public function execute()
4442
'text' => $text,
4543
];
4644

47-
return Request::sendMessage($data)->isOk();
45+
return Request::sendMessage($data);
4846
}
4947
}

src/Commands/SystemCommands/SupergroupchatcreatedCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ class SupergroupchatcreatedCommand extends SystemCommand
2727
/**#@-*/
2828

2929
/**
30-
* Execute command
31-
*
32-
* @return boolean
30+
* {@inheritdoc}
3331
*/
3432
public function execute()
3533
{
@@ -48,6 +46,6 @@ public function execute()
4846
'text' => $text,
4947
];
5048

51-
return Request::sendMessage($data)->isOk();
49+
return Request::sendMessage($data);
5250
}
5351
}

src/Commands/UserCommands/DateCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ private function request($url)
175175
}
176176

177177
/**
178-
* Execute command
179-
*
180-
* @return boolean
178+
* {@inheritdoc}
181179
*/
182180
public function execute()
183181
{
@@ -204,6 +202,6 @@ public function execute()
204202
'text' => $text,
205203
];
206204

207-
return Request::sendMessage($data)->isOk();
205+
return Request::sendMessage($data);
208206
}
209207
}

src/Commands/UserCommands/EchoCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class EchoCommand extends UserCommand
2828
/**#@-*/
2929

3030
/**
31-
* Execute command
32-
*
33-
* @return boolean
31+
* {@inheritdoc}
3432
*/
3533
public function execute()
3634
{
@@ -47,6 +45,6 @@ public function execute()
4745
'text' => $text,
4846
];
4947

50-
return Request::sendMessage($data)->isOk();
48+
return Request::sendMessage($data);
5149
}
5250
}

src/Commands/UserCommands/HelpCommand.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ class HelpCommand extends UserCommand
2828
/**#@-*/
2929

3030
/**
31-
* Execute command
32-
*
33-
* @return boolean
31+
* {@inheritdoc}
3432
*/
3533
public function execute()
3634
{
@@ -72,6 +70,6 @@ public function execute()
7270
'text' => $text,
7371
];
7472

75-
return Request::sendMessage($data)->isOk();
73+
return Request::sendMessage($data);
7674
}
7775
}

0 commit comments

Comments
 (0)