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
c9e38bc5
Unverified
Commit
c9e38bc5
authored
Aug 26, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and improve System commands.
parent
e67d9b73
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
153 additions
and
61 deletions
+153
-61
CallbackqueryCommand.php
src/Commands/SystemCommands/CallbackqueryCommand.php
+7
-10
ChannelchatcreatedCommand.php
src/Commands/SystemCommands/ChannelchatcreatedCommand.php
+12
-4
ChoseninlineresultCommand.php
src/Commands/SystemCommands/ChoseninlineresultCommand.php
+11
-3
DeletechatphotoCommand.php
src/Commands/SystemCommands/DeletechatphotoCommand.php
+11
-3
EditedmessageCommand.php
src/Commands/SystemCommands/EditedmessageCommand.php
+13
-5
GenericCommand.php
src/Commands/SystemCommands/GenericCommand.php
+5
-3
GenericmessageCommand.php
src/Commands/SystemCommands/GenericmessageCommand.php
+3
-2
GroupchatcreatedCommand.php
src/Commands/SystemCommands/GroupchatcreatedCommand.php
+11
-3
InlinequeryCommand.php
src/Commands/SystemCommands/InlinequeryCommand.php
+5
-4
LeftchatmemberCommand.php
src/Commands/SystemCommands/LeftchatmemberCommand.php
+11
-3
MigratefromchatidCommand.php
src/Commands/SystemCommands/MigratefromchatidCommand.php
+11
-3
MigratetochatidCommand.php
src/Commands/SystemCommands/MigratetochatidCommand.php
+11
-3
NewchatmemberCommand.php
src/Commands/SystemCommands/NewchatmemberCommand.php
+6
-4
NewchatphotoCommand.php
src/Commands/SystemCommands/NewchatphotoCommand.php
+11
-3
NewchattitleCommand.php
src/Commands/SystemCommands/NewchattitleCommand.php
+11
-3
StartCommand.php
src/Commands/SystemCommands/StartCommand.php
+3
-2
SupergroupchatcreatedCommand.php
src/Commands/SystemCommands/SupergroupchatcreatedCommand.php
+11
-3
No files found.
src/Commands/SystemCommands/CallbackqueryCommand.php
View file @
c9e38bc5
...
...
@@ -31,12 +31,13 @@ class CallbackqueryCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0
.0'
;
protected
$version
=
'1.
1
.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
...
...
@@ -45,15 +46,11 @@ class CallbackqueryCommand extends SystemCommand
$callback_query_id
=
$callback_query
->
getId
();
$callback_data
=
$callback_query
->
getData
();
$data
[
'callback_query_id'
]
=
$callback_query_id
;
if
(
$callback_data
==
'thumb up'
)
{
$data
[
'text'
]
=
'Hello World!'
;
$data
[
'show_alert'
]
=
true
;
}
else
{
$data
[
'text'
]
=
'Hello World!'
;
$data
[
'show_alert'
]
=
false
;
}
$data
=
[
'callback_query_id'
=>
$callback_query_id
,
'text'
=>
'Hello World!'
,
'show_alert'
=>
$callback_data
===
'thumb up'
,
];
return
Request
::
answerCallbackQuery
(
$data
);
}
...
...
src/Commands/SystemCommands/ChannelchatcreatedCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class ChannelchatcreatedCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.0.1
'
;
protected
$version
=
'1.1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/ChoseninlineresultCommand.php
View file @
c9e38bc5
...
...
@@ -30,13 +30,21 @@ class ChoseninlineresultCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//Information about chosen result is returned
//$update = $this->getUpdate();
//$inline_query = $update->getChosenInlineResult();
//$query = $inline_query->getQuery();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/DeletechatphotoCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class DeletechatphotoCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$delete_chat_photo = $message->getDeleteChatPhoto();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/EditedmessageCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class EditedmessageCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0
.0'
;
protected
$version
=
'1.
1
.0'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
$update = $this->getUpdate();
$edited_message = $update->getEditedMessage();
}*/
//$update = $this->getUpdate();
//$edited_message = $update->getEditedMessage();
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/GenericCommand.php
View file @
c9e38bc5
...
...
@@ -31,12 +31,13 @@ class GenericCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
...
...
@@ -47,8 +48,9 @@ class GenericCommand extends SystemCommand
$user_id
=
$message
->
getFrom
()
->
getId
();
$command
=
$message
->
getCommand
();
if
(
in_array
(
$user_id
,
$this
->
telegram
->
getAdminList
())
&&
strtolower
(
substr
(
$command
,
0
,
5
))
==
'whois'
)
{
return
$this
->
telegram
->
executeCommand
(
'whois'
,
$this
->
update
);
//If the user is and admin and the command is in the format "/whoisXYZ", call the /whois command
if
(
stripos
(
$command
,
'whois'
)
===
0
&&
$this
->
telegram
->
isAdmin
(
$user_id
))
{
return
$this
->
telegram
->
executeCommand
(
'whois'
);
}
$data
=
[
...
...
src/Commands/SystemCommands/GenericmessageCommand.php
View file @
c9e38bc5
...
...
@@ -32,7 +32,7 @@ class GenericmessageCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.2
'
;
protected
$version
=
'1.
1.0
'
;
/**
* @var bool
...
...
@@ -54,6 +54,7 @@ class GenericmessageCommand extends SystemCommand
* Execute command
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
...
...
@@ -64,7 +65,7 @@ class GenericmessageCommand extends SystemCommand
);
//Fetch conversation command if it exists and execute it
if
(
$conversation
->
exists
()
&&
(
$command
=
$conversation
->
getCommand
()))
{
return
$this
->
telegram
->
executeCommand
(
$command
,
$this
->
update
);
return
$this
->
telegram
->
executeCommand
(
$command
);
}
return
Request
::
emptyResponse
();
...
...
src/Commands/SystemCommands/GroupchatcreatedCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class GroupchatcreatedCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$group_chat_created = $message->getGroupChatCreated();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/InlinequeryCommand.php
View file @
c9e38bc5
...
...
@@ -33,12 +33,13 @@ class InlinequeryCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.2
'
;
protected
$version
=
'1.
1.0
'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
...
...
@@ -55,19 +56,19 @@ class InlinequeryCommand extends SystemCommand
'id'
=>
'001'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
,
],
[
'id'
=>
'002'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
,
],
[
'id'
=>
'003'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
,
],
];
...
...
src/Commands/SystemCommands/LeftchatmemberCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class LeftchatmemberCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$member = $message->getLeftChatMember();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/MigratefromchatidCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class MigratefromchatidCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$migrate_from_chat_id = $message->getMigrateFromChatId();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/MigratetochatidCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class MigratetochatidCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$migrate_to_chat_id = $message->getMigrateToChatId();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/NewchatmemberCommand.php
View file @
c9e38bc5
...
...
@@ -31,10 +31,13 @@ class NewchatmemberCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
...
...
@@ -42,10 +45,9 @@ class NewchatmemberCommand extends SystemCommand
$chat_id
=
$message
->
getChat
()
->
getId
();
$member
=
$message
->
getNewChatMember
();
if
(
$message
->
botAddedInChat
())
{
$text
=
'Hi there!'
;
}
else
{
if
(
!
$message
->
botAddedInChat
())
{
$text
=
'Hi '
.
$member
->
tryMention
()
.
'!'
;
}
...
...
src/Commands/SystemCommands/NewchatphotoCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class NewchatphotoCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$new_chat_photo = $message->getNewChatPhoto();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/NewchattitleCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class NewchattitleCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
}*/
return
parent
::
execute
();
}
}
src/Commands/SystemCommands/StartCommand.php
View file @
c9e38bc5
...
...
@@ -36,19 +36,20 @@ class StartCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
'Hi there!'
.
"
\n
"
.
'Type /help to see all commands!'
;
$text
=
'Hi there!'
.
PHP_EOL
.
'Type /help to see all commands!'
;
$data
=
[
'chat_id'
=>
$chat_id
,
...
...
src/Commands/SystemCommands/SupergroupchatcreatedCommand.php
View file @
c9e38bc5
...
...
@@ -30,11 +30,19 @@ class SupergroupchatcreatedCommand extends SystemCommand
/**
* @var string
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/*public function execute()
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$supergroup_chat_created = $message->getSuperGroupChatCreated();
}*/
return
parent
::
execute
();
}
}
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