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
87e0d1c4
Commit
87e0d1c4
authored
Aug 23, 2016
by
Avtandil Kikabidze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved code and doc-blocks
parent
c6e430a8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
37 deletions
+37
-37
Telegram.php
src/Telegram.php
+37
-37
No files found.
src/Telegram.php
View file @
87e0d1c4
...
...
@@ -16,13 +16,7 @@ define('BASE_COMMANDS_PATH', BASE_PATH . '/Commands');
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Exception\TelegramException
;
/**
* @package Telegram
* @author Avtandil Kikabidze <akalongman@gmail.com>
* @copyright Avtandil Kikabidze <akalongman@gmail.com>
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
* @link http://www.github.com/akalongman/php-telegram-bot
*/
class
Telegram
{
/**
...
...
@@ -63,7 +57,7 @@ class Telegram
/**
* Current Update object
*
* @var Entities\Update
* @var
\Longman\TelegramBot\
Entities\Update
*/
protected
$update
;
...
...
@@ -112,7 +106,7 @@ class Telegram
/**
* ServerResponse of the last Command execution
*
* @var Entities\ServerResponse
* @var
\Longman\TelegramBot\
Entities\ServerResponse
*/
protected
$last_command_response
;
...
...
@@ -124,10 +118,11 @@ class Telegram
protected
$botan_enabled
=
false
;
/**
*
Constructor
*
Telegram constructor.
*
* @param string $api_key
* @param string $bot_name
* @param $api_key
* @param $bot_name
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
__construct
(
$api_key
,
$bot_name
)
{
...
...
@@ -158,7 +153,7 @@ class Telegram
* @param array $credential
* @param string $table_prefix
*
* @return Telegram
* @return
\Longman\TelegramBot\
Telegram
*/
public
function
enableMySql
(
array
$credential
,
$table_prefix
=
null
,
$encoding
=
'utf8mb4'
)
{
...
...
@@ -185,6 +180,7 @@ class Telegram
* Get commands list
*
* @return array $commands
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
getCommandsList
()
{
...
...
@@ -211,7 +207,6 @@ class Telegram
require_once
$file
->
getPathname
();
$command_obj
=
$this
->
getCommandObject
(
$command
);
if
(
$command_obj
instanceof
Commands\Command
)
{
$commands
[
$command_name
]
=
$command_obj
;
...
...
@@ -274,7 +269,7 @@ class Telegram
/**
* Get the ServerResponse of the last Command execution
*
* @return Entities\ServerResponse
* @return
\Longman\TelegramBot\
Entities\ServerResponse
*/
public
function
getLastCommandResponse
()
{
...
...
@@ -312,7 +307,7 @@ class Telegram
if
(
$response
->
isOk
())
{
//Process all updates
foreach
((
array
)
$response
->
getResult
()
as
$result
)
{
foreach
((
array
)
$response
->
getResult
()
as
$result
)
{
$this
->
processUpdate
(
$result
);
}
}
...
...
@@ -361,9 +356,9 @@ class Telegram
/**
* Process bot Update request
*
* @param Entities\Update $update
* @param
\Longman\TelegramBot\
Entities\Update $update
*
* @return Entities\ServerResponse
* @return
\Longman\TelegramBot\
Entities\ServerResponse
*/
public
function
processUpdate
(
Update
$update
)
{
...
...
@@ -419,6 +414,7 @@ class Telegram
* @param string $command
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
executeCommand
(
$command
)
{
...
...
@@ -451,7 +447,6 @@ class Telegram
return
$this
->
last_command_response
;
}
/**
* Sanitize Command
*
...
...
@@ -469,7 +464,7 @@ class Telegram
*
* @param integer $admin_id Single admin id
*
* @return Telegram
* @return
\Longman\TelegramBot\
Telegram
*/
public
function
enableAdmin
(
$admin_id
)
{
...
...
@@ -487,7 +482,7 @@ class Telegram
*
* @param array $admin_ids List of admin ids
*
* @return Telegram
* @return
\Longman\TelegramBot\
Telegram
*/
public
function
enableAdmins
(
array
$admin_ids
)
{
...
...
@@ -556,7 +551,7 @@ class Telegram
* @param string $path Custom commands path to add
* @param bool $before If the path should be prepended or appended to the list
*
* @return Telegram
* @return
\Longman\TelegramBot\
Telegram
*/
public
function
addCommandsPath
(
$path
,
$before
=
true
)
{
...
...
@@ -579,7 +574,7 @@ class Telegram
* @param array $paths Custom commands paths to add
* @param bool $before If the paths should be prepended or appended to the list
*
* @return Telegram
* @return
\Longman\TelegramBot\
Telegram
*/
public
function
addCommandsPaths
(
array
$paths
,
$before
=
true
)
{
...
...
@@ -703,6 +698,7 @@ class Telegram
* @param string|null $path_certificate
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
setWebHook
(
$url
,
$path_certificate
=
null
)
{
...
...
@@ -724,7 +720,8 @@ class Telegram
/**
* Unset Webhook for bot
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
unsetWebHook
()
{
...
...
@@ -762,14 +759,17 @@ class Telegram
*/
protected
function
ucfirstUnicode
(
$str
,
$encoding
=
'UTF-8'
)
{
return
mb_strtoupper
(
mb_substr
(
$str
,
0
,
1
,
$encoding
),
$encoding
)
.
mb_strtolower
(
mb_substr
(
$str
,
1
,
mb_strlen
(
$str
),
$encoding
),
$encoding
);
return
mb_strtoupper
(
mb_substr
(
$str
,
0
,
1
,
$encoding
),
$encoding
)
.
mb_strtolower
(
mb_substr
(
$str
,
1
,
mb_strlen
(
$str
),
$encoding
),
$encoding
);
}
/**
* Enable Botan.io integration
*
* @param $token
* @return Telegram
* @return
\Longman\TelegramBot\
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