Skip to content

Commit 41cbf84

Browse files
authored
Merge pull request #101 from tanhongit/build-core
fix: optimize code
2 parents 72c3d02 + b1b419b commit 41cbf84

File tree

6 files changed

+33
-35
lines changed

6 files changed

+33
-35
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lbiltech/telegram-git-notifier-app",
3-
"description": "Send notification from Gitlab and Github events to Telegram",
3+
"description": "The PHP app to send notification from Gitlab and Github events to Telegram",
44
"keywords": [
55
"lbiltech",
66
"telegram-bot",
@@ -22,7 +22,7 @@
2222
"require": {
2323
"php": "^8.0",
2424
"ext-json": "*",
25-
"lbiltech/telegram-git-notifier": "dev-main"
25+
"lbiltech/telegram-git-notifier": "^1.2.0"
2626
},
2727
"autoload": {
2828
"psr-4": {
File renamed without changes.

src/Services/CallbackService.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
use LbilTech\TelegramGitNotifier\Bot;
66
use LbilTech\TelegramGitNotifier\Constants\SettingConstant;
77
use LbilTech\TelegramGitNotifier\Exceptions\MessageIsEmptyException;
8+
use LbilTech\TelegramGitNotifierApp\Traits\Markup;
89

910
class CallbackService
1011
{
12+
use Markup;
13+
1114
private Bot $bot;
1215

1316
public function __construct(Bot $bot)
@@ -42,7 +45,7 @@ public function answerBackButton(string $callback): void
4245
break;
4346
case 'menu':
4447
$view = view('tools.menu');
45-
$markup = $this->menuMarkup();
48+
$markup = $this->menuMarkup($this->bot->telegram);
4649
break;
4750
default:
4851
$this->bot->answerCallbackQuery('Unknown callback');
@@ -53,18 +56,4 @@ public function answerBackButton(string $callback): void
5356
'reply_markup' => $markup,
5457
]);
5558
}
56-
57-
/**
58-
* @return array[]
59-
*/
60-
public function menuMarkup(): array
61-
{
62-
return [
63-
[
64-
$this->bot->telegram->buildInlineKeyBoardButton('🗨 Discussion', config('telegram-git-notifier.author.discussion'))
65-
], [
66-
$this->bot->telegram->buildInlineKeyBoardButton('💠 Source Code', config('telegram-git-notifier.author.source_code'))
67-
]
68-
];
69-
}
7059
}

src/Services/CommandService.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
use LbilTech\TelegramGitNotifier\Bot;
66
use LbilTech\TelegramGitNotifier\Exceptions\EntryNotFoundException;
7-
use Telegram;
7+
use LbilTech\TelegramGitNotifierApp\Traits\Markup;
88

99
class CommandService
1010
{
11+
use Markup;
12+
1113
public const MENU_COMMANDS
1214
= [
1315
[
@@ -34,22 +36,6 @@ class CommandService
3436
],
3537
];
3638

37-
/**
38-
* Generate menu markup
39-
*
40-
* @return array[]
41-
*/
42-
public function menuMarkup(Telegram $telegram): array
43-
{
44-
return [
45-
[
46-
$telegram->buildInlineKeyBoardButton("🗨 Discussion", config('telegram-git-notifier.author.discussion'))
47-
], [
48-
$telegram->buildInlineKeyBoardButton("💠 Source Code", config('telegram-git-notifier.author.source_code'))
49-
]
50-
];
51-
}
52-
5339
/**
5440
* @param Bot $bot
5541
*

src/Traits/Markup.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace LbilTech\TelegramGitNotifierApp\Traits;
4+
5+
use Telegram;
6+
7+
trait Markup
8+
{
9+
/**
10+
* Generate menu markup
11+
*
12+
* @return array[]
13+
*/
14+
public function menuMarkup(Telegram $telegram): array
15+
{
16+
return [
17+
[
18+
$telegram->buildInlineKeyBoardButton('🗨 Discussion', config('telegram-git-notifier.author.discussion'))
19+
], [
20+
$telegram->buildInlineKeyBoardButton('💠 Source Code', config('telegram-git-notifier.author.source_code'))
21+
]
22+
];
23+
}
24+
}

storage/.htaccess

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)