californiamountainsnake / longmantelegrambot-utils
此包已被弃用且不再维护。未建议替代包。
这是为 longman/telegram-bot 库设计的 util 特性集!
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
这是为 longman/telegram-bot 库设计的 util 特性集!
功能
- 一行即可轻松发送文本消息。
安装
使用 Composer 安装此包
通过 Composer 安装此包。编辑你的项目 composer.json
文件,以需要 californiamountainsnake/longmantelegrambot-utils
{ "name": "yourproject/yourproject", "type": "project", "require": { "php": "^7.2", "californiamountainsnake/longmantelegrambot-utils": "*" } }
并运行 composer update
或者
在命令行中运行此命令
composer require californiamountainsnake/longmantelegrambot-utils
使用方法
- 像往常一样创建自定义机器人命令。
- 使用所需的特性和实现抽象特性的方法
<?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!'); } }