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
3204a0c0
Commit
3204a0c0
authored
Dec 30, 2016
by
Armando Lüscher
Committed by
GitHub
Dec 30, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #368 from noplanman/scrutinizer_fixes
Scrutinizer fixes
parents
ad4ab40f
2036770f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
30 deletions
+34
-30
Botan.php
src/Botan.php
+3
-1
Conversation.php
src/Conversation.php
+15
-12
DB.php
src/DB.php
+1
-1
Entity.php
src/Entities/Entity.php
+2
-1
Message.php
src/Entities/Message.php
+1
-1
Request.php
src/Request.php
+3
-4
TelegramLog.php
src/TelegramLog.php
+9
-10
No files found.
src/Botan.php
View file @
3204a0c0
...
...
@@ -166,7 +166,9 @@ class Botan
}
// In case there is no from field assign id = 0
$uid
=
(
isset
(
$data
[
'from'
][
'id'
]))
?
$data
[
'from'
][
'id'
]
:
0
;
$uid
=
isset
(
$data
[
'from'
][
'id'
])
?
$data
[
'from'
][
'id'
]
:
0
;
$result
=
null
;
try
{
$response
=
self
::
$client
->
post
(
...
...
src/Conversation.php
View file @
3204a0c0
...
...
@@ -21,23 +21,23 @@ class Conversation
/**
* All information fetched from the database
*
* @var array
* @var array
|null
*/
protected
$conversation
=
null
;
protected
$conversation
;
/**
* Notes stored inside the conversation
*
* @var
array
* @var
mixed
*/
protected
$protected_notes
=
null
;
protected
$protected_notes
;
/**
* Notes to be stored
*
* @var
array
* @var
mixed
*/
public
$notes
=
null
;
public
$notes
;
/**
* Telegram user id
...
...
@@ -66,6 +66,8 @@ class Conversation
* @param int $user_id
* @param int $chat_id
* @param string $command
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
__construct
(
$user_id
,
$chat_id
,
$command
=
null
)
{
...
...
@@ -98,10 +100,10 @@ class Conversation
* Load the conversation from the database
*
* @return bool
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
protected
function
load
()
{
//Select an active conversation
$conversation
=
ConversationDB
::
selectConversation
(
$this
->
user_id
,
$this
->
chat_id
,
1
);
if
(
isset
(
$conversation
[
0
]))
{
...
...
@@ -138,18 +140,19 @@ class Conversation
* Start a new conversation if the current command doesn't have one yet
*
* @return bool
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
protected
function
start
()
{
if
(
!
$this
->
exists
()
&&
$this
->
command
)
{
if
(
ConversationDB
::
insertConversation
(
if
(
$this
->
command
&&
!
$this
->
exists
()
&&
ConversationDB
::
insertConversation
(
$this
->
user_id
,
$this
->
chat_id
,
$this
->
command
)
)
{
return
$this
->
load
();
}
)
{
return
$this
->
load
();
}
return
false
;
...
...
src/DB.php
View file @
3204a0c0
...
...
@@ -116,7 +116,7 @@ class DB
self
::
$pdo
=
$external_pdo_connection
;
self
::
$telegram
=
$telegram
;
self
::
$mysql_credentials
=
null
;
self
::
$mysql_credentials
=
[]
;
self
::
$table_prefix
=
$table_prefix
;
self
::
defineTables
();
...
...
src/Entities/Entity.php
View file @
3204a0c0
...
...
@@ -21,7 +21,8 @@ use ReflectionObject;
*
* @link https://core.telegram.org/bots/api#available-types
*
* @method array getRawData() Get the raw data passed to this entity
* @method array getRawData() Get the raw data passed to this entity
* @method string getBotName() Return the bot name passed to this entity
*/
abstract
class
Entity
{
...
...
src/Entities/Message.php
View file @
3204a0c0
...
...
@@ -182,7 +182,7 @@ class Message extends Entity
$split_cmd
=
explode
(
'@'
,
$cmd
);
if
(
isset
(
$split_cmd
[
1
]))
{
//command is followed by name check if is addressed to me
if
(
strtolower
(
$split_cmd
[
1
])
===
strtolower
(
$this
->
bot_name
))
{
if
(
strtolower
(
$split_cmd
[
1
])
===
strtolower
(
$this
->
getBotName
()
))
{
return
$split_cmd
[
0
];
}
}
else
{
...
...
src/Request.php
View file @
3204a0c0
...
...
@@ -209,17 +209,16 @@ class Request
$data
[
'reply_markup'
]
=
json_encode
(
$data
[
'reply_markup'
]);
}
$result
=
null
;
$request_params
=
self
::
setUpRequestParams
(
$data
);
$debug_handle
=
TelegramLog
::
getDebugLogTempStream
();
$request_params
[
'debug'
]
=
$debug_handle
;
$request_params
[
'debug'
]
=
TelegramLog
::
getDebugLogTempStream
();
try
{
$response
=
self
::
$client
->
post
(
'/bot'
.
self
::
$telegram
->
getApiKey
()
.
'/'
.
$action
,
$request_params
);
$result
=
(
string
)
$response
->
getBody
();
$result
=
(
string
)
$response
->
getBody
();
//Logging getUpdates Update
if
(
$action
===
'getUpdates'
)
{
...
...
src/TelegramLog.php
View file @
3204a0c0
...
...
@@ -10,10 +10,10 @@
namespace
Longman\TelegramBot
;
use
Monolog\Logger
;
use
Monolog\Handler\StreamHandler
;
use
Monolog\Formatter\LineFormatter
;
use
Longman\TelegramBot\Exception\TelegramLogException
;
use
Monolog\Formatter\LineFormatter
;
use
Monolog\Handler\StreamHandler
;
use
Monolog\Logger
;
class
TelegramLog
{
...
...
@@ -55,7 +55,7 @@ class TelegramLog
/**
* Temporary stream handle for debug log
*
* @var null
* @var
resource|
null
*/
static
protected
$debug_log_temp_stream_handle
;
...
...
@@ -77,10 +77,10 @@ class TelegramLog
foreach
(
self
::
$monolog
->
getHandlers
()
as
$handler
)
{
if
(
$handler
->
getLevel
()
===
400
)
{
self
::
$error_log_path
=
true
;
self
::
$error_log_path
=
'true'
;
}
if
(
$handler
->
getLevel
()
===
100
)
{
self
::
$debug_log_path
=
true
;
self
::
$debug_log_path
=
'true'
;
}
}
}
else
{
...
...
@@ -147,11 +147,10 @@ class TelegramLog
public
static
function
getDebugLogTempStream
()
{
if
(
self
::
$debug_log_temp_stream_handle
===
null
)
{
if
(
self
::
isDebugLogActive
())
{
self
::
$debug_log_temp_stream_handle
=
fopen
(
'php://temp'
,
'w+'
);
}
else
{
if
(
!
self
::
isDebugLogActive
())
{
return
false
;
}
self
::
$debug_log_temp_stream_handle
=
fopen
(
'php://temp'
,
'w+b'
);
}
return
self
::
$debug_log_temp_stream_handle
;
...
...
@@ -164,7 +163,7 @@ class TelegramLog
*/
public
static
function
endDebugLogTempStream
(
$message
=
'%s'
)
{
if
(
self
::
$debug_log_temp_stream_handle
!==
null
)
{
if
(
is_resource
(
self
::
$debug_log_temp_stream_handle
)
)
{
rewind
(
self
::
$debug_log_temp_stream_handle
);
self
::
debug
(
sprintf
(
...
...
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