Skip to content

Commit 258c8ec

Browse files
authored
Merge pull request #47 from IgorMonkey/fixed
Bugfix of GenericmessageCommand, instruction update
2 parents 2c8051a + de0240c commit 258c8ec

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

readme.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,66 @@
55

66
## Installation
77

8-
Via Composer
8+
Install this package through Composer. Run this command in your project's terminal:
99

1010
``` bash
11-
$ composer require php-telegram-bot/laravel
11+
composer require php-telegram-bot/laravel
1212
```
13-
1413
## Usage
14+
For further basic configuration of this Laravel package you do not need to create any configuration files.
15+
16+
Artisan terminal commands for the Webhook usage (remember, that you need an HTTPS server for it):
17+
``` bash
18+
# Use this method to specify a url and receive incoming updates via an outgoing webhook
19+
php artisan telegram:set-webhook
20+
# List of available options:
21+
# --d|drop-pending-updates : Drop all pending updates
22+
# --a|all-update-types : Explicitly allow all updates (including "chat_member")
23+
# --allowed-updates= : Define allowed updates (comma-seperated)
24+
25+
# Use this method to remove webhook integration if you decide to switch back to getUpdates
26+
php artisan telegram:delete-webhook
27+
# List of available options:
28+
# --d|drop-pending-updates : Pass to drop all pending updates
29+
```
30+
Artisan terminal commands for the Telegram getUpdates method:
31+
``` bash
32+
# Fetches Telegram updates periodically
33+
php artisan telegram:fetch
34+
# List of available options:
35+
# --a|all-update-types : Explicitly allow all updates (including "chat_member")
36+
# --allowed-updates= : Define allowed updates (comma-seperated)
37+
```
38+
Artisan terminal command for Telegram Server logging out:
39+
``` bash
40+
# Sends a logout to the currently registered Telegram Server
41+
php artisan telegram:logout
42+
```
43+
Artisan terminal command for closing Telegram Server:
44+
``` bash
45+
# Sends a close to the currently registered Telegram Server
46+
php artisan telegram:close
47+
```
48+
Artisan terminal command for publishing Telegram command folder structure in your project:
49+
``` bash
50+
# Publishes folder structure for Telegram Commands
51+
# Default StartCommand class will be created
52+
php artisan telegram:publish
53+
```
54+
Artisan terminal command for creating new Telegram command class in your project:
55+
``` bash
56+
# Create a new Telegram Bot Command class
57+
# e.g. php artisan make:telegram-command Menu --> will make User command class MenuCommand
58+
# e.g. php artisan make:telegram-command Genericmessage --system --> will make System command class GenericmessageCommand
59+
php artisan make:telegram-command
60+
# List of available options:
61+
# name : Name of the Telegram Command
62+
# --a|admin : Generate a AdminCommand
63+
# --s|system : Generate a SystemCommand
64+
# Without admin or system option default User command will be created
65+
```
66+
67+
1568

1669
## Credits
1770

src/Telegram/Commands/GenericmessageCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PhpTelegramBot\Laravel\Telegram\Commands;
44

5+
use Illuminate\Support\Facades\App;
56
use Longman\TelegramBot\Commands\SystemCommand;
67
use Longman\TelegramBot\Conversation;
78
use Longman\TelegramBot\Entities\ServerResponse;
@@ -38,6 +39,14 @@ public function execute(): ServerResponse
3839
return $this->getTelegram()->executeCommand($command);
3940
}
4041

42+
// Check if own GenericmessageCommand class is available
43+
$class = App::getNamespace() . 'Telegram\\Commands\\GenericmessageCommand';
44+
if (class_exists($class) && is_subclass_of($class, SystemCommand::class)) {
45+
/** @var SystemCommand $command */
46+
$command = new $class($this->telegram, $this->update);
47+
return $command->preExecute();
48+
}
49+
4150
return Request::emptyResponse();
4251
}
4352

0 commit comments

Comments
 (0)