californiamountainsnake/longmantelegrambot-inlinecalendar

This package is abandoned and no longer maintained. No replacement package was suggested.

This is the calendar in form of inline keyboard.

1.4.3 2021-05-03 11:15 UTC

This package is auto-updated.

Last update: 2022-05-31 00:18:57 UTC


README

This is the calendar in form of inline keyboard intended for using with longman/telegram-bot and californiamountainsnake/longmantelegrambot-inlinemenu libraries. Calendar screenshot

Install:

Require this package with Composer

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

or

run this command in your command line:

composer require californiamountainsnake/longmantelegrambot-inlinecalendar

Usage:

  1. Include trait into your bot command and realise the abstract methods (mostly contains lang strings):
<?php
class TestCommand extends BaseUserCommand
{
    use InlineCalendar;
}
  1. 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);
    }
}
  1. 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;
    }
}