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
8509c63c
Commit
8509c63c
authored
Feb 11, 2016
by
Marco Boretto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #98 from noplanman/command_code_cleanup
Remove any unnecessary code from commands.
parents
9960f62f
fba22125
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
65 additions
and
399 deletions
+65
-399
ChatsCommand.php
src/Admin/ChatsCommand.php
+6
-17
SendtoallCommand.php
src/Admin/SendtoallCommand.php
+5
-18
SendtochannelCommand.php
src/Admin/SendtochannelCommand.php
+1
-14
ChannelchatcreatedCommand.php
src/Commands/ChannelchatcreatedCommand.php
+4
-22
ChoseninlineresultCommand.php
src/Commands/ChoseninlineresultCommand.php
+5
-31
DateCommand.php
src/Commands/DateCommand.php
+2
-12
DeletechatphotoCommand.php
src/Commands/DeletechatphotoCommand.php
+4
-22
EchoCommand.php
src/Commands/EchoCommand.php
+1
-12
GenericCommand.php
src/Commands/GenericCommand.php
+1
-21
GenericmessageCommand.php
src/Commands/GenericmessageCommand.php
+2
-28
GroupchatcreatedCommand.php
src/Commands/GroupchatcreatedCommand.php
+4
-22
HelpCommand.php
src/Commands/HelpCommand.php
+1
-11
InlinequeryCommand.php
src/Commands/InlinequeryCommand.php
+5
-30
LeftchatparticipantCommand.php
src/Commands/LeftchatparticipantCommand.php
+4
-22
NewchatparticipantCommand.php
src/Commands/NewchatparticipantCommand.php
+3
-20
NewchattitleCommand.php
src/Commands/NewchattitleCommand.php
+4
-22
SlapCommand.php
src/Commands/SlapCommand.php
+2
-11
StartCommand.php
src/Commands/StartCommand.php
+1
-18
SupergroupchatcreatedCommand.php
src/Commands/SupergroupchatcreatedCommand.php
+3
-20
WeatherCommand.php
src/Commands/WeatherCommand.php
+5
-15
WhoamiCommand.php
src/Commands/WhoamiCommand.php
+2
-11
No files found.
src/Admin/ChatsCommand.php
View file @
8509c63c
...
...
@@ -13,8 +13,6 @@ namespace Longman\TelegramBot\Commands;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\DB
;
use
Longman\TelegramBot\Entities\Chat
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Exception\TelegramException
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -50,13 +48,6 @@ class ChatsCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -81,12 +72,13 @@ class ChatsCommand extends Command
//Preparing message
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$data
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
'Sorry no database connection, unable to execute "'
.
$this
->
name
.
'" command.'
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
/**
...
...
@@ -96,12 +88,9 @@ class ChatsCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$message_id
=
$message
->
getMessageId
();
$text
=
$message
->
getText
(
true
);
$results
=
DB
::
selectChats
(
true
,
//Send to groups (group chat)
...
...
@@ -133,7 +122,7 @@ class ChatsCommand extends Command
}
}
if
((
$user_chats
+
$group_chats
+
$super_group_chats
)
==
0
)
{
if
((
$user_chats
+
$group_chats
+
$super_group_chats
)
==
=
0
)
{
$text
=
'No chats found..'
;
}
else
{
$text
.=
"
\n
"
.
'Private Chats: '
.
$user_chats
;
...
...
@@ -146,7 +135,7 @@ class ChatsCommand extends Command
'chat_id'
=>
$chat_id
,
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Admin/SendtoallCommand.php
View file @
8509c63c
...
...
@@ -11,9 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\DB
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Exception\TelegramException
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -49,13 +46,6 @@ class SendtoallCommand extends Command
*/
protected
$version
=
'1.2.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -80,12 +70,13 @@ class SendtoallCommand extends Command
//Preparing message
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$data
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
'Sorry no database connection, unable to execute "'
.
$this
->
name
.
'" command.'
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
/**
...
...
@@ -97,12 +88,9 @@ class SendtoallCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$message_id
=
$message
->
getMessageId
();
$text
=
$message
->
getText
(
true
);
if
(
empty
(
$text
))
{
$text
=
'Write the message to send: /sendall <message>'
;
...
...
@@ -147,7 +135,7 @@ class SendtoallCommand extends Command
}
$text
.=
'Delivered: '
.
(
$tot
-
$fail
)
.
'/'
.
$tot
.
"
\n
"
;
}
if
(
$tot
==
0
)
{
if
(
$tot
==
=
0
)
{
$text
=
'No users or chats found..'
;
}
...
...
@@ -156,7 +144,6 @@ class SendtoallCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Admin/SendtochannelCommand.php
View file @
8509c63c
...
...
@@ -11,9 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\DB
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Exception\TelegramException
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -49,13 +46,6 @@ class SendtochannelCommand extends Command
*/
protected
$version
=
'0.1.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -79,11 +69,9 @@ class SendtochannelCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$message_id
=
$message
->
getMessageId
();
$text
=
$message
->
getText
(
true
);
if
(
empty
(
$text
))
{
...
...
@@ -109,7 +97,6 @@ class SendtochannelCommand extends Command
'text'
=>
$text_back
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/ChannelchatcreatedCommand.php
View file @
8509c63c
...
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
* Channel chat created command
...
...
@@ -33,13 +31,6 @@ class ChannelchatcreatedCommand extends Command
*/
protected
$description
=
'Channel chat created'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +38,6 @@ class ChannelchatcreatedCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,12 +45,10 @@ class ChannelchatcreatedCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$channel_chat_created
=
$message
->
getChannelChatCreated
();
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
//
Temporary
, do nothing
return
1
;
//
System command
, do nothing
return
true
;
}
}
src/Commands/ChoseninlineresultCommand.php
View file @
8509c63c
...
...
@@ -11,10 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Entity
;
use
Longman\TelegramBot\Entities\InlineQueryResultArticle
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
* Chosen inline result command
...
...
@@ -35,13 +31,6 @@ class ChoseninlineresultCommand extends Command
*/
protected
$description
=
'Chosen result query'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
''
;
/**
* Version
*
...
...
@@ -49,20 +38,6 @@ class ChoseninlineresultCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
* @var boolean
*/
protected
$public
=
false
;
/**
* Execute command
*
...
...
@@ -70,13 +45,12 @@ class ChoseninlineresultCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$inline_query
=
$update
->
getChosenInlineResult
();
$query
=
$inline_query
->
getQuery
();
//Information about chosen result is returned
//Do nothing
//$update = $this->getUpdate();
//$inline_query = $update->getChosenInlineResult();
//$query = $inline_query->getQuery();
return
1
;
//System command, do nothing
return
true
;
}
}
src/Commands/DateCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Exception\TelegramException
;
use
Longman\TelegramBot\Request
;
...
...
@@ -48,13 +47,6 @@ class DateCommand extends Command
*/
protected
$version
=
'1.2.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -135,7 +127,7 @@ class DateCommand extends Command
$google_api_key
=
$this
->
getConfig
(
'google_api_key'
);
if
(
!
empty
(
$google_api_key
))
{
$params
.=
'&key='
.
$google_api_key
;
$params
.=
'&key='
.
$google_api_key
;
}
$data
=
$this
->
request
(
$url
.
$params
);
...
...
@@ -214,7 +206,6 @@ class DateCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
...
...
@@ -238,7 +229,6 @@ class DateCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/DeletechatphotoCommand.php
View file @
8509c63c
...
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
* Delete chat photo command
...
...
@@ -33,13 +31,6 @@ class DeletechatphotoCommand extends Command
*/
protected
$description
=
'Delete chat photo'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +38,6 @@ class DeletechatphotoCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,12 +45,10 @@ class DeletechatphotoCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$delete_chat_photo
=
$message
->
getDeleteChatPhoto
();
//$message = $this->getMessage();
//$delete_chat_photo = $message->getDeleteChatPhoto();
//
Temporary
, do nothing
return
1
;
//
System command
, do nothing
return
true
;
}
}
src/Commands/EchoCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -47,13 +46,6 @@ class EchoCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -68,9 +60,7 @@ class EchoCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
...
...
@@ -79,7 +69,6 @@ class EchoCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/GenericCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -33,13 +32,6 @@ class GenericCommand extends Command
*/
protected
$description
=
'Handles generic commands or is executed by default when a command is not found'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +39,6 @@ class GenericCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -63,22 +48,17 @@ class GenericCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
//You can use $command as param
$command
=
$message
->
getCommand
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
'Command: '
.
$command
.
' not found.. :('
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/GenericmessageCommand.php
View file @
8509c63c
...
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
* Generic message command
...
...
@@ -33,13 +31,6 @@ class GenericmessageCommand extends Command
*/
protected
$description
=
'Handle generic message'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +38,6 @@ class GenericmessageCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,17 +45,7 @@ class GenericmessageCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
//You can use $command as param
$command
=
$message
->
getCommand
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
//Do nothing
return
1
;
//System command, do nothing
return
true
;
}
}
src/Commands/GroupchatcreatedCommand.php
View file @
8509c63c
...
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
* Group chat created command
...
...
@@ -33,13 +31,6 @@ class GroupchatcreatedCommand extends Command
*/
protected
$description
=
'Group chat created'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +38,6 @@ class GroupchatcreatedCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,12 +45,10 @@ class GroupchatcreatedCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$group_chat_created
=
$message
->
getGroupChatCreated
();
//$message = $this->getMessage();
//$group_chat_created = $message->getGroupChatCreated();
//
Temporary
, do nothing
return
1
;
//
System command
, do nothing
return
true
;
}
}
src/Commands/HelpCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -47,13 +46,6 @@ class HelpCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -68,7 +60,6 @@ class HelpCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
...
...
@@ -116,7 +107,6 @@ class HelpCommand extends Command
'text'
=>
$msg
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/InlinequeryCommand.php
View file @
8509c63c
...
...
@@ -11,9 +11,7 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Entity
;
use
Longman\TelegramBot\Entities\InlineQueryResultArticle
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -35,13 +33,6 @@ class InlinequeryCommand extends Command
*/
protected
$description
=
'Reply to inline query'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
''
;
/**
* Version
*
...
...
@@ -49,20 +40,6 @@ class InlinequeryCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
* @var boolean
*/
protected
$public
=
false
;
/**
* Execute command
*
...
...
@@ -77,19 +54,17 @@ class InlinequeryCommand extends Command
$data
=
[
'inline_query_id'
=>
$inline_query
->
getId
()];
$articles
=
[
[
'id'
=>
'001'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
],
[
'id'
=>
'002'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
],
[
'id'
=>
'003'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
],
[
'id'
=>
'001'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
],
[
'id'
=>
'002'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
],
[
'id'
=>
'003'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'message_text'
=>
'you enter: '
.
$query
],
];
$array_article
=
[];
foreach
(
$articles
as
$article
)
{
$array_article
[]
=
new
InlineQueryResultArticle
(
$article
);
}
$array_json
=
'['
.
implode
(
','
,
$array_article
)
.
']'
;
$data
[
'results'
]
=
$array_json
;
$data
[
'results'
]
=
'['
.
implode
(
','
,
$array_article
)
.
']'
;
$result
=
Request
::
answerInlineQuery
(
$data
);
return
$result
->
isOk
();
return
Request
::
answerInlineQuery
(
$data
)
->
isOk
();
}
}
src/Commands/LeftchatparticipantCommand.php
View file @
8509c63c
...
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
* Left chat participant command
...
...
@@ -33,13 +31,6 @@ class LeftchatparticipantCommand extends Command
*/
protected
$description
=
'Left Chat Participant'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +38,6 @@ class LeftchatparticipantCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,12 +45,10 @@ class LeftchatparticipantCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$participant
=
$message
->
getLeftChatParticipant
();
//$message = $this->getMessage();
//$participant = $message->getLeftChatParticipant();
//
Temporary
, do nothing
return
1
;
//
System command
, do nothing
return
true
;
}
}
src/Commands/NewchatparticipantCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -33,13 +32,6 @@ class NewchatparticipantCommand extends Command
*/
protected
$description
=
'New Chat Participant'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +39,6 @@ class NewchatparticipantCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,16 +46,15 @@ class NewchatparticipantCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$participant
=
$message
->
getNewChatParticipant
();
if
(
strtolower
(
$participant
->
getUsername
())
==
strtolower
(
$this
->
getTelegram
()
->
getBotName
()))
{
if
(
strtolower
(
$participant
->
getUsername
())
==
=
strtolower
(
$this
->
getTelegram
()
->
getBotName
()))
{
$text
=
'Hi there!'
;
}
else
{
$text
=
'Hi '
.
$participant
->
tryMention
()
.
'
!'
;
$text
=
'Hi '
.
$participant
->
tryMention
()
.
'!'
;
}
$data
=
[
...
...
@@ -78,7 +62,6 @@ class NewchatparticipantCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/NewchattitleCommand.php
View file @
8509c63c
...
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
* New chat title command
...
...
@@ -33,13 +31,6 @@ class NewchattitleCommand extends Command
*/
protected
$description
=
'New chat Title'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,13 +38,6 @@ class NewchattitleCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,12 +45,10 @@ class NewchattitleCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$new_chat_title
=
$message
->
getNewChatTitle
();
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
//
Temporary
, do nothing
return
1
;
//
System command
, do nothing
return
true
;
}
}
src/Commands/SlapCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -47,13 +46,6 @@ class SlapCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
...
...
@@ -61,8 +53,8 @@ class SlapCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$message_id
=
$message
->
getMessageId
();
$text
=
$message
->
getText
(
true
);
...
...
@@ -82,7 +74,6 @@ class SlapCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/StartCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -47,20 +46,6 @@ class StartCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
* @var boolean
*/
protected
$public
=
false
;
/**
* Execute command
*
...
...
@@ -68,7 +53,6 @@ class StartCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
...
...
@@ -79,7 +63,6 @@ class StartCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/SupergroupchatcreatedCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -33,13 +32,6 @@ class SupergroupchatcreatedCommand extends Command
*/
protected
$description
=
'Super group chat created'
;
/**
* Usage
*
* @var string
*/
protected
$usage
=
'/'
;
/**
* Version
*
...
...
@@ -47,24 +39,16 @@ class SupergroupchatcreatedCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* Execute command
*
* @todo $chat_id isn't defined!
*
* @return boolean
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
''
;
if
(
$message
->
getSuperGroupChatCreated
())
{
...
...
@@ -77,7 +61,6 @@ class SupergroupchatcreatedCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/WeatherCommand.php
View file @
8509c63c
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -47,13 +46,6 @@ class WeatherCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -125,19 +117,19 @@ class WeatherCommand extends Command
switch
(
strtolower
(
$decode
[
'weather'
][
0
][
'main'
]))
{
case
'clear'
:
$conditions
.=
' ☀'
;
$conditions
.=
' ☀'
;
break
;
case
'clouds'
:
$conditions
.=
' ☁☁'
;
$conditions
.=
' ☁☁'
;
break
;
case
'rain'
:
$conditions
.=
' ☔'
;
$conditions
.=
' ☔'
;
break
;
case
'thunderstorm'
:
$conditions
.=
' ☔☔☔☔'
;
$conditions
.=
' ☔☔☔☔'
;
break
;
}
...
...
@@ -156,7 +148,6 @@ class WeatherCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
...
...
@@ -180,7 +171,6 @@ class WeatherCommand extends Command
'text'
=>
$text
,
];
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
return
Request
::
sendMessage
(
$data
)
->
isOk
();
}
}
src/Commands/WhoamiCommand.php
View file @
8509c63c
...
...
@@ -14,7 +14,6 @@ namespace Longman\TelegramBot\Commands;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\File
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Request
;
/**
...
...
@@ -50,13 +49,6 @@ class WhoamiCommand extends Command
*/
protected
$version
=
'1.0.0'
;
/**
* If this command is enabled
*
* @var boolean
*/
protected
$enabled
=
true
;
/**
* If this command is public
*
...
...
@@ -71,7 +63,6 @@ class WhoamiCommand extends Command
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$user_id
=
$message
->
getFrom
()
->
getId
();
...
...
@@ -82,9 +73,9 @@ class WhoamiCommand extends Command
//Send chat action
Request
::
sendChatAction
([
'chat_id'
=>
$chat_id
,
'action'
=>
'typing'
]);
$caption
=
'Your Id: '
.
$
message
->
getFrom
()
->
getId
()
.
"
\n
"
;
$caption
=
'Your Id: '
.
$
user_id
.
"
\n
"
;
$caption
.=
'Name: '
.
$message
->
getFrom
()
->
getFirstName
()
.
' '
.
$message
->
getFrom
()
->
getLastName
()
.
"
\n
"
;
.
' '
.
$message
->
getFrom
()
->
getLastName
()
.
"
\n
"
;
$caption
.=
'Username: '
.
$message
->
getFrom
()
->
getUsername
();
//Fetch user profile photo
...
...
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