我正在使用集成laravel和php的Botman Studio在电报API中进行聊天机器人。我想计算用户使用聊天机器人的时间。
当用户键入“/ start”时,与bot的对话开始:
我想从那里开始计算将其输入我的数据库的时间,以便知道用户与聊天机器人交互的时间。
我怎么能在谈话中这样做?
<?php
return [
/*
|--------------------------------------------------------------------------
| Conversation Cache Time
|--------------------------------------------------------------------------
|
| BotMan caches each started conversation. This value defines the
| number of minutes that a conversation will remain stored in
| the cache.
|
*/
'conversation_cache_time' => 1,
/*
|--------------------------------------------------------------------------
| User Cache Time
|--------------------------------------------------------------------------
|
| BotMan caches user information of the incoming messages.
| This value defines the number of minutes that this
| data will remain stored in the cache.
|
*/
'user_cache_time' => 1,
];
在这里,我确定在一分钟不活动后,会话停止,我希望在数据库中的会话停止的同时存储时间。我怎么能为它建立一个条件?
好吧,如果您有办法知道用户退出对话,您可以存储用户开始对话的日期时间并存储用户结束对话的日期时间。然后,如果你想知道用户花了多少钱,只需减去endDate - beginDate。在操作Datetimes时,您可以使用Carbon来让您的生活更轻松