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
7d6b6d32
Commit
7d6b6d32
authored
Aug 23, 2016
by
Avtandil Kikabidze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed array style
parent
2822ba5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
Telegram.php
src/Telegram.php
+19
-10
No files found.
src/Telegram.php
View file @
7d6b6d32
...
@@ -13,8 +13,14 @@ namespace Longman\TelegramBot;
...
@@ -13,8 +13,14 @@ namespace Longman\TelegramBot;
define
(
'BASE_PATH'
,
__DIR__
);
define
(
'BASE_PATH'
,
__DIR__
);
define
(
'BASE_COMMANDS_PATH'
,
BASE_PATH
.
'/Commands'
);
define
(
'BASE_COMMANDS_PATH'
,
BASE_PATH
.
'/Commands'
);
use
Exception
;
use
Longman\TelegramBot\Commands\Command
;
use
Longman\TelegramBot\Entities\ServerResponse
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Exception\TelegramException
;
use
Longman\TelegramBot\Exception\TelegramException
;
use
RecursiveDirectoryIterator
;
use
RecursiveIteratorIterator
;
use
RegexIterator
;
class
Telegram
class
Telegram
{
{
...
@@ -189,9 +195,9 @@ class Telegram
...
@@ -189,9 +195,9 @@ class Telegram
foreach
(
$this
->
commands_paths
as
$path
)
{
foreach
(
$this
->
commands_paths
as
$path
)
{
try
{
try
{
//Get all "*Command.php" files
//Get all "*Command.php" files
$files
=
new
\
RegexIterator
(
$files
=
new
RegexIterator
(
new
\
RecursiveIteratorIterator
(
new
RecursiveIteratorIterator
(
new
\
RecursiveDirectoryIterator
(
$path
)
new
RecursiveDirectoryIterator
(
$path
)
),
),
'/^.+Command.php$/'
'/^.+Command.php$/'
);
);
...
@@ -208,11 +214,11 @@ class Telegram
...
@@ -208,11 +214,11 @@ class Telegram
require_once
$file
->
getPathname
();
require_once
$file
->
getPathname
();
$command_obj
=
$this
->
getCommandObject
(
$command
);
$command_obj
=
$this
->
getCommandObject
(
$command
);
if
(
$command_obj
instanceof
Command
s\Command
)
{
if
(
$command_obj
instanceof
Command
)
{
$commands
[
$command_name
]
=
$command_obj
;
$commands
[
$command_name
]
=
$command_obj
;
}
}
}
}
}
catch
(
\
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
throw
new
TelegramException
(
'Error getting commands from path: '
.
$path
);
throw
new
TelegramException
(
'Error getting commands from path: '
.
$path
);
}
}
}
}
...
@@ -287,10 +293,13 @@ class Telegram
...
@@ -287,10 +293,13 @@ class Telegram
public
function
handleGetUpdates
(
$limit
=
null
,
$timeout
=
null
)
public
function
handleGetUpdates
(
$limit
=
null
,
$timeout
=
null
)
{
{
if
(
!
DB
::
isDbConnected
())
{
if
(
!
DB
::
isDbConnected
())
{
return
new
Entities\ServerResponse
([
return
new
ServerResponse
(
'ok'
=>
false
,
[
'description'
=>
'getUpdates needs MySQL connection!'
,
'ok'
=>
false
,
],
$this
->
bot_name
);
'description'
=>
'getUpdates needs MySQL connection!'
,
],
$this
->
bot_name
);
}
}
//DB Query
//DB Query
...
@@ -307,7 +316,7 @@ class Telegram
...
@@ -307,7 +316,7 @@ class Telegram
if
(
$response
->
isOk
())
{
if
(
$response
->
isOk
())
{
//Process all updates
//Process all updates
foreach
((
array
)
$response
->
getResult
()
as
$result
)
{
foreach
((
array
)
$response
->
getResult
()
as
$result
)
{
$this
->
processUpdate
(
$result
);
$this
->
processUpdate
(
$result
);
}
}
}
}
...
...
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