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
0cd6a07b
Commit
0cd6a07b
authored
May 24, 2016
by
Jack'lul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
botan integration fixes
parent
52e1ef1e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
Botan.php
src/Botan.php
+23
-3
Telegram.php
src/Telegram.php
+6
-2
No files found.
src/Botan.php
View file @
0cd6a07b
...
...
@@ -34,6 +34,11 @@ class Botan
*/
protected
static
$token
=
''
;
/**
* @var string The actual command that is going to be reported
*/
public
static
$command
=
''
;
/**
* Initilize botan
*/
...
...
@@ -47,17 +52,30 @@ class Botan
}
/**
* Track function
* Lock function to make sure only the first command is reported
* ( in case commands are calling other commands $telegram->executedCommand() )
*
* @todo Advanced integration: https://github.com/botanio/sdk#advanced-integration
* @param string $command
*/
public
static
function
lock
(
$command
=
''
)
{
if
(
empty
(
self
::
$command
))
{
self
::
$command
=
$command
;
}
}
/**
* Track function
*
* @param string $input
* @param string $command
*
* @return bool|string
* @throws TelegramException
*/
public
static
function
track
(
$input
,
$command
=
''
)
{
if
(
empty
(
self
::
$token
))
{
if
(
empty
(
self
::
$token
)
||
$command
!=
self
::
$command
)
{
return
false
;
}
...
...
@@ -129,7 +147,9 @@ class Botan
*
* @param $url
* @param $user_id
*
* @return string
* @throws TelegramException
*/
public
static
function
shortenUrl
(
$url
,
$user_id
)
{
...
...
src/Telegram.php
View file @
0cd6a07b
...
...
@@ -515,11 +515,16 @@ class Telegram
//Handle a generic command or non existing one
$this
->
last_command_response
=
$this
->
executeCommand
(
'Generic'
);
}
else
{
//Botan.io integration, make sure only the command user executed is reported
if
(
$this
->
botan_enabled
)
{
Botan
::
lock
(
$command
);
}
//execute() method is executed after preExecute()
//This is to prevent executing a DB query without a valid connection
$this
->
last_command_response
=
$command_obj
->
preExecute
();
//Botan.io integration
//Botan.io integration
, send report after executing the command
if
(
$this
->
botan_enabled
)
{
Botan
::
track
(
$this
->
update
,
$command
);
}
...
...
@@ -808,7 +813,6 @@ class Telegram
* Enable Botan.io integration
*
* @param $token
* @param $custom
* @return Telegram
*/
public
function
enableBotan
(
$token
)
...
...
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