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
c7837b02
Commit
c7837b02
authored
Mar 21, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new command structure in examples
parent
9828c736
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
100 deletions
+81
-100
README.md
README.md
+3
-2
ForcereplyCommand.php
examples/Commands/ForcereplyCommand.php
+19
-26
HidekeyboardCommand.php
examples/Commands/HidekeyboardCommand.php
+19
-24
ImageCommand.php
examples/Commands/ImageCommand.php
+19
-18
KeyboardCommand.php
examples/Commands/KeyboardCommand.php
+21
-30
No files found.
README.md
View file @
c7837b02
...
...
@@ -28,7 +28,8 @@ The Bot can:
-
handle commands in chat with other bots.
-
manage Channel from the bot admin interface.
-
full support for
**inline bots**
. (
**new!**
)
-
Messages, InlineQuery and ChosenInlineQuery are stored in the Database. (
**new!**
)
-
Messages, InlineQuery and ChosenInlineQuery are stored in the Database.
-
Conversation feature (
**new!**
)
-----
This code is available on
...
...
@@ -397,7 +398,7 @@ $telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_he
Enabling this feature, the admin bot can perform some super user commands like:
-
Send message to all chats
*/sendtoall*
-
List all the chats started with the bot
*/chats*
-
Send a message
to your channels
*/sendtochannel*
(NEW! see below how to configure it)
-
Post any content
to your channels
*/sendtochannel*
(NEW! see below how to configure it)
You can specify one or more admins with this option:
```
php
...
...
examples/Commands/ForcereplyCommand.php
View file @
c7837b02
<?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.
* Written by <marco.bore@gmail.com>
*/
namespace
Longman\TelegramBot\Commands
;
*/
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
namespace
Longman\TelegramBot\Commands\UserCommands
;
use
Longman\TelegramBot\
Entities\ReplyKeyboardMarkup
;
use
Longman\TelegramBot\
Entities\ReplyKeyboardHide
;
use
Longman\TelegramBot\
Commands\UserCommand
;
use
Longman\TelegramBot\
Request
;
use
Longman\TelegramBot\Entities\ForceReply
;
class
ForceReplyCommand
extends
Command
/**
* User "/forcereply" command
*/
class
ForceReplyCommand
extends
UserCommand
{
/**#@+
* {@inheritdoc}
*/
protected
$name
=
'forcereply'
;
protected
$description
=
'Force reply with reply markup'
;
protected
$usage
=
'/forcereply'
;
protected
$version
=
'0.0.5'
;
protected
$enabled
=
true
;
/**#@-*/
/**
* {@inheritdoc}
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$message_id
=
$message
->
getMessageId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
array
()
;
$data
=
[]
;
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'text'
]
=
'Write something:'
;
#$data['reply_to_message_id'] = $message_id;
$force_reply
=
new
ForceReply
([
'selective'
=>
false
]);
#echo $json;
$data
[
'reply_markup'
]
=
$force_reply
;
$data
[
'reply_markup'
]
=
new
ForceReply
([
'selective'
=>
false
]);
$result
=
Request
::
sendMessage
(
$data
);
return
$result
;
return
Request
::
sendMessage
(
$data
);
}
}
examples/Commands/HidekeyboardCommand.php
View file @
c7837b02
<?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.
* Written by Marco Boretto <marco.bore@gmail.com>
*/
namespace
Longman\TelegramBot\Commands
;
*/
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
namespace
Longman\TelegramBot\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommand
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Entities\ReplyKeyboardMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardHide
;
use
Longman\TelegramBot\Entities\ForceReply
;
class
HidekeyboardCommand
extends
Command
/**
* User "/hidekeyboard" command
*/
class
HidekeyboardCommand
extends
UserCommand
{
/**#@+
* {@inheritdoc}
*/
protected
$name
=
'hidekeyboard'
;
protected
$description
=
'Hide the custom keyboard'
;
protected
$usage
=
'/hidekeyboard'
;
protected
$version
=
'0.0.5'
;
protected
$enabled
=
true
;
/**#@-*/
/**
* {@inheritdoc}
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$message_id
=
$message
->
getMessageId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
array
()
;
$data
=
[]
;
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'text'
]
=
'Keyboard Hided'
;
#$data['reply_to_message_id'] = $message_id;
$reply_keyboard_hide
=
new
ReplyKeyboardHide
([
'selective'
=>
false
]);
$data
[
'reply_markup'
]
=
$reply_keyboard_hide
;
$data
[
'reply_markup'
]
=
new
ReplyKeyboardHide
([
'selective'
=>
false
]);
$result
=
Request
::
sendMessage
(
$data
);
return
$result
;
return
Request
::
sendMessage
(
$data
);
}
}
examples/Commands/ImageCommand.php
View file @
c7837b02
<?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
;
*/
namespace
Longman\TelegramBot\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommand
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
use
Longman\TelegramBot\Entities\ReplyKeyboardMarkup
;
class
ImageCommand
extends
Command
/**
* User "/image" command
*/
class
ImageCommand
extends
UserCommand
{
/**#@+
* {@inheritdoc}
*/
protected
$name
=
'image'
;
protected
$description
=
'Send Image'
;
protected
$usage
=
'/image'
;
protected
$version
=
'1.0.0'
;
protected
$enabled
=
true
;
protected
$public
=
true
;
/**#@-*/
/**
* {@inheritdoc}
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
array
()
;
$data
=
[]
;
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'caption'
]
=
$text
;
//$result = Request::sendDocument($data,'structure.sql');
//$result = Request::sendSticker($data, $this->telegram->getUploadPath().'/'.'image.jpg');
$result
=
Request
::
sendPhoto
(
$data
,
$this
->
telegram
->
getUploadPath
()
.
'/'
.
'image.jpg'
);
return
$result
;
return
Request
::
sendPhoto
(
$data
,
$this
->
telegram
->
getUploadPath
()
.
'/'
.
'image.jpg'
);
}
}
examples/Commands/KeyboardCommand.php
View file @
c7837b02
<?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.
* written by Marco Boretto <marco.bore@gmail.com>
*/
namespace
Longman\TelegramBot\Commands
;
*/
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Command
;
use
Longman\TelegramBot\Entities\Update
;
namespace
Longman\TelegramBot\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommand
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Entities\ReplyKeyboardMarkup
;
use
Longman\TelegramBot\Entities\ReplyKeyboardHide
;
use
Longman\TelegramBot\Entities\ForceReply
;
class
KeyboardCommand
extends
Command
/**
* User "/keyboard" command
*/
class
KeyboardCommand
extends
UserCommand
{
/**#@+
* {@inheritdoc}
*/
protected
$name
=
'keyboard'
;
protected
$description
=
'Show a custom keybord with reply markup'
;
protected
$usage
=
'/keyboard'
;
protected
$version
=
'0.0.5'
;
protected
$enabled
=
true
;
/**#@-*/
/**
* {@inheritdoc}
*/
public
function
execute
()
{
$update
=
$this
->
getUpdate
();
$message
=
$this
->
getMessage
();
$message_id
=
$message
->
getMessageId
();
$chat_id
=
$message
->
getChat
()
->
getId
();
$text
=
$message
->
getText
(
true
);
$data
=
array
()
;
$data
=
[]
;
$data
[
'chat_id'
]
=
$chat_id
;
$data
[
'text'
]
=
'Press a Button:'
;
#$data['reply_to_message_id'] = $message_id;
#Keyboard examples
$keyboards
=
array
();
//Keyboard examples
$keyboards
=
[];
//0
$keyboard
[]
=
[
'7'
,
'8'
,
'9'
];
...
...
@@ -64,7 +62,6 @@ class KeyboardCommand extends Command
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//2
$keyboard
[]
=
[
'A'
];
$keyboard
[]
=
[
'B'
];
...
...
@@ -73,8 +70,6 @@ class KeyboardCommand extends Command
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
//3
$keyboard
[]
=
[
'A'
];
$keyboard
[]
=
[
'B'
];
...
...
@@ -83,8 +78,7 @@ class KeyboardCommand extends Command
$keyboards
[]
=
$keyboard
;
unset
(
$keyboard
);
$reply_keyboard_markup
=
new
ReplyKeyboardMarkup
(
$data
[
'reply_markup'
]
=
new
ReplyKeyboardMarkup
(
[
'keyboard'
=>
$keyboards
[
1
]
,
'resize_keyboard'
=>
true
,
...
...
@@ -92,10 +86,7 @@ class KeyboardCommand extends Command
'selective'
=>
false
]
);
#echo $json;
$data
[
'reply_markup'
]
=
$reply_keyboard_markup
;
$result
=
Request
::
sendMessage
(
$data
);
return
$result
;
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