zarincheg / telegram-bot-dialogs

The extension for Telegram Bot API PHP SDK that allows to implement dialogs in bots
MIT License
40 stars 27 forks source link

[Request] More docs and examples #5

Closed seyfer closed 7 years ago

seyfer commented 7 years ago

@zarincheg will extension work without Laravel ? I'm use different framework.

Please, provide example of config.php (with description of possible options) file and how to configure dialogues without framework (with which methods and in which order, step by step).

seyfer commented 7 years ago

I could create factory for

/**
 * Class Dialogs
 * @package BotDialogs
 */
class Dialogs

...

/**
     * @param Api $telegram
     * @param Redis $redis
     */
    public function __construct(Api $telegram, Redis $redis)

But it depends on

use Illuminate\Redis\Database as Redis;
use Illuminate\Support\Facades\Config;

How to init and configure this components?

seyfer commented 7 years ago

Connected issue https://github.com/zarincheg/telegram-bot-dialogs/issues/6

zarincheg commented 7 years ago

Hi, thank for question. I developed this extension for Laravel/Lumen usage at first and did not test with another frameworks or stand-alone.

But it depends on

use Illuminate\Redis\Database as Redis;
use Illuminate\Support\Facades\Config;

How to init and configure this components?

You can install this components by composer.

seyfer commented 7 years ago

@zarincheg I'm asking about config file structure. I want to use them in ZF3 factory, something like

$redis = new Redis($config);
$config = new Config($config);

$dialogues = new Dialogues($redis, $config);

return $dialogues;

So, what the structure of the $config should be for manual instantiation?

zarincheg commented 7 years ago
<?php

return [
    /**
     * Aliases for different meanings of words.
     */
    'aliases' => [
        'yes' => ['yes', 'yep', 'да', 'ага', 'угу', 'знаю', 'помню'],
        'no'  => ['no', 'nope', 'нет', 'не знаю', 'незнаю', 'не помню', 'непомню']
    ],
    /**
     * Timeout for dialog memory in seconds
     */
    'expires' => env('DIALOGS_MEMORY_TIMEOUT', 300),
    // It is for YAML-described dialogs, optional
    'scenarios' => [
        \Bot\Telegram\Dialogs\FeedbackDialog::class => base_path('config/dialogs/feedback.yml')
    ],
];
zarincheg commented 7 years ago

Conversation moved to #7