【问题标题】:Botman conversation cache time not workingBotman 对话缓存时间不起作用
【发布时间】:2021-01-22 04:53:53
【问题描述】:

BotMan 版本:2.6

PHP 版本:7.3.23

Laravel 版本:7.16.1

缓存驱动:LaravelCache

我将botman 用于电报机器人。 botman 一切正常,只是对话缓存时间不起作用。 这是我的 botman 配置代码:

use BotMan\BotMan\Cache\LaravelCache;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\BotMan\BotManFactory;

$config = [
    // Your driver-specific configuration
    "botman" => [
        'conversation_cache_time' => 720 ,
        'user_cache_time' => 720,
    ],
    "telegram" => [
        "token" => env('TELEGRAM_TOKEN'),
    ]
];
// Load the driver(s) you want to use
DriverManager::loadDriver(\BotMan\Drivers\Telegram\TelegramDriver::class);

// Create an instance
$botman = BotManFactory::create($config, new LaravelCache());

//  and other hears , fallback and conversations functions ...

关于机器人和对话的一切都很好,但问题在于对话的现金时间 基于conversation document,我们必须使用驱动器缓存来使用对话,我使用的驱动程序是 laravelCache 但我将conversation_cache_time 设置为 720 分钟,但它只需要默认的 30 分钟。

我该怎么办?

提前致谢。

【问题讨论】:

    标签: php laravel botman


    【解决方案1】:

    从他们的 github 中的这些行:

    https://github.com/botman/botman/blob/79310f6e6464436aaa2d0522267b2ca00a07fda5/tests/BotManConversationTest.php#L79-L83

    https://github.com/botman/botman/blob/4ec6e3f30d620cbcb73a0cf8e1dbf6b34e47f75d/src/Traits/HandlesConversations.php#L47

    https://github.com/botman/botman/blob/203e7f5ef68473dd4d71ca7ee31275eae9a92745/src/BotMan.php#L238-L239

    一定是这样的:

    $config = [
        'user_cache_time' => 720,
    
        'config' => [
            'conversation_cache_time' => 720 ,
        ],
    
        // Your driver-specific configuration
        "telegram" => [
            "token" => env('TELEGRAM_TOKEN'),
        ]
    ];
    
    

    它有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 2020-04-16
      相关资源
      最近更新 更多