This is the calendar in form of inline keyboard intended for using with longman/telegram-bot
and californiamountainsnake/longmantelegrambot-inlinemenu
libraries.
Install this package through Composer.
Edit your project's composer.json
file to require californiamountainsnake/longmantelegrambot-inlinecalendar
:
{
"name": "yourproject/yourproject",
"type": "project",
"require": {
"php": "^7.1",
"californiamountainsnake/longmantelegrambot-inlinecalendar": "*"
}
}
and run composer update
run this command in your command line:
composer require californiamountainsnake/longmantelegrambot-inlinecalendar
<?php
class TestCommand extends BaseUserCommand
{
use InlineCalendar;
}
Create the calendar config:
<?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);
}
}
Use calendar!
<?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;
}
}