/// <summary> /// Rename existing chat profile. /// </summary> /// <param name="newProfileName"></param> /// <returns></returns> public async Task RenameCurrentChatProfile(string newProfileName) { await RenameChatProfile(_activeProfile, newProfileName); await BotCollection.SetActiveChatProfileById(BotAlphaName, newProfileName); SyncChatProfile(newProfileName); }
public BotCollection Build(IServiceProvider provider) { var collection = new BotCollection(); foreach (var builder in botBuilders) { collection.Add(builder.Build(provider)); } return(collection); }
private void DoForAll(Action <BotBase> action, Self me) { if (bots == null) { bots = Builder.Build(_provider); } foreach (BotBase bot in bots) { bot.Me = me; action(bot); } }
/// <summary> /// Update old chat profile collections to new chat profile name. /// </summary> /// <param name="oldProfileName"></param> /// <param name="newProfileName"></param> /// <returns></returns> public async Task RenameChatProfile(string oldProfileName, string newProfileName) { var db = GetDatabase(); var profile = await BotCollection.GetActiveChatProfile(BotAlphaName); profile.Name = newProfileName; await BotCollection.AddOrUpdateChatProfileById(BotAlphaName, profile); await BotCollection.RemoveChatProfileById(BotAlphaName, _activeProfile); var curLinkCollectionName = GetLinkCollectionName(oldProfileName); if (await CollectionExistsAsync(db, curLinkCollectionName)) { await db.RenameCollectionAsync(curLinkCollectionName, GetLinkCollectionName(newProfileName)); } var curActionCollectionName = GetActionCollectionName(oldProfileName); if (await CollectionExistsAsync(db, curActionCollectionName)) { await db.RenameCollectionAsync(curActionCollectionName, GetActionCollectionName(newProfileName)); } var curResourceCollectionName = GetResourceCollectionName(oldProfileName); if (await CollectionExistsAsync(db, curResourceCollectionName)) { await db.RenameCollectionAsync(curResourceCollectionName, GetResourceCollectionName(newProfileName)); } var curTrainDataCollectionName = GetTrainDataCollectionName(oldProfileName); if (await CollectionExistsAsync(db, curTrainDataCollectionName)) { await db.RenameCollectionAsync(curTrainDataCollectionName, GetTrainDataCollectionName(newProfileName)); } }