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
485743d8
Commit
485743d8
authored
Feb 19, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add parameter to handle() method which allows for test input.
Fix some documentation and error outputs.
parent
168e7338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
Telegram.php
src/Telegram.php
+15
-5
No files found.
src/Telegram.php
View file @
485743d8
...
...
@@ -196,12 +196,11 @@ class Telegram
foreach
(
$this
->
commands_dir
as
$dir
)
{
try
{
//Get all "*Command.php" files
(except the "Abstract*" one)
//Get all "*Command.php" files
$files
=
new
\RegexIterator
(
new
\RecursiveIteratorIterator
(
new
\RecursiveDirectoryIterator
(
$dir
)
),
//'/^(?!Abstract).+Command.php$/'
'/^.+Command.php$/'
);
...
...
@@ -424,11 +423,15 @@ class Telegram
* instead the latter return if the command has failed or not (true|false).
* We shoud use the same convention for both.
*
* @param string $custom_json Allow custom JSON string to be passed for testing
*
* @return bool
*/
public
function
handle
()
public
function
handle
(
$custom_json
=
null
)
{
$this
->
input
=
Request
::
getInput
();
//If a custom JSON string is passed, that gets priority
$this
->
input
=
$custom_json
?:
Request
::
getInput
();
if
(
empty
(
$this
->
input
))
{
throw
new
TelegramException
(
'Input is empty!'
);
}
...
...
@@ -440,6 +443,13 @@ class Telegram
return
$this
->
processUpdate
(
$update
);
}
/**
* Get the command name from the command type
*
* @param string $type
*
* @return string
*/
private
function
getCommandFromType
(
$type
)
{
return
ucfirst
(
str_replace
(
'_'
,
''
,
$type
));
...
...
@@ -594,7 +604,7 @@ class Telegram
public
function
addCommandsPath
(
$folder
,
$before
=
true
)
{
if
(
!
is_dir
(
$folder
))
{
throw
new
TelegramException
(
'Commands folder does not exist!'
);
throw
new
TelegramException
(
'Commands folder
"'
.
$folder
.
'"
does not exist!'
);
}
if
(
!
in_array
(
$folder
,
$this
->
commands_dir
))
{
if
(
$before
)
{
...
...
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