Skip to content

Commit

Permalink
Merge pull request #15 from tanhongit/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tanhongit authored Oct 13, 2023
2 parents 51671f5 + b1c5cd9 commit 22706e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/tg-notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
],

'author' => [
'contact' => $_ENV['TGN_AUTHOR_CONTACT'] ??
'https://t.me/tannp27',
'discussion' => $_ENV['TGN_AUTHOR_DISCUSSION'] ??
'https://github.com/lbiltech/telegram-git-notifier/discussions',
'source_code' => $_ENV['TGN_AUTHOR_SOURCE_CODE'] ??
'https://github.com/lbiltech/telegram-git-notifier',
],
Expand Down
7 changes: 7 additions & 0 deletions src/Interfaces/TelegramInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ public function isCallback(): bool;
* @return bool
*/
public function isMessage(): bool;

/**
* Check owner of a telegram
*
* @return bool
*/
public function isOwner(): bool;
}
2 changes: 1 addition & 1 deletion src/Services/AppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AppService implements AppInterface
{
public Telegram $telegram;

protected string $chatId;
public string $chatId;

public function __construct(Telegram $telegram = null)
{
Expand Down
15 changes: 14 additions & 1 deletion src/Services/TelegramService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ class TelegramService extends AppService implements TelegramInterface
public Telegram $telegram;

public function __construct(
Telegram $telegram
Telegram $telegram,
?string $chatId = null
) {
parent::__construct($telegram);
$this->setCurrentChatId($chatId);

$this->telegram = $telegram;
}

public function setMyCommands(
Expand Down Expand Up @@ -47,4 +51,13 @@ public function isMessage(): bool

return false;
}

public function isOwner(): bool
{
if ($this->telegram->ChatID() == $this->chatId) {
return true;
}

return false;
}
}

0 comments on commit 22706e9

Please sign in to comment.