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
b65d7da7
Commit
b65d7da7
authored
Feb 20, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename all "path" related variables and documentation.
Correct and complete a few docblocks.
parent
485743d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
+28
-28
Telegram.php
src/Telegram.php
+28
-28
No files found.
src/Telegram.php
View file @
b65d7da7
...
...
@@ -54,11 +54,11 @@ class Telegram
protected
$input
;
/**
* Custom commands
folder
* Custom commands
paths
*
* @var array
*/
protected
$commands_
dir
=
[];
protected
$commands_
paths
=
[];
/**
* Row custom update (json)
...
...
@@ -163,7 +163,7 @@ class Telegram
$this
->
api_key
=
$api_key
;
$this
->
bot_name
=
$bot_name
;
//Set default download and upload
dir
//Set default download and upload
path
$this
->
setDownloadPath
(
BASE_PATH
.
'/../Download'
);
$this
->
setUploadPath
(
BASE_PATH
.
'/../Upload'
);
...
...
@@ -194,12 +194,12 @@ class Telegram
{
$commands
=
[];
foreach
(
$this
->
commands_
dir
as
$dir
)
{
foreach
(
$this
->
commands_
paths
as
$path
)
{
try
{
//Get all "*Command.php" files
$files
=
new
\RegexIterator
(
new
\RecursiveIteratorIterator
(
new
\RecursiveDirectoryIterator
(
$
dir
)
new
\RecursiveDirectoryIterator
(
$
path
)
),
'/^.+Command.php$/'
);
...
...
@@ -251,7 +251,7 @@ class Telegram
}
*/
}
catch
(
\Exception
$e
)
{
throw
new
TelegramException
(
'Error getting commands from path: '
.
$
dir
);
throw
new
TelegramException
(
'Error getting commands from path: '
.
$
path
);
}
}
...
...
@@ -507,8 +507,8 @@ class Telegram
/**
* Execute /command
*
* @param string
$command
* @param \Longman\TelegramBot\Entities\
ServerResponse
$update
* @param string $command
* @param \Longman\TelegramBot\Entities\
Update
$update
*
* @return mixed
*/
...
...
@@ -597,20 +597,21 @@ class Telegram
/**
* Add custom commands path
*
* @param string $folder Custom commands path
* @param string $path Custom commands path
* @param bool $before If the path should be prepended or appended to the list
*
* @return \Longman\TelegramBot\Telegram
*/
public
function
addCommandsPath
(
$
folder
,
$before
=
true
)
public
function
addCommandsPath
(
$
path
,
$before
=
true
)
{
if
(
!
is_dir
(
$
folder
))
{
throw
new
TelegramException
(
'Commands
folder "'
.
$folder
.
'" does not exist!'
);
if
(
!
is_dir
(
$
path
))
{
throw
new
TelegramException
(
'Commands
path "'
.
$path
.
'" does not exist!'
);
}
if
(
!
in_array
(
$
folder
,
$this
->
commands_dir
))
{
if
(
!
in_array
(
$
path
,
$this
->
commands_paths
))
{
if
(
$before
)
{
array_unshift
(
$this
->
commands_
dir
,
$folder
);
array_unshift
(
$this
->
commands_
paths
,
$path
);
}
else
{
array_push
(
$this
->
commands_
dir
,
$folder
);
array_push
(
$this
->
commands_
paths
,
$path
);
}
}
return
$this
;
...
...
@@ -619,13 +620,13 @@ class Telegram
/**
* Set custom upload path
*
* @param string $
folder
Custom upload path
* @param string $
path
Custom upload path
*
* @return \Longman\TelegramBot\Telegram
*/
public
function
setUploadPath
(
$
folder
)
public
function
setUploadPath
(
$
path
)
{
$this
->
upload_path
=
$
folder
;
$this
->
upload_path
=
$
path
;
return
$this
;
}
...
...
@@ -642,13 +643,13 @@ class Telegram
/**
* Set custom download path
*
* @param string $
folder
Custom download path
* @param string $
path
Custom download path
*
* @return \Longman\TelegramBot\Telegram
*/
public
function
setDownloadPath
(
$
folder
)
public
function
setDownloadPath
(
$
path
)
{
$this
->
download_path
=
$
folder
;
$this
->
download_path
=
$
path
;
return
$this
;
}
...
...
@@ -669,24 +670,23 @@ class Telegram
* For example you can add the channel name at the command /sendtochannel
* Or you can add the api key for external service.
*
*
* @param string $command
* @param array $array
* @param string $command
* @param array $config
*
* @return \Longman\TelegramBot\Telegram
*/
public
function
setCommandConfig
(
$command
,
array
$
array
)
public
function
setCommandConfig
(
$command
,
array
$
config
)
{
$this
->
commands_config
[
$command
]
=
$
array
;
$this
->
commands_config
[
$command
]
=
$
config
;
return
$this
;
}
/**
* Get command config
*
* @param string
$command
* @param string $command
*
* @return
object
* @return
array
*/
public
function
getCommandConfig
(
$command
)
{
...
...
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