Skip to content

Commit b14742a

Browse files
committed
Merge branch 'master' into feature/logger
2 parents b1184d8 + 999ee2e commit b14742a

17 files changed

+1430
-174
lines changed

.travis.yml

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
sudo: false
2+
13
language: php
24

35
php:
@@ -6,25 +8,27 @@ php:
68
- 7.0
79
- hhvm
810

9-
sudo: false
11+
matrix:
12+
allow_failures:
13+
- php: hhvm
14+
fast_finish: true
15+
16+
notifications:
17+
on_success: never
18+
on_failure: always
19+
20+
git:
21+
depth: 1
1022

1123
before_install:
1224
- composer self-update
1325

1426
install:
1527
- travis_retry composer install --no-interaction
1628

29+
before_script:
30+
- mysql -e 'create database telegrambot; use telegrambot; source structure.sql;'
31+
1732
script:
1833
- vendor/bin/phpunit
19-
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '7.0' ]; then vendor/bin/phpcs --report=full --extensions=php -np --standard=build/phpcs .; fi"
20-
21-
matrix:
22-
allow_failures:
23-
- php: hhvm
24-
- php: 7.0
25-
fast_finish: true
26-
27-
28-
notifications:
29-
on_success: never
30-
on_failure: always
34+
- vendor/bin/phpcs --report=full --extensions=php -np --standard=build/phpcs .

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ The Bot can:
2828
- handle commands in chat with other bots.
2929
- manage Channel from the bot admin interface.
3030
- full support for **inline bots**. (**new!**)
31-
- Messages, InlineQuery and ChosenInlineQuery are stored in the Database. (**new!**)
31+
- Messages, InlineQuery and ChosenInlineQuery are stored in the Database.
32+
- Conversation feature (**new!**)
3233

3334
-----
3435
This code is available on
@@ -348,7 +349,7 @@ You can also store inline query and chosen inline query in the database.
348349
### Channels Support
349350

