getBot method
Get the collected bot.
- {botName} is the name of the bot that you want. If this is different from the bot that is collected, the bot will be loaded from the server and replace the collected bot. {botName} should not be specified if the bot is already collected to avoid unnecessary loading.
Implementation
Future<Bot?> getBot({String? botName}) async {
if (botName == null && _bot == null) {
return null;
}
if (botName != null && _bot?.botName != botName) {
if (implicitCollecting) {
await BotnoiChatbot.serverInstance.findBotWithName(botName).then((bot) {
if (bot != null) {
collectBot(bot);
return bot;
} else {
return null;
}
});
} else {
return null;
}
}
if (_bot != null) {
return _bot;
} else {
return null;
}
}