californiamountainsnake / longmantelegrambot-utils
This package is abandoned and no longer maintained.
No replacement package was suggested.
This is the set of util traits intended for the longman/telegram-bot library!
1.1.24
2020-01-31 06:10 UTC
Requires
- php: ^7.2
- californiamountainsnake/php-simple-telegram-api: ~2.0.4
- longman/telegram-bot: ~0.59
- myclabs/php-enum: ~1.5
- psr/log: ^1.1
Requires (Dev)
- ext-dom: *
- phpunit/phpunit: ^7.0
README
This is the set of util traits intended for the longman/telegram-bot library!
Functionality:
- Easily send text messages in one line.
Install:
Require this package with Composer
Install this package through Composer.
Edit your project's composer.json
file to require californiamountainsnake/longmantelegrambot-utils
:
{ "name": "yourproject/yourproject", "type": "project", "require": { "php": "^7.2", "californiamountainsnake/longmantelegrambot-utils": "*" } }
and run composer update
or
run this command in your command line:
composer require californiamountainsnake/longmantelegrambot-utils
Usage:
- Create your custom bot command as usual.
- Use needed traits and realise the abstract traits' methods:
<?php class TestCommand extends Command { use TelegramUtils; use SendUtils; use ConversationUtils; /** * @var Conversation|null */ protected $conversation; public function getTelegramMessage(): ?Message { return $this->getMessage(); } protected function getStateNoteName(): string { return 'state'; } protected function getConversation(): ?Conversation { return $this->conversation; } protected function setConversation(?Conversation $_new_conversation_state): void { $this->conversation = $_new_conversation_state; } /** * Execute command * * @return ServerResponse * @throws TelegramException */ public function execute(): ServerResponse { return $this->sendTextMessage('Test!'); } }