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
6d57861d
Unverified
Commit
6d57861d
authored
Jul 03, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add flexible methods for enabling admins and adding custom commands paths.
parent
e8400d66
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
16 deletions
+47
-16
Telegram.php
src/Telegram.php
+47
-16
No files found.
src/Telegram.php
View file @
6d57861d
...
...
@@ -459,20 +459,34 @@ class Telegram
}
/**
* Enable
Admin A
ccount
* Enable
a single Admin a
ccount
*
* @param
array $admins_list List of admins
* @param
integer $admin_id Single admin id
*
* @return
string
* @return
Telegram
*/
public
function
enableAdmin
s
(
array
$admins_list
)
public
function
enableAdmin
(
$admin_id
)
{
foreach
(
$admins_list
as
$admin
)
{
if
(
$admin
>
0
)
{
$this
->
admins_list
[]
=
$admin
;
if
(
is_int
(
$admin_id
)
&&
$admin_id
>
0
&&
!
in_array
(
$admin_id
,
$this
->
admins_list
))
{
$this
->
admins_list
[]
=
$admin_id
;
}
else
{
throw
new
TelegramException
(
'Invalid value "'
.
$admin
.
'" for admin!
'
);
TelegramLog
::
error
(
'Invalid value "'
.
$admin_id
.
'" for admin.
'
);
}
return
$this
;
}
/**
* Enable a list of Admin Accounts
*
* @param array $admin_ids List of admin ids
*
* @return Telegram
*/
public
function
enableAdmins
(
array
$admin_ids
)
{
foreach
(
$admin_ids
as
$admin_id
)
{
$this
->
enableAdmin
(
$admin_id
);
}
return
$this
;
...
...
@@ -531,25 +545,42 @@ class Telegram
}
/**
* Add custom commands path
* Add
a single
custom commands path
*
* @param string $path Custom commands path
* @param string $path Custom commands path
to add
* @param bool $before If the path should be prepended or appended to the list
*
* @return
\Longman\TelegramBot\
Telegram
* @return Telegram
*/
public
function
addCommandsPath
(
$path
,
$before
=
true
)
{
if
(
!
is_dir
(
$path
))
{
throw
new
TelegramException
(
'Commands path "'
.
$path
.
'" does not exist!'
);
}
if
(
!
in_array
(
$path
,
$this
->
commands_paths
))
{
TelegramLog
::
error
(
'Commands path "'
.
$path
.
'" does not exist.'
);
}
elseif
(
!
in_array
(
$path
,
$this
->
commands_paths
))
{
if
(
$before
)
{
array_unshift
(
$this
->
commands_paths
,
$path
);
}
else
{
array_push
(
$this
->
commands_paths
,
$path
);
}
}
return
$this
;
}
/**
* Add multiple custom commands paths
*
* @param array $paths Custom commands paths to add
* @param bool $before If the paths should be prepended or appended to the list
*
* @return Telegram
*/
public
function
addCommandsPaths
(
array
$paths
,
$before
=
true
)
{
foreach
(
$paths
as
$path
)
{
$this
->
addCommandsPath
(
$path
);
}
return
$this
;
}
...
...
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