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
8a152560
Commit
8a152560
authored
Feb 26, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some fix
parent
eda8c212
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
23 deletions
+19
-23
SendtochannelCommand.php
src/Commands/AdminCommands/SendtochannelCommand.php
+8
-13
GenericmessageCommand.php
src/Commands/SystemCommands/GenericmessageCommand.php
+4
-4
Conversation.php
src/Conversation.php
+5
-5
ConversationDB.php
src/ConversationDB.php
+2
-1
No files found.
src/Commands/AdminCommands/SendtochannelCommand.php
View file @
8a152560
<?php
/*
/*
*
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
...
...
@@ -7,14 +7,15 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Commands\AdminCommands
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Conversation
;
use
Longman\TelegramBot\Commands\AdminCommand
;
use
Longman\TelegramBot\Entities\Message
;
use
Longman\TelegramBot\Entities\ReplyKeyboardHide
;
use
Longman\TelegramBot\Entities\ReplyKeyboardMarkup
;
use
Longman\TelegramBot\Commands\AdminCommand
;
class
SendtochannelCommand
extends
AdminCommand
{
...
...
@@ -33,17 +34,11 @@ class SendtochannelCommand extends AdminCommand
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat
=
$message
->
getChat
();
$user
=
$message
->
getFrom
();
$type
=
$message
->
getType
();
$chat_id
=
$chat
->
getId
();
$text
=
trim
(
$message
->
getText
(
true
));
$
user_id
=
$user
->
getId
();
$
chat_id
=
$message
->
getChat
()
->
getId
();
$user_id
=
$message
->
getFrom
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
[];
...
...
@@ -228,11 +223,11 @@ class SendtochannelCommand extends AdminCommand
* SendBack
*
* Received a message, the bot can send a copy of it to another chat/channel.
* You don't have to care about the type of the
i
message, the function detect it and use the proper
* You don't have to care about the type of the message, the function detect it and use the proper
* REQUEST:: function to send it.
* $data include all the var that you need to send the message to the prop
o
r chat
* $data include all the var that you need to send the message to the prop
e
r chat
*
* @todo This method will be moved at an higher level maybe in AdminComman
s
or Command
* @todo This method will be moved at an higher level maybe in AdminComman
d
or Command
* @todo Looking for a more significative name
*
* @param Longman\TelegramBot\Entities\Message $message
...
...
src/Commands/SystemCommands/GenericmessageCommand.php
View file @
8a152560
...
...
@@ -35,7 +35,7 @@ class GenericmessageCommand extends SystemCommand
public
function
executeNoDB
()
{
//Do nothing
return
true
;
return
new
ServerResponse
([
'ok'
=>
true
,
'result'
=>
true
],
null
)
;
}
/**
...
...
@@ -45,15 +45,15 @@ class GenericmessageCommand extends SystemCommand
*/
public
function
execute
()
{
//System command, fetch command to execute if
track
exist
//System command, fetch command to execute if
conversation
exist
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$user_id
=
$message
->
getFrom
()
->
getId
();
//Fetch
Track
if exist
//Fetch
Conversation
if exist
$command
=
(
new
Conversation
(
$user_id
,
$chat_id
))
->
getConversationCommand
();
if
(
!
is_null
(
$command
))
{
return
$this
->
telegram
->
executeCommand
(
$command
,
$this
->
update
);
}
return
true
;
return
new
ServerResponse
([
'ok'
=>
true
,
'result'
=>
true
],
null
)
;
}
}
src/Conversation.php
100644 → 100755
View file @
8a152560
...
...
@@ -95,7 +95,7 @@ class Conversation
*
* @return bool
*/
protected
function
conversationE
xist
()
protected
function
e
xist
()
{
//Conversation info already fetched
if
(
$this
->
is_fetched
)
{
...
...
@@ -136,7 +136,7 @@ class Conversation
*/
public
function
start
()
{
if
(
!
$this
->
conversationE
xist
())
{
if
(
!
$this
->
e
xist
())
{
$status
=
ConversationDB
::
insertConversation
(
$this
->
command
,
$this
->
group_name
,
$this
->
user_id
,
$this
->
chat_id
);
$this
->
is_fetched
=
true
;
}
...
...
@@ -153,7 +153,7 @@ class Conversation
public
function
update
(
$data
)
{
//Conversation must exist!
if
(
$this
->
conversationE
xist
())
{
if
(
$this
->
e
xist
())
{
$fields
[
'data'
]
=
json_encode
(
$data
);
ConversationDB
::
updateConversation
(
$fields
,
[
'chat_id'
=>
$this
->
chat_id
,
'user_id'
=>
$this
->
user_id
,
'status'
=>
'active'
]);
...
...
@@ -171,7 +171,7 @@ class Conversation
*/
public
function
stop
()
{
if
(
$this
->
conversationE
xist
())
{
if
(
$this
->
e
xist
())
{
ConversationDB
::
updateConversation
([
'status'
=>
'stopped'
],
[
'chat_id'
=>
$this
->
chat_id
,
'user_id'
=>
$this
->
user_id
,
'status'
=>
'active'
]);
}
}
...
...
@@ -183,7 +183,7 @@ class Conversation
*/
public
function
getConversationCommand
()
{
if
(
$this
->
conversationE
xist
())
{
if
(
$this
->
e
xist
())
{
return
$this
->
conversation
[
'conversation_command'
];
}
return
null
;
...
...
src/ConversationDB.php
100644 → 100755
View file @
8a152560
...
...
@@ -95,7 +95,8 @@ class ConversationDB extends DB
)
'
);
$active
=
'active'
;
$data
=
json_encode
(
''
);
//$data = json_encode('');
$data
=
'""'
;
$created_at
=
self
::
getTimestamp
();
$sth
->
bindParam
(
':status'
,
$active
);
...
...
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