-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from tanhongit/refactor
Refactor
- Loading branch information
Showing
33 changed files
with
423 additions
and
234 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace LbilTech\TelegramGitNotifier; | ||
|
||
use LbilTech\TelegramGitNotifier\Constants\EventConstant; | ||
use LbilTech\TelegramGitNotifier\Interfaces\BotInterface; | ||
use LbilTech\TelegramGitNotifier\Interfaces\Structures\AppInterface; | ||
use LbilTech\TelegramGitNotifier\Interfaces\EventInterface; | ||
use LbilTech\TelegramGitNotifier\Models\Event; | ||
use LbilTech\TelegramGitNotifier\Models\Setting; | ||
use LbilTech\TelegramGitNotifier\Structures\App; | ||
use LbilTech\TelegramGitNotifier\Structures\TelegramBot; | ||
use LbilTech\TelegramGitNotifier\Trait\BotSettingTrait; | ||
use LbilTech\TelegramGitNotifier\Trait\EventSettingTrait; | ||
use LbilTech\TelegramGitNotifier\Trait\EventTrait; | ||
use Telegram; | ||
|
||
class Bot implements AppInterface, BotInterface, EventInterface | ||
{ | ||
use App; | ||
use TelegramBot; | ||
|
||
use EventTrait; | ||
use BotSettingTrait; | ||
use EventSettingTrait; | ||
|
||
public Event $event; | ||
|
||
public Setting $setting; | ||
|
||
public function __construct( | ||
Telegram $telegram = null, | ||
?string $chatBotId = null, | ||
Setting $setting = null, | ||
Event $event = null, | ||
?string $settingFile = null, | ||
?string $platform = EventConstant::DEFAULT_PLATFORM, | ||
?string $platformFile = null, | ||
) { | ||
$this->telegram = $telegram ?? new Telegram(config('telegram-git-notifier.bot.token')); | ||
$this->setCurrentChatBotId($chatBotId); | ||
$this->event = $event ?? new Event(); | ||
$this->setPlatFormForEvent($platform, $platformFile); | ||
|
||
$this->setting = $setting ?? new Setting(); | ||
$this->updateSetting($settingFile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace LbilTech\TelegramGitNotifier\Constants; | ||
|
||
final class NotificationConstant | ||
{ | ||
// Separation between chat id pairs | ||
public const CHAT_ID_PAIRS_SEPARATOR = ';'; | ||
|
||
// Separation between chat id and thread id | ||
public const CHAT_THREAD_ID_SEPARATOR = ':'; | ||
|
||
// Separation between thread id | ||
public const THREAD_ID_SEPARATOR = ','; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace LbilTech\TelegramGitNotifier\Exceptions; | ||
|
||
use Exception; | ||
|
||
class TelegramGitNotifierException extends Exception | ||
{ | ||
public static function isEmpty(): self | ||
{ | ||
return new static('Telegram Git Notifier is empty'); | ||
} | ||
|
||
public static function invalid(): self | ||
{ | ||
return new static('Telegram Git Notifier is invalid'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.