350351
All methods implemented can be used to manage channels.
351-
With [admin commands](#admin-commands) you can manage your channel directly with your bot private chat.
352+
With [admin commands](#admin-commands) you can manage your channels directly with your bot private chat.
352353

353354
### Commands
354355

@@ -397,7 +398,7 @@ $telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_he
397398
Enabling this feature, the admin bot can perform some super user commands like:
398399
- Send message to all chats */sendtoall*
399400
- List all the chats started with the bot */chats*
400-
- Send a message to a channel */sendtochannel* (NEW! see below how to configure it)
401+
- Post any content to your channels */sendtochannel* (NEW! see below how to configure it)
401402
You can specify one or more admins with this option:
402403

403404
```php
@@ -414,7 +415,11 @@ To enable this feature follow these steps:
414415
- Enable admin interface for your user as explained in the admin section above.
415416
- Enter your channel name as a parameter for the */sendtochannel* command:
416417
```php
417-
$telegram->setCommandConfig('sendtochannel', ['your_channel' => '@type_here_your_channel']);
418+
$telegram->setCommandConfig('sendtochannel', ['your_channel' => ['@type_here_your_channel']]);
419+
```
420+
- If you want to manage more channels:
421+
```php
422+
$telegram->setCommandConfig('sendtochannel', ['your_channel'=>['@type_here_your_channel', '@type_here_another_channel', '@and_so_on']]);
418423
```
419424
- Enjoy!
420425

+19-26
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,46 @@
11
<?php
2-
3-
/*
2+
/**
43
* This file is part of the TelegramBot package.
54
*
65
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
76
*
87
* For the full copyright and license information, please view the LICENSE
98
* file that was distributed with this source code.
10-
* Written by <[email protected]>
11-
*/
12-
namespace Longman\TelegramBot\Commands;
9+
*/
1310

14-
use Longman\TelegramBot\Request;
15-
use Longman\TelegramBot\Command;
16-
use Longman\TelegramBot\Entities\Update;
11+
namespace Longman\TelegramBot\Commands\UserCommands;
1712

18-
use Longman\TelegramBot\Entities\ReplyKeyboardMarkup;
19-
use Longman\TelegramBot\Entities\ReplyKeyboardHide;
13+
use Longman\TelegramBot\Commands\UserCommand;
14+
use Longman\TelegramBot\Request;
2015
use Longman\TelegramBot\Entities\ForceReply;
2116

22-
class ForceReplyCommand extends Command
17+
/**
18+
* User "/forcereply" command
19+
*/
20+
class ForceReplyCommand extends UserCommand
2321
{
22+
/**#@+
23+
* {@inheritdoc}
24+
*/
2425
protected $name = 'forcereply';
2526
protected $description = 'Force reply with reply markup';
2627
protected $usage = '/forcereply';
2728
protected $version = '0.0.5';
28-
protected $enabled = true;
29+
/**#@-*/
2930

31+
/**
32+
* {@inheritdoc}
33+
*/
3034
public function execute()
3135
{
32-
$update = $this->getUpdate();
3336
$message = $this->getMessage();
34-
$message_id = $message->getMessageId();
35-
3637
$chat_id = $message->getChat()->getId();
37-
$text = $message->getText(true);
3838

39-
$data = array();
39+
$data = [];
4040
$data['chat_id'] = $chat_id;
4141
$data['text'] = 'Write something:';
42-
#$data['reply_to_message_id'] = $message_id;
43-
44-
$force_reply = new ForceReply(['selective' => false]);
45-
46-
#echo $json;
47-
$data['reply_markup'] = $force_reply;
48-
42+
$data['reply_markup'] = new ForceReply(['selective' => false]);
4943

50-
$result = Request::sendMessage($data);
51-
return $result;
44+
return Request::sendMessage($data);
5245
}
5346
}
+19-24
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,46 @@
11
<?php
2-
3-
/*
2+
/**
43
* This file is part of the TelegramBot package.
54
*
65
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
76
*
87
* For the full copyright and license information, please view the LICENSE
98
* file that was distributed with this source code.
10-
* Written by Marco Boretto <[email protected]>
11-
*/
12-
namespace Longman\TelegramBot\Commands;
9+
*/
1310

14-
use Longman\TelegramBot\Request;
15-
use Longman\TelegramBot\Command;
16-
use Longman\TelegramBot\Entities\Update;
11+
namespace Longman\TelegramBot\Commands\UserCommands;
1712

13+
use Longman\TelegramBot\Commands\UserCommand;
14+
use Longman\TelegramBot\Request;
1815
use Longman\TelegramBot\Entities\ReplyKeyboardMarkup;
19-
use Longman\TelegramBot\Entities\ReplyKeyboardHide;
20-
use Longman\TelegramBot\Entities\ForceReply;
2116

22-
class HidekeyboardCommand extends Command
17+
/**
18+
* User "/hidekeyboard" command
19+
*/
20+
class HidekeyboardCommand extends UserCommand
2321
{
22+
/**#@+
23+
* {@inheritdoc}
24+
*/
2425
protected $name = 'hidekeyboard';
2526
protected $description = 'Hide the custom keyboard';
2627
protected $usage = '/hidekeyboard';
2728
protected $version = '0.0.5';
28-
protected $enabled = true;
29+
/**#@-*/
2930

31+
/**
32+
* {@inheritdoc}
33+
*/
3034
public function execute()
3135
{
32-
$update = $this->getUpdate();
3336
$message = $this->getMessage();
34-
$message_id = $message->getMessageId();
35-
3637
$chat_id = $message->getChat()->getId();
37-
$text = $message->getText(true);
3838

39-
$data = array();
39+
$data = [];
4040
$data['chat_id'] = $chat_id;
4141
$data['text'] = 'Keyboard Hided';
42-
#$data['reply_to_message_id'] = $message_id;
43-
44-
$reply_keyboard_hide = new ReplyKeyboardHide([ 'selective' => false]);
45-
46-
$data['reply_markup'] = $reply_keyboard_hide;
42+
$data['reply_markup'] = new ReplyKeyboardHide([ 'selective' => false]);
4743

48-
$result = Request::sendMessage($data);
49-
return $result;
44+
return Request::sendMessage($data);
5045
}
5146
}

examples/Commands/ImageCommand.php

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
11
<?php
2-
3-
/*
2+
/**
43
* This file is part of the TelegramBot package.
54
*
65
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
76
*
87
* For the full copyright and license information, please view the LICENSE
98
* file that was distributed with this source code.
10-
*/
11-
namespace Longman\TelegramBot\Commands;
9+
*/
10+
11+
namespace Longman\TelegramBot\Commands\UserCommands;
1212

13+
use Longman\TelegramBot\Commands\UserCommand;
1314
use Longman\TelegramBot\Request;
14-
use Longman\TelegramBot\Command;
15-
use Longman\TelegramBot\Entities\Update;
15+
use Longman\TelegramBot\Entities\ReplyKeyboardMarkup;
1616

17-
class ImageCommand extends Command
17+
/**
18+
* User "/image" command
19+
*/
20+
class ImageCommand extends UserCommand
1821
{
22+
/**#@+
23+
* {@inheritdoc}
24+
*/
1925
protected $name = 'image';
2026
protected $description = 'Send Image';
2127
protected $usage = '/image';
2228
protected $version = '1.0.0';
23-
protected $enabled = true;
24-
protected $public = true;
29+
/**#@-*/
2530

31+
/**
32+
* {@inheritdoc}
33+
*/
2634
public function execute()
2735
{
28-
$update = $this->getUpdate();
2936
$message = $this->getMessage();
30-
3137
$chat_id = $message->getChat()->getId();
3238
$text = $message->getText(true);
3339

34-
$data = array();
40+
$data = [];
3541
$data['chat_id'] = $chat_id;
3642
$data['caption'] = $text;
3743

38-
39-
//$result = Request::sendDocument($data,'structure.sql');
40-
//$result = Request::sendSticker($data, $this->telegram->getUploadPath().'/'.'image.jpg');
41-
42-
$result = Request::sendPhoto($data, $this->telegram->getUploadPath().'/'.'image.jpg');
43-
return $result;
44+
return Request::sendPhoto($data, $this->telegram->getUploadPath().'/'.'image.jpg');
4445
}
4546
}

0 commit comments

Comments
 (0)