Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build core #100

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 11 additions & 5 deletions src/Services/CallbackService.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\MessageIsEmptyException;

class CallbackService
{
Expand All @@ -18,7 +19,9 @@ public function __construct(Bot $bot)
* Answer the back button
*
* @param string $callback
*
* @return void
* @throws MessageIsEmptyException
*/
public function answerBackButton(string $callback): void
{
Expand All @@ -30,17 +33,20 @@ public function answerBackButton(string $callback): void
$markup = $this->bot->settingMarkup();
break;
case 'settings.custom_events.github':
$view = view('tools.custom_events', ['platform' => 'github']);
$view = view('tools.custom_event', ['platform' => 'github']);
$markup = $this->bot->eventMarkup();
break;
case 'settings.custom_events.gitlab':
$view = view('tools.custom_events', ['platform' => 'gitlab']);
$view = view('tools.custom_event', ['platform' => 'gitlab']);
$markup = $this->bot->eventMarkup(null, 'gitlab');
break;
default:
case 'menu':
$view = view('tools.menu');
$markup = $this->menuMarkup();
break;
default:
$this->bot->answerCallbackQuery('Unknown callback');
return;
}

$this->bot->editMessageText($view, [
Expand All @@ -55,9 +61,9 @@ public function menuMarkup(): array
{
return [
[
$this->bot->telegram->buildInlineKeyBoardButton("📞 Contact", config('author.contact'))
$this->bot->telegram->buildInlineKeyBoardButton('🗨 Discussion', config('telegram-git-notifier.author.discussion'))
], [
$this->bot->telegram->buildInlineKeyBoardButton("💠 Source Code", config('author.source_code'))
$this->bot->telegram->buildInlineKeyBoardButton('💠 Source Code', config('telegram-git-notifier.author.source_code'))
]
];
}
Expand Down
51 changes: 26 additions & 25 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' => 'Go to settings of the bot'
],
];

/**
* Generate menu markup
Expand Down Expand Up @@ -63,7 +64,7 @@ public function sendStartMessage(Bot $bot): void
);
$bot->sendPhoto(
__DIR__ . '/../../resources/images/start.png',
$reply
['caption' => $reply]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update sendPhoto method to sync the core

);
}
}
45 changes: 0 additions & 45 deletions src/Traits/SetFilePathTrait.php

This file was deleted.