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
94741e70
Unverified
Commit
94741e70
authored
Sep 23, 2017
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix "Major" issues, mainly docblock type hints.
Refactor TelegramLog a tiny bit.
parent
2ad44458
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
24 deletions
+19
-24
CHANGELOG.md
CHANGELOG.md
+3
-0
DB.php
src/DB.php
+2
-2
Message.php
src/Entities/Message.php
+3
-2
TelegramLog.php
src/TelegramLog.php
+9
-18
MessageTest.php
tests/unit/Entities/MessageTest.php
+2
-2
No files found.
CHANGELOG.md
View file @
94741e70
...
...
@@ -7,10 +7,12 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Added
-
Finish implementing payments, adding all missing type checks and docblock methods.
### Changed
-
[
:exclamation:
][
unreleased-bc-messagegetcommand-return-value
]
`Message::getCommand()`
returns
`null`
if not a command, instead of
`false`
.
### Deprecated
### Removed
### Fixed
-
SQL update script for version 0.44.1-0.45.0.
-
Issues found by Scrutinizer (Type hints and return values).
### Security
## [0.49.0] - 2017-09-17
...
...
@@ -169,6 +171,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated
-
Move
`hideKeyboard`
to
`removeKeyboard`
.
[
unreleased-bc-messagegetcommand-return-value
]:
https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#messagegetcommand-return-value
[
0.48.0-sql-migration
]:
https://github.com/php-telegram-bot/core/tree/develop/utils/db-schema-update/0.47.1-0.48.0.sql
[
0.48.0-bc-correct-printerror
]:
https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#correct-printerror
[
0.47.0-bc-private-only-admin-commands
]:
https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#private-only-admin-commands
...
...
src/DB.php
View file @
94741e70
...
...
@@ -452,7 +452,7 @@ class DB
$chat_id
=
$chat
->
getId
();
$chat_type
=
$chat
->
getType
();
if
(
$migrate_to_chat_id
)
{
if
(
$migrate_to_chat_id
!==
null
)
{
$chat_type
=
'supergroup'
;
$sth
->
bindValue
(
':id'
,
$migrate_to_chat_id
);
...
...
@@ -872,7 +872,7 @@ class DB
$sth
->
bindValue
(
':forward_date'
,
$forward_date
);
$reply_to_chat_id
=
null
;
if
(
$reply_to_message_id
)
{
if
(
$reply_to_message_id
!==
null
)
{
$reply_to_chat_id
=
$chat_id
;
}
$sth
->
bindValue
(
':reply_to_chat'
,
$reply_to_chat_id
);
...
...
src/Entities/Message.php
View file @
94741e70
...
...
@@ -190,7 +190,7 @@ class Message extends Entity
$full_command
=
$this
->
getFullCommand
();
if
(
strpos
(
$full_command
,
'/'
)
!==
0
)
{
return
false
;
return
null
;
}
$full_command
=
substr
(
$full_command
,
1
);
...
...
@@ -281,9 +281,10 @@ class Message extends Entity
'successful_payment'
,
];
$is_command
=
strlen
(
$this
->
getCommand
())
>
0
;
foreach
(
$types
as
$type
)
{
if
(
$this
->
getProperty
(
$type
))
{
if
(
$
type
===
'text'
&&
$this
->
getCommand
()
)
{
if
(
$
is_command
&&
$type
===
'text'
)
{
return
'command'
;
}
...
...
src/TelegramLog.php
View file @
94741e70
...
...
@@ -60,10 +60,7 @@ class TelegramLog
static
protected
$debug_log_temp_stream_handle
;
/**
* Initialize
*
* Initilize monolog instance. Singleton
* Is possbile provide an external monolog instance
* Initialize Monolog Logger instance, optionally passing an existing one
*
* @param \Monolog\Logger
*
...
...
@@ -76,10 +73,10 @@ class TelegramLog
self
::
$monolog
=
$external_monolog
;
foreach
(
self
::
$monolog
->
getHandlers
()
as
$handler
)
{
if
(
$handler
->
getLevel
()
===
400
)
{
if
(
method_exists
(
$handler
,
'getLevel'
)
&&
$handler
->
getLevel
()
===
400
)
{
self
::
$error_log_path
=
'true'
;
}
if
(
$handler
->
getLevel
()
===
100
)
{
if
(
method_exists
(
$handler
,
'getLevel'
)
&&
$handler
->
getLevel
()
===
100
)
{
self
::
$debug_log_path
=
'true'
;
}
}
...
...
@@ -174,9 +171,6 @@ class TelegramLog
/**
* Initialize update log
*
* Initilize monolog instance. Singleton
* Is possbile provide an external monolog instance
*
* @param string $path
*
* @return \Monolog\Logger
...
...
@@ -190,20 +184,17 @@ class TelegramLog
throw
new
TelegramLogException
(
'Empty path for update log'
);
}
self
::
$update_log_path
=
$path
;
if
(
self
::
$monolog_update
===
null
)
{
self
::
$monolog_update
=
new
Logger
(
'bot_update_log'
);
// Create a formatter
$output
=
'%message%'
.
PHP_EOL
;
$formatter
=
new
LineFormatter
(
$output
);
// Update handler
$update_handler
=
new
StreamHandler
(
self
::
$update_log_path
,
Logger
::
INFO
);
$update_handler
->
setFormatter
(
$formatter
);
self
::
$monolog_update
->
pushHandler
(
$update_handler
);
self
::
$monolog_update
->
pushHandler
(
(
new
StreamHandler
(
self
::
$update_log_path
,
Logger
::
INFO
))
->
setFormatter
(
new
LineFormatter
(
'%message%'
.
PHP_EOL
))
);
}
return
self
::
$monolog
;
return
self
::
$monolog
_update
;
}
/**
...
...
tests/unit/Entities/MessageTest.php
View file @
94741e70
...
...
@@ -30,8 +30,8 @@ class MessageTest extends TestCase
// text
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'some text'
]);
self
::
assert
Equals
(
''
,
$message
->
getFullCommand
());
self
::
assert
Equals
(
''
,
$message
->
getCommand
());
self
::
assert
Null
(
$message
->
getFullCommand
());
self
::
assert
Null
(
$message
->
getCommand
());
self
::
assertEquals
(
'some text'
,
$message
->
getText
());
self
::
assertEquals
(
'some text'
,
$message
->
getText
(
true
));
...
...
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