/// <inheritdoc /> public string SetProviderInfo(ChatSetupInfo info) { info.AdminList.RemoveAll(x => String.IsNullOrWhiteSpace(x)); info.AdminChannels.RemoveAll(x => String.IsNullOrWhiteSpace(x)); info.GameChannels.RemoveAll(x => String.IsNullOrWhiteSpace(x)); info.DevChannels.RemoveAll(x => String.IsNullOrWhiteSpace(x)); info.WatchdogChannels.RemoveAll(x => String.IsNullOrWhiteSpace(x)); try { lock (ChatLock) { foreach (var ChatProvider in ChatProviders) { if (info.Provider == ChatProvider.ProviderInfo().Provider) { return(ChatProvider.SetProviderInfo(info)); } } return("Error: Invalid provider: " + info.Provider.ToString()); } } catch (Exception e) { return(e.ToString()); } }
/// <summary> /// Properly shuts down all <see cref="ChatProviders"/> /// </summary> void DisposeChat() { var infosList = new List <IList <string> >(); foreach (var ChatProvider in ChatProviders) { infosList.Add(ChatProvider.ProviderInfo().DataFields); ChatProvider.Dispose(); } ChatProviders = null; var rawdata = JsonConvert.SerializeObject(infosList, Formatting.Indented); Config.ChatProviderData = Interface.Helpers.EncryptData(rawdata, out string entrp); Config.ChatProviderEntropy = entrp; }
/// <summary> /// Broadcast a message to appropriate channels based on the message type /// </summary> /// <param name="msg">The message to send</param> /// <param name="mt">The message type</param> public void SendMessage(string msg, MessageType mt) { lock (ChatLock) { foreach (var ChatProvider in ChatProviders) { try { ChatProvider.SendMessage(msg, mt); } catch (Exception e) { WriteWarning(String.Format("Chat broadcast failed (Provider: {3}) (Flags: {0}) (Message: {1}): {2}", mt, msg, e.ToString(), ChatProvider.ProviderInfo().Provider), EventID.ChatBroadcastFail); } } } }