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
4ed9660b
Commit
4ed9660b
authored
Feb 21, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALL commands now return a ServerResponse object instead of a bool.
parent
4fbb6a56
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
59 additions
and
113 deletions
+59
-113
ChatsCommand.php
src/Commands/AdminCommands/ChatsCommand.php
+2
-4
SendtoallCommand.php
src/Commands/AdminCommands/SendtoallCommand.php
+1
-1
SendtochannelCommand.php
src/Commands/AdminCommands/SendtochannelCommand.php
+2
-3
Command.php
src/Commands/Command.php
+5
-3
SystemCommand.php
src/Commands/SystemCommand.php
+6
-4
ChannelchatcreatedCommand.php
src/Commands/SystemCommands/ChannelchatcreatedCommand.php
+3
-8
ChoseninlineresultCommand.php
src/Commands/SystemCommands/ChoseninlineresultCommand.php
+3
-8
DeletechatphotoCommand.php
src/Commands/SystemCommands/DeletechatphotoCommand.php
+3
-8
GenericCommand.php
src/Commands/SystemCommands/GenericCommand.php
+2
-4
GenericmessageCommand.php
src/Commands/SystemCommands/GenericmessageCommand.php
+4
-7
GroupchatcreatedCommand.php
src/Commands/SystemCommands/GroupchatcreatedCommand.php
+3
-8
InlinequeryCommand.php
src/Commands/SystemCommands/InlinequeryCommand.php
+2
-4
LeftchatparticipantCommand.php
src/Commands/SystemCommands/LeftchatparticipantCommand.php
+3
-8
NewchatparticipantCommand.php
src/Commands/SystemCommands/NewchatparticipantCommand.php
+2
-4
NewchattitleCommand.php
src/Commands/SystemCommands/NewchattitleCommand.php
+3
-8
StartCommand.php
src/Commands/SystemCommands/StartCommand.php
+2
-4
SupergroupchatcreatedCommand.php
src/Commands/SystemCommands/SupergroupchatcreatedCommand.php
+2
-4
DateCommand.php
src/Commands/UserCommands/DateCommand.php
+2
-4
EchoCommand.php
src/Commands/UserCommands/EchoCommand.php
+2
-4
HelpCommand.php
src/Commands/UserCommands/HelpCommand.php
+2
-4
SlapCommand.php
src/Commands/UserCommands/SlapCommand.php
+2
-4
WeatherCommand.php
src/Commands/UserCommands/WeatherCommand.php
+2
-4
WhoamiCommand.php
src/Commands/UserCommands/WhoamiCommand.php
+1
-3
No files found.
src/Commands/AdminCommands/ChatsCommand.php
View file @
4ed9660b
...
...
@@ -31,9 +31,7 @@ class ChatsCommand extends AdminCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -85,6 +83,6 @@ class ChatsCommand extends AdminCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/AdminCommands/SendtoallCommand.php
View file @
4ed9660b
...
...
@@ -95,6 +95,6 @@ class SendtoallCommand extends AdminCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/AdminCommands/SendtochannelCommand.php
View file @
4ed9660b
...
...
@@ -52,8 +52,7 @@ class SendtochannelCommand extends AdminCommand
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
if
(
$result
->
isOk
())
{
if
(
Request
::
sendMessage
(
$data
)
->
isOk
())
{
$text_back
=
'Message sent succesfully to: '
.
$your_channel
;
}
else
{
$text_back
=
'Sorry message not sent to: '
.
$your_channel
;
...
...
@@ -65,6 +64,6 @@ class SendtochannelCommand extends AdminCommand
'text'
=>
$text_back
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/Command.php
View file @
4ed9660b
...
...
@@ -122,7 +122,7 @@ abstract class Command
/**
* Pre-execute command
*
* @return
mixed
* @return
Entities\ServerResponse
*/
public
function
preExecute
()
{
...
...
@@ -134,13 +134,15 @@ abstract class Command
/**
* Execute command
*
* @return Entities\ServerResponse
*/
abstract
public
function
execute
();
/**
* Execution if MySQL is required but not available
*
* @return
boolean
* @return
Entities\ServerResponse
*/
public
function
executeNoDB
()
{
...
...
@@ -153,7 +155,7 @@ abstract class Command
'text'
=>
'Sorry no database connection, unable to execute "'
.
$this
->
name
.
'" command.'
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
...
...
src/Commands/SystemCommand.php
View file @
4ed9660b
...
...
@@ -10,6 +10,8 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Entities\ServerResponse
;
/**
* Abstract System Command Class
*/
...
...
@@ -18,14 +20,14 @@ abstract class SystemCommand extends Command
/**
* A system command just executes
*
* Although system commands should just work and return
'true'
,
* Although system commands should just work and return
a successful ServerResponse
,
* each system command can override this method to add custom functionality.
*
* @return
bool
* @return
Entities\ServerResponse
*/
public
function
execute
()
{
//System command,
do nothing
return
true
;
//System command,
return successful ServerResponse
return
new
ServerResponse
([
'ok'
=>
true
,
'result'
=>
true
],
null
)
;
}
}
src/Commands/SystemCommands/ChannelchatcreatedCommand.php
View file @
4ed9660b
...
...
@@ -26,16 +26,11 @@ class ChannelchatcreatedCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
/*
public function execute()
{
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
//System command, do nothing
return
true
;
}
}*/
}
src/Commands/SystemCommands/ChoseninlineresultCommand.php
View file @
4ed9660b
...
...
@@ -26,18 +26,13 @@ class ChoseninlineresultCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
/*
public function execute()
{
//Information about chosen result is returned
//$update = $this->getUpdate();
//$inline_query = $update->getChosenInlineResult();
//$query = $inline_query->getQuery();
//System command, do nothing
return
true
;
}
}*/
}
src/Commands/SystemCommands/DeletechatphotoCommand.php
View file @
4ed9660b
...
...
@@ -26,16 +26,11 @@ class DeletechatphotoCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
/*
public function execute()
{
//$message = $this->getMessage();
//$delete_chat_photo = $message->getDeleteChatPhoto();
//System command, do nothing
return
true
;
}
}*/
}
src/Commands/SystemCommands/GenericCommand.php
View file @
4ed9660b
...
...
@@ -27,9 +27,7 @@ class GenericCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -44,6 +42,6 @@ class GenericCommand extends SystemCommand
'text'
=>
'Command /'
.
$command
.
' not found.. :('
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/SystemCommands/GenericmessageCommand.php
View file @
4ed9660b
...
...
@@ -26,13 +26,10 @@ class GenericmessageCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
/*
public function execute()
{
//System command, do nothing
return
true
;
}
}*/
}
src/Commands/SystemCommands/GroupchatcreatedCommand.php
View file @
4ed9660b
...
...
@@ -26,16 +26,11 @@ class GroupchatcreatedCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
/*
public function execute()
{
//$message = $this->getMessage();
//$group_chat_created = $message->getGroupChatCreated();
//System command, do nothing
return
true
;
}
}*/
}
src/Commands/SystemCommands/InlinequeryCommand.php
View file @
4ed9660b
...
...
@@ -28,9 +28,7 @@ class InlinequeryCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -52,6 +50,6 @@ class InlinequeryCommand extends SystemCommand
}
$data
[
'results'
]
=
'['
.
implode
(
','
,
$array_article
)
.
']'
;
return
Request
::
answerInlineQuery
(
$data
)
->
isOk
()
;
return
Request
::
answerInlineQuery
(
$data
);
}
}
src/Commands/SystemCommands/LeftchatparticipantCommand.php
View file @
4ed9660b
...
...
@@ -26,16 +26,11 @@ class LeftchatparticipantCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
/*
public function execute()
{
//$message = $this->getMessage();
//$participant = $message->getLeftChatParticipant();
//System command, do nothing
return
true
;
}
}*/
}
src/Commands/SystemCommands/NewchatparticipantCommand.php
View file @
4ed9660b
...
...
@@ -27,9 +27,7 @@ class NewchatparticipantCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -49,6 +47,6 @@ class NewchatparticipantCommand extends SystemCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/SystemCommands/NewchattitleCommand.php
View file @
4ed9660b
...
...
@@ -26,16 +26,11 @@ class NewchattitleCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
/*
public function execute()
{
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
//System command, do nothing
return
true
;
}
}*/
}
src/Commands/SystemCommands/StartCommand.php
View file @
4ed9660b
...
...
@@ -28,9 +28,7 @@ class StartCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -44,6 +42,6 @@ class StartCommand extends SystemCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/SystemCommands/SupergroupchatcreatedCommand.php
View file @
4ed9660b
...
...
@@ -27,9 +27,7 @@ class SupergroupchatcreatedCommand extends SystemCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -48,6 +46,6 @@ class SupergroupchatcreatedCommand extends SystemCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/UserCommands/DateCommand.php
View file @
4ed9660b
...
...
@@ -175,9 +175,7 @@ class DateCommand extends UserCommand
}
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -204,6 +202,6 @@ class DateCommand extends UserCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/UserCommands/EchoCommand.php
View file @
4ed9660b
...
...
@@ -28,9 +28,7 @@ class EchoCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -47,6 +45,6 @@ class EchoCommand extends UserCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/UserCommands/HelpCommand.php
View file @
4ed9660b
...
...
@@ -28,9 +28,7 @@ class HelpCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -72,6 +70,6 @@ class HelpCommand extends UserCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/UserCommands/SlapCommand.php
View file @
4ed9660b
...
...
@@ -28,9 +28,7 @@ class SlapCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -55,6 +53,6 @@ class SlapCommand extends UserCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/UserCommands/WeatherCommand.php
View file @
4ed9660b
...
...
@@ -110,9 +110,7 @@ class WeatherCommand extends UserCommand
}
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
@@ -139,6 +137,6 @@ class WeatherCommand extends UserCommand
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
)
->
isOk
()
;
return
Request
::
sendMessage
(
$data
);
}
}
src/Commands/UserCommands/WhoamiCommand.php
View file @
4ed9660b
...
...
@@ -32,9 +32,7 @@ class WhoamiCommand extends UserCommand
/**#@-*/
/**
* Execute command
*
* @return boolean
* {@inheritdoc}
*/
public
function
execute
()
{
...
...
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