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
aec70278
Commit
aec70278
authored
Jan 22, 2017
by
Jack'lul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move default commands to examples
parent
518e9dd8
Changes
36
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
1105 additions
and
78 deletions
+1105
-78
CallbackqueryCommand.php
examples/Commands/CallbackqueryCommand.php
+58
-0
CancelCommand.php
examples/Commands/CancelCommand.php
+0
-0
ChannelchatcreatedCommand.php
examples/Commands/ChannelchatcreatedCommand.php
+48
-0
ChannelpostCommand.php
examples/Commands/ChannelpostCommand.php
+47
-0
ChoseninlineresultCommand.php
examples/Commands/ChoseninlineresultCommand.php
+50
-0
DateCommand.php
examples/Commands/DateCommand.php
+0
-0
DeletechatphotoCommand.php
examples/Commands/DeletechatphotoCommand.php
+48
-0
EchoCommand.php
examples/Commands/EchoCommand.php
+0
-0
EditedchannelpostCommand.php
examples/Commands/EditedchannelpostCommand.php
+47
-0
EditedmessageCommand.php
examples/Commands/EditedmessageCommand.php
+48
-0
GenericCommand.php
examples/Commands/GenericCommand.php
+63
-0
GenericmessageCommand.php
examples/Commands/GenericmessageCommand.php
+74
-0
GroupchatcreatedCommand.php
examples/Commands/GroupchatcreatedCommand.php
+48
-0
HelpCommand.php
examples/Commands/HelpCommand.php
+0
-0
InlinequeryCommand.php
examples/Commands/InlinequeryCommand.php
+84
-0
LeftchatmemberCommand.php
examples/Commands/LeftchatmemberCommand.php
+48
-0
MigratefromchatidCommand.php
examples/Commands/MigratefromchatidCommand.php
+48
-0
MigratetochatidCommand.php
examples/Commands/MigratetochatidCommand.php
+48
-0
NewchatmemberCommand.php
examples/Commands/NewchatmemberCommand.php
+61
-0
NewchatphotoCommand.php
examples/Commands/NewchatphotoCommand.php
+48
-0
NewchattitleCommand.php
examples/Commands/NewchattitleCommand.php
+48
-0
PinnedmessageCommand.php
examples/Commands/PinnedmessageCommand.php
+48
-0
SlapCommand.php
examples/Commands/SlapCommand.php
+0
-0
StartCommand.php
examples/Commands/StartCommand.php
+61
-0
SupergroupchatcreatedCommand.php
examples/Commands/SupergroupchatcreatedCommand.php
+48
-0
SurveyCommand.php
examples/Commands/SurveyCommand.php
+0
-0
WeatherCommand.php
examples/Commands/WeatherCommand.php
+0
-0
WhoamiCommand.php
examples/Commands/WhoamiCommand.php
+0
-0
cron.php
examples/cron.php
+4
-1
getUpdatesCLI.php
examples/getUpdatesCLI.php
+4
-1
hook.php
examples/hook.php
+4
-1
CallbackqueryCommand.php
src/Commands/SystemCommands/CallbackqueryCommand.php
+5
-12
GenericCommand.php
src/Commands/SystemCommands/GenericCommand.php
+6
-17
GenericmessageCommand.php
src/Commands/SystemCommands/GenericmessageCommand.php
+1
-0
InlinequeryCommand.php
src/Commands/SystemCommands/InlinequeryCommand.php
+4
-36
StartCommand.php
src/Commands/SystemCommands/StartCommand.php
+4
-10
No files found.
examples/Commands/CallbackqueryCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
* Callback query command
*/
class
CallbackqueryCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'callbackquery'
;
/**
* @var string
*/
protected
$description
=
'Reply to callback query'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$callback_query
=
$update
->
getCallbackQuery
();
$callback_query_id
=
$callback_query
->
getId
();
$callback_data
=
$callback_query
->
getData
();
$data
=
[
'callback_query_id'
=>
$callback_query_id
,
'text'
=>
'Hello World!'
,
'show_alert'
=>
$callback_data
===
'thumb up'
,
'cache_time'
=>
5
,
];
return
Request
::
answerCallbackQuery
(
$data
);
}
}
src/Commands/User
Commands/CancelCommand.php
→
examples/
Commands/CancelCommand.php
View file @
aec70278
File moved
examples/Commands/ChannelchatcreatedCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Channel chat created command
*/
class
ChannelchatcreatedCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Channelchatcreated'
;
/**
* @var string
*/
protected
$description
=
'Channel chat created'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
return
parent
::
execute
();
}
}
examples/Commands/ChannelpostCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Channel post command
*/
class
ChannelpostCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Channelpost'
;
/**
* @var string
*/
protected
$description
=
'Handle channel post'
;
/**
* @var string
*/
protected
$version
=
'1.0.0'
;
/**
* Execute command
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$channel_post = $this->getUpdate()->getChannelPost();
return
parent
::
execute
();
}
}
examples/Commands/ChoseninlineresultCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Chosen inline result command
*/
class
ChoseninlineresultCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'choseninlineresult'
;
/**
* @var string
*/
protected
$description
=
'Chosen result query'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* 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/User
Commands/DateCommand.php
→
examples/
Commands/DateCommand.php
View file @
aec70278
File moved
examples/Commands/DeletechatphotoCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Delete chat photo command
*/
class
DeletechatphotoCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Deletechatphoto'
;
/**
* @var string
*/
protected
$description
=
'Delete chat photo'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* 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/User
Commands/EchoCommand.php
→
examples/
Commands/EchoCommand.php
View file @
aec70278
File moved
examples/Commands/EditedchannelpostCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Edited channel post command
*/
class
EditedchannelpostCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Editedchannelpost'
;
/**
* @var string
*/
protected
$description
=
'Handle edited channel post'
;
/**
* @var string
*/
protected
$version
=
'1.0.0'
;
/**
* Execute command
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$edited_channel_post = $this->getUpdate()->getEditedChannelPost();
return
parent
::
execute
();
}
}
examples/Commands/EditedmessageCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Edited message command
*/
class
EditedmessageCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'editedmessage'
;
/**
* @var string
*/
protected
$description
=
'User edited message'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$update = $this->getUpdate();
//$edited_message = $update->getEditedMessage();
return
parent
::
execute
();
}
}
examples/Commands/GenericCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
* Generic command
*/
class
GenericCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Generic'
;
/**
* @var string
*/
protected
$description
=
'Handles generic commands or is executed by default when a command is not found'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
$message
=
$this
->
getMessage
();
//You can use $command as param
$chat_id
=
$message
->
getChat
()
->
getId
();
$user_id
=
$message
->
getFrom
()
->
getId
();
$command
=
$message
->
getCommand
();
//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
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
'Command /'
.
$command
.
' not found.. :('
,
];
return
Request
::
sendMessage
(
$data
);
}
}
examples/Commands/GenericmessageCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Conversation
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Generic message command
*/
class
GenericmessageCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Genericmessage'
;
/**
* @var string
*/
protected
$description
=
'Handle generic message'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* @var bool
*/
protected
$need_mysql
=
true
;
/**
* Execution if MySQL is required but not available
*
* @return \Longman\TelegramBot\Entities\ServerResponse
*/
public
function
executeNoDb
()
{
//Do nothing
return
Request
::
emptyResponse
();
}
/**
* Execute command
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//If a conversation is busy, execute the conversation command after handling the message
$conversation
=
new
Conversation
(
$this
->
getMessage
()
->
getFrom
()
->
getId
(),
$this
->
getMessage
()
->
getChat
()
->
getId
()
);
//Fetch conversation command if it exists and execute it
if
(
$conversation
->
exists
()
&&
(
$command
=
$conversation
->
getCommand
()))
{
return
$this
->
telegram
->
executeCommand
(
$command
);
}
return
Request
::
emptyResponse
();
}
}
examples/Commands/GroupchatcreatedCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Group chat created command
*/
class
GroupchatcreatedCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Groupchatcreated'
;
/**
* @var string
*/
protected
$description
=
'Group chat created'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* 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/User
Commands/HelpCommand.php
→
examples/
Commands/HelpCommand.php
View file @
aec70278
File moved
examples/Commands/InlinequeryCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Entities\InlineQuery\InlineQueryResultArticle
;
use
Longman\TelegramBot\Entities\InputMessageContent\InputTextMessageContent
;
use
Longman\TelegramBot\Request
;
/**
* Inline query command
*/
class
InlinequeryCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'inlinequery'
;
/**
* @var string
*/
protected
$description
=
'Reply to inline query'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$inline_query
=
$update
->
getInlineQuery
();
$query
=
$inline_query
->
getQuery
();
$data
=
[
'inline_query_id'
=>
$inline_query
->
getId
()];
$results
=
[];
if
(
$query
!==
''
)
{
$articles
=
[
[
'id'
=>
'001'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$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
]),
],
[
'id'
=>
'003'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
]),
],
];
foreach
(
$articles
as
$article
)
{
$results
[]
=
new
InlineQueryResultArticle
(
$article
);
}
}
$data
[
'results'
]
=
'['
.
implode
(
','
,
$results
)
.
']'
;
return
Request
::
answerInlineQuery
(
$data
);
}
}
examples/Commands/LeftchatmemberCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Left chat member command
*/
class
LeftchatmemberCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Leftchatmember'
;
/**
* @var string
*/
protected
$description
=
'Left Chat Member'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$member = $message->getLeftChatMember();
return
parent
::
execute
();
}
}
examples/Commands/MigratefromchatidCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Migrate from chat id command
*/
class
MigratefromchatidCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Migratefromchatid'
;
/**
* @var string
*/
protected
$description
=
'Migrate from chat id'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* 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
();
}
}
examples/Commands/MigratetochatidCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Migrate to chat id command
*/
class
MigratetochatidCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Migratetochatid'
;
/**
* @var string
*/
protected
$description
=
'Migrate to chat id'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* 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
();
}
}
examples/Commands/NewchatmemberCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
* New chat member command
*/
class
NewchatmemberCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Newchatmember'
;
/**
* @var string
*/
protected
$description
=
'New Chat Member'
;
/**
* @var string
*/
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
();
$member
=
$message
->
getNewChatMember
();
$text
=
'Hi there!'
;
if
(
!
$message
->
botAddedInChat
())
{
$text
=
'Hi '
.
$member
->
tryMention
()
.
'!'
;
}
$data
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
);
}
}
examples/Commands/NewchatphotoCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* New chat photo command
*/
class
NewchatphotoCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Newchatphoto'
;
/**
* @var string
*/
protected
$description
=
'New chat Photo'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$new_chat_photo = $message->getNewChatPhoto();
return
parent
::
execute
();
}
}
examples/Commands/NewchattitleCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* New chat title command
*/
class
NewchattitleCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Newchattitle'
;
/**
* @var string
*/
protected
$description
=
'New chat Title'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
return
parent
::
execute
();
}
}
examples/Commands/PinnedmessageCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Pinned message command
*/
class
PinnedmessageCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Pinnedmessage'
;
/**
* @var string
*/
protected
$description
=
'Message was pinned'
;
/**
* @var string
*/
protected
$version
=
'1.0.0'
;
/**
* Execute command
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$pinned_message = $message->getPinnedMessage();
return
parent
::
execute
();
}
}
src/Commands/User
Commands/SlapCommand.php
→
examples/
Commands/SlapCommand.php
View file @
aec70278
File moved
examples/Commands/StartCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
* Start command
*/
class
StartCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'start'
;
/**
* @var string
*/
protected
$description
=
'Start command'
;
/**
* @var string
*/
protected
$usage
=
'/start'
;
/**
* @var string
*/
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!'
.
PHP_EOL
.
'Type /help to see all commands!'
;
$data
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
$text
,
];
return
Request
::
sendMessage
(
$data
);
}
}
examples/Commands/SupergroupchatcreatedCommand.php
0 → 100644
View file @
aec70278
<?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\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Super group chat created command
*/
class
SupergroupchatcreatedCommand
extends
SystemCommand
{
/**
* @var string
*/
protected
$name
=
'Supergroupchatcreated'
;
/**
* @var string
*/
protected
$description
=
'Super group chat created'
;
/**
* @var string
*/
protected
$version
=
'1.1.0'
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
//$message = $this->getMessage();
//$supergroup_chat_created = $message->getSuperGroupChatCreated();
return
parent
::
execute
();
}
}
src/Commands/User
Commands/SurveyCommand.php
→
examples/
Commands/SurveyCommand.php
View file @
aec70278
File moved
src/Commands/User
Commands/WeatherCommand.php
→
examples/
Commands/WeatherCommand.php
View file @
aec70278
File moved
src/Commands/User
Commands/WhoamiCommand.php
→
examples/
Commands/WhoamiCommand.php
View file @
aec70278
File moved
examples/cron.php
View file @
aec70278
...
@@ -42,7 +42,10 @@ try {
...
@@ -42,7 +42,10 @@ try {
// Enable MySQL with table prefix
// Enable MySQL with table prefix
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
// Add an additional commands path
// Uncomment this line to load example commands
//$telegram->addCommandsPath(BASE_PATH . '/../examples/Commands');
// Add commands path containing your commands
//$telegram->addCommandsPath($commands_path);
//$telegram->addCommandsPath($commands_path);
// Enable admin user(s)
// Enable admin user(s)
...
...
examples/getUpdatesCLI.php
View file @
aec70278
...
@@ -43,7 +43,10 @@ try {
...
@@ -43,7 +43,10 @@ try {
// Enable MySQL with table prefix
// Enable MySQL with table prefix
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
// Add an additional commands path
// Uncomment this line to load example commands
//$telegram->addCommandsPath(BASE_PATH . '/../examples/Commands');
// Add commands path containing your commands
//$telegram->addCommandsPath($commands_path);
//$telegram->addCommandsPath($commands_path);
// Enable admin user(s)
// Enable admin user(s)
...
...
examples/hook.php
View file @
aec70278
...
@@ -42,7 +42,10 @@ try {
...
@@ -42,7 +42,10 @@ try {
// Enable MySQL with table prefix
// Enable MySQL with table prefix
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
// Add an additional commands path
// Uncomment this line to load example commands
//$telegram->addCommandsPath(BASE_PATH . '/../examples/Commands');
// Add commands path containing your commands
//$telegram->addCommandsPath($commands_path);
//$telegram->addCommandsPath($commands_path);
// Enable admin user(s)
// Enable admin user(s)
...
...
src/Commands/SystemCommands/CallbackqueryCommand.php
View file @
aec70278
...
@@ -41,18 +41,11 @@ class CallbackqueryCommand extends SystemCommand
...
@@ -41,18 +41,11 @@ class CallbackqueryCommand extends SystemCommand
*/
*/
public
function
execute
()
public
function
execute
()
{
{
$update
=
$this
->
getUpdate
();
//$callback_query = $this->getUpdate()->getCallbackQuery
();
$callback_query
=
$update
->
getCallbackQuery
();
//$user_id = $callback_query->getFrom()->getId
();
$callback_query_id
=
$callback_query
->
getId
();
//$query_id
= $callback_query->getId();
$callback
_data
=
$callback_query
->
getData
();
//$query
_data = $callback_query->getData();
$data
=
[
return
Request
::
answerCallbackQuery
([
'callback_query_id'
=>
$this
->
getUpdate
()
->
getCallbackQuery
()
->
getId
()]);
'callback_query_id'
=>
$callback_query_id
,
'text'
=>
'Hello World!'
,
'show_alert'
=>
$callback_data
===
'thumb up'
,
'cache_time'
=>
5
,
];
return
Request
::
answerCallbackQuery
(
$data
);
}
}
}
}
src/Commands/SystemCommands/GenericCommand.php
View file @
aec70278
...
@@ -41,23 +41,12 @@ class GenericCommand extends SystemCommand
...
@@ -41,23 +41,12 @@ class GenericCommand extends SystemCommand
*/
*/
public
function
execute
()
public
function
execute
()
{
{
$message
=
$this
->
getMessage
();
//$message = $this->getMessage();
//$chat_id = $message->getChat()->getId();
//$user_id = $message->getFrom()->getId();
//$command = $message->getCommand();
//#text = trim($message->getText(true));
//You can use $command as param
return
parent
::
execute
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$user_id
=
$message
->
getFrom
()
->
getId
();
$command
=
$message
->
getCommand
();
//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
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
'Command /'
.
$command
.
' not found.. :('
,
];
return
Request
::
sendMessage
(
$data
);
}
}
}
}
src/Commands/SystemCommands/GenericmessageCommand.php
View file @
aec70278
...
@@ -63,6 +63,7 @@ class GenericmessageCommand extends SystemCommand
...
@@ -63,6 +63,7 @@ class GenericmessageCommand extends SystemCommand
$this
->
getMessage
()
->
getFrom
()
->
getId
(),
$this
->
getMessage
()
->
getFrom
()
->
getId
(),
$this
->
getMessage
()
->
getChat
()
->
getId
()
$this
->
getMessage
()
->
getChat
()
->
getId
()
);
);
//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
);
return
$this
->
telegram
->
executeCommand
(
$command
);
...
...
src/Commands/SystemCommands/InlinequeryCommand.php
View file @
aec70278
...
@@ -43,42 +43,10 @@ class InlinequeryCommand extends SystemCommand
...
@@ -43,42 +43,10 @@ class InlinequeryCommand extends SystemCommand
*/
*/
public
function
execute
()
public
function
execute
()
{
{
$update
=
$this
->
getUpdate
();
//$inline_query = $this->getUpdate()->getInlineQuery
();
$inline_query
=
$update
->
getInlineQuery
();
//$user_id = $inline_query->getFrom()->getId
();
$query
=
$inline_query
->
getQuery
();
//
$query = $inline_query->getQuery();
$data
=
[
'inline_query_id'
=>
$inline_query
->
getId
()];
return
Request
::
answerInlineQuery
([
'inline_query_id'
=>
$this
->
getUpdate
()
->
getInlineQuery
()
->
getId
()]);
$results
=
[];
if
(
$query
!==
''
)
{
$articles
=
[
[
'id'
=>
'001'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$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
]),
],
[
'id'
=>
'003'
,
'title'
=>
'https://core.telegram.org/bots/api#answerinlinequery'
,
'description'
=>
'you enter: '
.
$query
,
'input_message_content'
=>
new
InputTextMessageContent
([
'message_text'
=>
' '
.
$query
]),
],
];
foreach
(
$articles
as
$article
)
{
$results
[]
=
new
InlineQueryResultArticle
(
$article
);
}
}
$data
[
'results'
]
=
'['
.
implode
(
','
,
$results
)
.
']'
;
return
Request
::
answerInlineQuery
(
$data
);
}
}
}
}
src/Commands/SystemCommands/StartCommand.php
View file @
aec70278
...
@@ -46,16 +46,10 @@ class StartCommand extends SystemCommand
...
@@ -46,16 +46,10 @@ class StartCommand extends SystemCommand
*/
*/
public
function
execute
()
public
function
execute
()
{
{
$message
=
$this
->
getMessage
();
//$message = $this->getMessage();
//$chat_id = $message->getChat()->getId();
//$user_id = $message->getFrom()->getId();
$chat_id
=
$message
->
getChat
()
->
getId
();
return
parent
::
execute
();
$text
=
'Hi there!'
.
PHP_EOL
.
'Type /help to see all commands!'
;
$data
=
[
'chat_id'
=>
$chat_id
,
'text'
=>
$text
,
];
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