Skip to content

Commit

Permalink
fix: update callback action
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Oct 20, 2023
1 parent 8179f4c commit 0ac06c6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 74 deletions.
2 changes: 2 additions & 0 deletions src/Http/Actions/CallbackAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use LbilTech\TelegramGitNotifier\Bot;
use LbilTech\TelegramGitNotifier\Constants\SettingConstant;
use LbilTech\TelegramGitNotifier\Exceptions\InvalidViewTemplateException;
use LbilTech\TelegramGitNotifier\Exceptions\MessageIsEmptyException;
use LbilTech\TelegramGitNotifierApp\Services\CallbackService;

Expand All @@ -23,6 +24,7 @@ public function __construct(
/**
* @return void
* @throws MessageIsEmptyException
* @throws InvalidViewTemplateException
*/
public function __invoke(): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Actions/CommandAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
*/
public function __invoke(): void
{
$text = $this->bot->getCommandMessage();
$text = $this->bot->telegram->Text();

switch ($text) {
case '/start':
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Actions/IndexAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __invoke(): void
return;
}

if ($this->bot->isMessage()) {
if ($this->bot->isMessage() && $this->bot->isOwner()) {
$commandAction = new CommandAction($this->bot);
$commandAction();
return;
Expand Down
57 changes: 30 additions & 27 deletions src/Services/CommandService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,31 @@

class CommandService
{
public const MENU_COMMANDS = [
[
'command' => '/start',
'description' => 'Welcome to the bot'
], [
'command' => '/menu',
'description' => 'Show menu of the bot'
], [
'command' => '/token',
'description' => 'Show token of the bot'
], [
'command' => '/id',
'description' => 'Show the ID of the current chat'
], [
'command' => '/usage',
'description' => 'Show step by step usage'
], [
'command' => '/server',
'description' => 'To get Server Information'
], [
'command' => '/settings',
'description' => 'Show settings of the bot'
],
];
public const MENU_COMMANDS
= [
[
'command' => '/start',
'description' => 'Welcome to the bot'
], [
'command' => '/menu',
'description' => 'Show menu of the bot'
], [
'command' => '/token',
'description' => 'Show token of the bot'
], [
'command' => '/id',
'description' => 'Show the ID of the current chat'
], [
'command' => '/usage',
'description' => 'Show step by step usage'
], [
'command' => '/server',
'description' => 'To get Server Information'
], [
'command' => '/settings',
'description' => 'Show settings of the bot'
],
];

/**
* Generate menu markup
Expand All @@ -42,9 +43,11 @@ public function menuMarkup(Telegram $telegram): array
{
return [
[
$telegram->buildInlineKeyBoardButton("🗨 Discussion", config('telegram-git-notifier.author.discussion'))
$telegram->buildInlineKeyBoardButton("🗨 Discussion",
config('telegram-git-notifier.author.discussion'))
], [
$telegram->buildInlineKeyBoardButton("💠 Source Code", config('telegram-git-notifier.author.source_code'))
$telegram->buildInlineKeyBoardButton("💠 Source Code",
config('telegram-git-notifier.author.source_code'))
]
];
}
Expand All @@ -63,7 +66,7 @@ public function sendStartMessage(Bot $bot): void
);
$bot->sendPhoto(
__DIR__ . '/../../resources/images/start.png',
$reply
['caption' => $reply]
);
}
}
45 changes: 0 additions & 45 deletions src/Traits/SetFilePathTrait.php

This file was deleted.

0 comments on commit 0ac06c6

Please sign in to comment.