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
...
@@ -31,12 +31,13 @@ class CallbackqueryCommand extends SystemCommand
/**
/**
* @var string
* @var string
*/
*/
protected
$version
=
'1.
0
.0'
;
protected
$version
=
'1.
1
.0'
;
/**
/**
* Command execute method
* Command execute method
*
*
* @return mixed
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
*/
public
function
execute
()
public
function
execute
()
{
{
...
@@ -45,15 +46,11 @@ class CallbackqueryCommand extends SystemCommand
...
@@ -45,15 +46,11 @@ class CallbackqueryCommand extends SystemCommand
$callback_query_id
=
$callback_query
->
getId
();
$callback_query_id
=
$callback_query
->
getId
();
$callback_data
=
$callback_query
->
getData
();
$callback_data
=
$callback_query
->
getData
();
$data
[
'callback_query_id'
]
=
$callback_query_id
;
$data
=
[
'callback_query_id'
=>
$callback_query_id
,
if
(
$callback_data
==
'thumb up'
)
{
'text'
=>
'Hello World!'
,
$data
[
'text'
]
=
'Hello World!'
;
'show_alert'
=>
$callback_data
===
'thumb up'
,
$data
[
'show_alert'
]
=
true
;
];
}
else
{
$data
[
'text'
]
=
'Hello World!'
;
$data
[
'show_alert'
]
=
false
;
}
return
Request
::
answerCallbackQuery
(
$data
);
return
Request
::
answerCallbackQuery
(
$data
);
}
}
...
...
src/Commands/SystemCommands/ChannelchatcreatedCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class ChannelchatcreatedCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class ChannelchatcreatedCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
//$channel_chat_created = $message->getChannelChatCreated();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/ChoseninlineresultCommand.php
View file @
c9e38bc5
...
@@ -30,13 +30,21 @@ class ChoseninlineresultCommand extends SystemCommand
...
@@ -30,13 +30,21 @@ class ChoseninlineresultCommand extends SystemCommand
/**
/**
* @var string
* @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
//Information about chosen result is returned
//$update = $this->getUpdate();
//$update = $this->getUpdate();
//$inline_query = $update->getChosenInlineResult();
//$inline_query = $update->getChosenInlineResult();
//$query = $inline_query->getQuery();
//$query = $inline_query->getQuery();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/DeletechatphotoCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class DeletechatphotoCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class DeletechatphotoCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$delete_chat_photo = $message->getDeleteChatPhoto();
//$delete_chat_photo = $message->getDeleteChatPhoto();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/EditedmessageCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class EditedmessageCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class EditedmessageCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$update = $this->getUpdate();
$edited_message = $update->getEditedMessage();
//$edited_message = $update->getEditedMessage();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/GenericCommand.php
View file @
c9e38bc5
...
@@ -31,12 +31,13 @@ class GenericCommand extends SystemCommand
...
@@ -31,12 +31,13 @@ class GenericCommand extends SystemCommand
/**
/**
* @var string
* @var string
*/
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/**
/**
* Command execute method
* Command execute method
*
*
* @return mixed
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
*/
public
function
execute
()
public
function
execute
()
{
{
...
@@ -47,8 +48,9 @@ class GenericCommand extends SystemCommand
...
@@ -47,8 +48,9 @@ class GenericCommand extends SystemCommand
$user_id
=
$message
->
getFrom
()
->
getId
();
$user_id
=
$message
->
getFrom
()
->
getId
();
$command
=
$message
->
getCommand
();
$command
=
$message
->
getCommand
();
if
(
in_array
(
$user_id
,
$this
->
telegram
->
getAdminList
())
&&
strtolower
(
substr
(
$command
,
0
,
5
))
==
'whois'
)
{
//If the user is and admin and the command is in the format "/whoisXYZ", call the /whois command
return
$this
->
telegram
->
executeCommand
(
'whois'
,
$this
->
update
);
if
(
stripos
(
$command
,
'whois'
)
===
0
&&
$this
->
telegram
->
isAdmin
(
$user_id
))
{
return
$this
->
telegram
->
executeCommand
(
'whois'
);
}
}
$data
=
[
$data
=
[
...
...
src/Commands/SystemCommands/GenericmessageCommand.php
View file @
c9e38bc5
...
@@ -32,7 +32,7 @@ class GenericmessageCommand extends SystemCommand
...
@@ -32,7 +32,7 @@ class GenericmessageCommand extends SystemCommand
/**
/**
* @var string
* @var string
*/
*/
protected
$version
=
'1.
0.2
'
;
protected
$version
=
'1.
1.0
'
;
/**
/**
* @var bool
* @var bool
...
@@ -54,6 +54,7 @@ class GenericmessageCommand extends SystemCommand
...
@@ -54,6 +54,7 @@ class GenericmessageCommand extends SystemCommand
* Execute command
* Execute command
*
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
*/
public
function
execute
()
public
function
execute
()
{
{
...
@@ -64,7 +65,7 @@ class GenericmessageCommand extends SystemCommand
...
@@ -64,7 +65,7 @@ class GenericmessageCommand extends SystemCommand
);
);
//Fetch conversation command if it exists and execute it
//Fetch conversation command if it exists and execute it
if
(
$conversation
->
exists
()
&&
(
$command
=
$conversation
->
getCommand
()))
{
if
(
$conversation
->
exists
()
&&
(
$command
=
$conversation
->
getCommand
()))
{
return
$this
->
telegram
->
executeCommand
(
$command
,
$this
->
update
);
return
$this
->
telegram
->
executeCommand
(
$command
);
}
}
return
Request
::
emptyResponse
();
return
Request
::
emptyResponse
();
...
...
src/Commands/SystemCommands/GroupchatcreatedCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class GroupchatcreatedCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class GroupchatcreatedCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$group_chat_created = $message->getGroupChatCreated();
//$group_chat_created = $message->getGroupChatCreated();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/InlinequeryCommand.php
View file @
c9e38bc5
...
@@ -33,12 +33,13 @@ class InlinequeryCommand extends SystemCommand
...
@@ -33,12 +33,13 @@ class InlinequeryCommand extends SystemCommand
/**
/**
* @var string
* @var string
*/
*/
protected
$version
=
'1.
0.2
'
;
protected
$version
=
'1.
1.0
'
;
/**
/**
* Command execute method
* Command execute method
*
*
* @return mixed
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
*/
public
function
execute
()
public
function
execute
()
{
{
...
@@ -55,19 +56,19 @@ class InlinequeryCommand extends SystemCommand
...
@@ -55,19 +56,19 @@ class InlinequeryCommand extends SystemCommand
'id'
=>
'001'
,
'id'
=>
'001'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'description'
=>
'you enter: '
.
$query
,
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
,
],
],
[
[
'id'
=>
'002'
,
'id'
=>
'002'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'description'
=>
'you enter: '
.
$query
,
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
])
,
],
],
[
[
'id'
=>
'003'
,
'id'
=>
'003'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'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
...
@@ -30,11 +30,19 @@ class LeftchatmemberCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$member = $message->getLeftChatMember();
//$member = $message->getLeftChatMember();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/MigratefromchatidCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class MigratefromchatidCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class MigratefromchatidCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$migrate_from_chat_id = $message->getMigrateFromChatId();
//$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
...
@@ -30,11 +30,19 @@ class MigratetochatidCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$migrate_to_chat_id = $message->getMigrateToChatId();
//$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
...
@@ -31,10 +31,13 @@ class NewchatmemberCommand extends SystemCommand
/**
/**
* @var string
* @var string
*/
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/**
/**
* Command execute method
*
* @return mixed
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
*/
public
function
execute
()
public
function
execute
()
{
{
...
@@ -42,10 +45,9 @@ class NewchatmemberCommand extends SystemCommand
...
@@ -42,10 +45,9 @@ class NewchatmemberCommand extends SystemCommand
$chat_id
=
$message
->
getChat
()
->
getId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$member
=
$message
->
getNewChatMember
();
$member
=
$message
->
getNewChatMember
();
if
(
$message
->
botAddedInChat
())
{
$text
=
'Hi there!'
;
$text
=
'Hi there!'
;
}
else
{
if
(
!
$message
->
botAddedInChat
())
{
$text
=
'Hi '
.
$member
->
tryMention
()
.
'!'
;
$text
=
'Hi '
.
$member
->
tryMention
()
.
'!'
;
}
}
...
...
src/Commands/SystemCommands/NewchatphotoCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class NewchatphotoCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class NewchatphotoCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$new_chat_photo = $message->getNewChatPhoto();
//$new_chat_photo = $message->getNewChatPhoto();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/NewchattitleCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class NewchattitleCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class NewchattitleCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
//$new_chat_title = $message->getNewChatTitle();
}*/
return
parent
::
execute
();
}
}
}
src/Commands/SystemCommands/StartCommand.php
View file @
c9e38bc5
...
@@ -36,19 +36,20 @@ class StartCommand extends SystemCommand
...
@@ -36,19 +36,20 @@ class StartCommand extends SystemCommand
/**
/**
* @var string
* @var string
*/
*/
protected
$version
=
'1.
0.1
'
;
protected
$version
=
'1.
1.0
'
;
/**
/**
* Command execute method
* Command execute method
*
*
* @return mixed
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
*/
public
function
execute
()
public
function
execute
()
{
{
$message
=
$this
->
getMessage
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$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
=
[
$data
=
[
'chat_id'
=>
$chat_id
,
'chat_id'
=>
$chat_id
,
...
...
src/Commands/SystemCommands/SupergroupchatcreatedCommand.php
View file @
c9e38bc5
...
@@ -30,11 +30,19 @@ class SupergroupchatcreatedCommand extends SystemCommand
...
@@ -30,11 +30,19 @@ class SupergroupchatcreatedCommand extends SystemCommand
/**
/**
* @var string
* @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();
//$message = $this->getMessage();
//$supergroup_chat_created = $message->getSuperGroupChatCreated();
//$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