Skip to content

Commit

Permalink
feat: create method to get command messages from telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Oct 14, 2023
1 parent 85dfff5 commit 67c33a4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Interfaces/AppInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,18 @@ public function setCallbackContentMessage(array $options = []): array;
* @return void
*/
public function setCurrentChatId(string $chatId): void;

/**
* Get the username of the bot
*
* @return string|null
*/
public function getBotName(): ?string;

/**
* Get the command message from a telegram
*
* @return string
*/
public function getCommandMessage(): string;
}
11 changes: 11 additions & 0 deletions src/Services/AppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,15 @@ public function setCallbackContentMessage(array $options = []): array

return $content;
}

public function getBotName(): ?string
{
return $this->telegram->getMe()['result']['username'] ?? null;
}

public function getCommandMessage(): string
{
$text = $this->telegram->Text();
return str_replace('@' . $this->getBotName(), '', $text);
}
}

0 comments on commit 67c33a4

Please sign in to comment.