answerBot method

Future<void> answerBot({
  1. required LiveBroadcastItem liveBroadcastItem,
  2. required Chatbot chatbot,
  3. TimeStore? timeStore,
})

Use a Chatbot to answer questions in the liveChat.

Implementation

Future<void> answerBot(
    {required LiveBroadcastItem liveBroadcastItem,
    required Chatbot chatbot,
    TimeStore? timeStore}) async {
  await _download(
      liveBroadcastItem: liveBroadcastItem,
      onDownload: (List<LiveChatMessage> liveChatMessageList,
          LiveBroadcastItem liveBroadcastItem) {
        liveChatMessageList
            .where((liveChatMessage) =>
                liveChatMessage.authorDetails!.channelId !=
                liveBroadcastItem.snippet?.channelId)
            .forEach((liveChatMessage) {
          chatbot.checkDialog(
              liveChatMessage: liveChatMessage,
              onFound: (dialog, recipient) async => await send(
                  message:
                      '${chatbot.nameFormatted}: @$recipient - ${dialog.answer}',
                  chatId: liveChatMessage.snippet.liveChatId));
        });
      });
}