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
597fcd2f
Unverified
Commit
597fcd2f
authored
Sep 17, 2017
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further simplification of code snippets.
parent
beae90ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
26 deletions
+15
-26
Message.php
src/Entities/Message.php
+10
-11
StickerSet.php
src/Entities/StickerSet.php
+5
-15
No files found.
src/Entities/Message.php
View file @
597fcd2f
...
...
@@ -162,7 +162,8 @@ class Message extends Entity
if
(
strpos
(
$text
,
'/'
)
!==
0
)
{
return
null
;
}
$no_EOL
=
strtok
(
$text
,
PHP_EOL
);
$no_EOL
=
strtok
(
$text
,
PHP_EOL
);
$no_space
=
strtok
(
$text
,
' '
);
//try to understand which separator \n or space divide /command from text
...
...
@@ -176,30 +177,28 @@ class Message extends Entity
*/
public
function
getCommand
()
{
$command
=
$this
->
getProperty
(
'command'
);
if
(
!
empty
(
$command
))
{
if
(
$command
=
$this
->
getProperty
(
'command'
))
{
return
$command
;
}
$full_command
=
$this
->
getFullCommand
();
if
(
strpos
(
$full_command
,
'/'
)
!==
0
)
{
return
false
;
}
$full_command
=
substr
(
$full_command
,
1
);
//check if command is follow
by bot
name
//check if command is follow
ed by bot user
name
$split_cmd
=
explode
(
'@'
,
$full_command
);
if
(
isset
(
$split_cmd
[
1
]))
{
//command is followed by name check if is addressed to me
if
(
strtolower
(
$split_cmd
[
1
])
===
strtolower
(
$this
->
getBotUsername
()))
{
return
$split_cmd
[
0
];
}
}
else
{
if
(
!
isset
(
$split_cmd
[
1
]))
{
//command is not followed by name
return
$full_command
;
}
if
(
strtolower
(
$split_cmd
[
1
])
===
strtolower
(
$this
->
getBotUsername
()))
{
//command is addressed to me
return
$split_cmd
[
0
];
}
return
false
;
}
...
...
src/Entities/StickerSet.php
View file @
597fcd2f
...
...
@@ -24,25 +24,15 @@ class StickerSet extends Entity
/**
* List of all set stickers
*
* This method overrides the default getStickers method and returns a nice array
* This method overrides the default getStickers method
* and returns a nice array of Sticker objects.
*
* @return Sticker[]
* @return
null|
Sticker[]
*/
public
function
getStickers
()
{
$all_stickers
=
[];
$these_stickers
=
$this
->
getProperty
(
'stickers'
)
if
(
!
$these_stickers
)
{
return
[];
}
foreach
(
$these_stickers
as
$stickers
)
{
$new_stickers
=
[];
foreach
(
$stickers
as
$sticker
)
{
$new_stickers
[]
=
new
Sticker
(
$sticker
);
}
$all_stickers
[]
=
$new_stickers
;
}
$pretty_array
=
$this
->
makePrettyObjectArray
(
Sticker
::
class
,
'stickers'
);
return
$all_stickers
;
return
empty
(
$pretty_array
)
?
null
:
$pretty_array
;
}
}
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