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
6227c407
Unverified
Commit
6227c407
authored
Apr 22, 2018
by
Avtandil Kikabidze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve config
parent
b18d216e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
3 deletions
+68
-3
Config.php
src/Config.php
+46
-2
ConfigTest.php
tests/unit/ConfigTest.php
+22
-1
No files found.
src/Config.php
View file @
6227c407
...
...
@@ -27,7 +27,7 @@ class Config extends Repository
$paths
=
$this
->
get
(
'commands.paths'
,
[]);
if
(
!
is_dir
(
$path
))
{
TelegramLog
::
error
(
'Commands path "%s" does not exist.'
,
$path
);
Logger
::
error
(
'Commands path "%s" does not exist.'
,
$path
);
}
else
if
(
!
in_array
(
$path
,
$paths
,
true
))
{
if
(
$before
)
{
array_unshift
(
$paths
,
$path
);
...
...
@@ -76,7 +76,7 @@ class Config extends Repository
$admins
=
$this
->
get
(
'admins'
,
[]);
if
(
!
is_int
(
$admin_id
)
||
$admin_id
<=
0
)
{
TelegramLog
::
error
(
'Invalid value "%s" for admin.'
,
$admin_id
);
Logger
::
error
(
'Invalid value "%s" for admin.'
,
$admin_id
);
}
else
if
(
!
in_array
(
$admin_id
,
$admins
,
true
))
{
$admins
[]
=
$admin_id
;
}
...
...
@@ -107,4 +107,48 @@ class Config extends Repository
{
return
$this
->
get
(
'admins'
,
[]);
}
/**
* Set custom upload path
*
* @param string $path Custom upload path
*
* @return void
*/
public
function
setUploadPath
(
$path
)
{
$this
->
set
(
'upload_path'
,
$path
);
}
/**
* Get custom upload path
*
* @return string
*/
public
function
getUploadPath
()
{
return
$this
->
get
(
'upload_path'
,
''
);
}
/**
* Set custom download path
*
* @param string $path Custom download path
*
* @return void
*/
public
function
setDownloadPath
(
$path
)
{
$this
->
set
(
'download_path'
,
$path
);
}
/**
* Get custom download path
*
* @return string
*/
public
function
getDownloadPath
()
{
return
$this
->
get
(
'download_path'
,
''
);
}
}
tests/unit/ConfigTest.php
View file @
6227c407
...
...
@@ -56,7 +56,7 @@ class ConfigTest extends TestCase
$this
->
assertEquals
(
$paths
,
$config
->
getCommandsPaths
());
}
public
function
testAd
dAd
mins
()
public
function
testAdmins
()
{
$config
=
new
Config
();
...
...
@@ -67,4 +67,25 @@ class ConfigTest extends TestCase
$this
->
assertEquals
(
$admins
,
$config
->
getAdmins
());
}
public
function
testUploadPath
()
{
$config
=
new
Config
();
$path
=
'/some/path'
;
$config
->
setUploadPath
(
$path
);
$this
->
assertEquals
(
$path
,
$config
->
getUploadPath
());
}
public
function
testDownloadPath
()
{
$config
=
new
Config
();
$path
=
'/some/path'
;
$config
->
setDownloadPath
(
$path
);
$this
->
assertEquals
(
$path
,
$config
->
getDownloadPath
());
}
}
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