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
1131a087
Commit
1131a087
authored
Dec 26, 2016
by
Jack'lul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add editMessageText example
parent
b6f05fa4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
EditmessageCommand.php
examples/Commands/EditmessageCommand.php
+63
-0
No files found.
examples/Commands/EditmessageCommand.php
0 → 100644
View file @
1131a087
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommand
;
use
Longman\TelegramBot\Request
;
/**
* User "/editmessage" command
*/
class
EditmessageCommand
extends
UserCommand
{
/**#@+
* {@inheritdoc}
*/
protected
$name
=
'editmessage'
;
protected
$description
=
'Edit message'
;
protected
$usage
=
'/editmessage'
;
protected
$version
=
'1.0.0'
;
/**#@-*/
/**
* {@inheritdoc}
*/
public
function
execute
()
{
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$reply_to_message
=
$message
->
getReplyToMessage
();
$text
=
$message
->
getText
(
true
);
if
(
$reply_to_message
)
{
$message_to_edit
=
$reply_to_message
->
getMessageId
();
}
if
(
isset
(
$message_to_edit
)
&&
$message_to_edit
)
{
$data_edit
=
[];
$data_edit
[
'chat_id'
]
=
$chat_id
;
$data_edit
[
'message_id'
]
=
$message_to_edit
;
if
(
!
empty
(
$text
))
{
$data_edit
[
'text'
]
=
$text
;
}
else
{
$data_edit
[
'text'
]
=
"Edited message"
;
}
return
Request
::
editMessageText
(
$data_edit
);
}
else
{
$data
=
[];
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'text'
]
=
'Reply to any bot\'s message and use /'
.
$this
->
name
.
' <your text> to edit it.'
;
return
Request
::
sendMessage
(
$data
);
}
}
}
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