californiamountainsnake / longmantelegrambot-inlinecalendar
该包已被弃用,不再维护。未建议替代包。
这是一个以内嵌键盘形式的日历。
1.4.3
2021-05-03 11:15 UTC
Requires
- php: ^7.1
- ext-curl: *
- ext-json: *
- californiamountainsnake/longmantelegrambot-inlinemenu: ^1.2.0
- californiamountainsnake/php-utils: ^1.0.11
- myclabs/php-enum: ^1.5
- psr/log: ^1.1
Requires (Dev)
- ext-dom: *
- phpunit/phpunit: ^7.0
README
这是一个以内嵌键盘形式的日历,用于与 longman/telegram-bot
和 californiamountainsnake/longmantelegrambot-inlinemenu
库一起使用。
安装
使用 Composer 需求此包
通过 Composer 安装此包。编辑您项目的 composer.json
文件,以需求 californiamountainsnake/longmantelegrambot-inlinecalendar
{ "name": "yourproject/yourproject", "type": "project", "require": { "php": "^7.1", "californiamountainsnake/longmantelegrambot-inlinecalendar": "*" } }
并运行 composer update
或者
在命令行中运行此命令
composer require californiamountainsnake/longmantelegrambot-inlinecalendar
用法
- 将特质包含到您的机器人命令中并实现抽象方法(主要包含语言字符串)
<?php class TestCommand extends BaseUserCommand { use InlineCalendar; }
- 创建日历配置
<?php class TestCommand extends BaseUserCommand { use InlineCalendar; private function getCalendarConfig(): CalendarConfig { $min = [2019, 8, 28]; $max = [2037, 12, 31]; $def = $min; return new CalendarConfig('Date selection', $min, $max, $def); } }
- 使用日历!
<?php class TestCommand extends BaseUserCommand { use InlineCalendar; public function execute(): ServerResponse { // Conversation start $this->startConversation(); $isSelected = $this->selectDate($this->getCalendarConfig(), 'Please select the date:', $this->getMessage()); if (!$isSelected) { return $this->emptyResponse(); } $msg = $this->sendTextMessage (\print_r($this->getCalendarDate($this->getCalendarConfig()), true)); $this->stopConversation(); return $msg; } }