public static string DeHashTagMessage(IChirperMessage inputMessage) { string messageText = inputMessage.text; string[] words = messageText.Split(' '); List <string> newMessage = new List <string>(); for (int i = 0; i < words.Length; i++) { if (words[i].ToCharArray()[0].Equals(Char.Parse("#"))) { // Keep only if not an end word. if (!CheckEndHashTagWord(i, words)) { // Remove hashtag newMessage.Add(words[i].Substring(1, words[i].Length - 1)); } } else { newMessage.Add(words[i]); } } string outputMessage = String.Join(" ", newMessage.ToArray()); return(outputMessage); }
public void AddMessage(IChirperMessage message, bool show) { this.AddEntry(message, false); if (show && this.m_AutoExpand) { this.Show(this.m_MessageTimeout); } }
/// <summary> /// On a new message event we check and see if the message is one we want to keep or delete. Mostly copied from https://github.com/mabako/reddit-for-city-skylines/ /// </summary> public override void OnNewMessage(IChirperMessage message) { // If the message should be filtered, target it for removal var citizenMessage = message as CitizenMessage; if (citizenMessage == null) return; if (!Configuration.ConfigurationSettings.ShowDefaultChirperMessages) _messageRemovalTarget = citizenMessage; }
public string GetRandomResponse(IChirperMessage message) { var responses = RandomStrings.Responses(); var index = _random.Next(0, responses.Length); var response = responses[index]; var previousHandle = "@" + message.senderName.Replace(" ", ""); return(response.Replace("{previousHandle}", previousHandle)); }
public void OnNewMessage(IChirperMessage message) { var shouldSend = _random.Next(0, 100) > (_probabilityOfResponding * 100); if (!shouldSend) { return; } _chirperMessageSender.SendMessage( _grumpyEngine.GetRandomName(message.senderName), _grumpyEngine.GetRandomResponse(message)); }
private void ManagerOnMNewMessages(IChirperMessage message) { try { var msg = new ChirperMessage { SenderID = (int)message.senderID, SenderName = message.senderName, Text = message.text }; _messages.Add(msg); } catch (Exception ex) { WebServer.Log($"ChirpRetriever OnMNewMessages: {ex}"); } }
/// <summary> /// Invoked when the Chirper receives a new message /// </summary> /// <param name="message">New message.</param> public void OnNewMessage(IChirperMessage message) { try { var msg = new ChirperMessage { SenderID = (int)message.senderID, SenderName = message.senderName, Text = message.text, Time = Singleton <SimulationManager> .instance.m_currentGameTime, }; messages.Add(msg); SendJson(msg); } catch (Exception ex) { Log($"OnNewMessage: {ex}"); } }
public void OnNewMessage(IChirperMessage message) { try { if (ModConfig.FilterMessages) { filterService.HandleNewMessage(message); } } catch (Exception ex) { logger.LogException(ex); throw; } }
public void OnNewMessage(IChirperMessage message) { try { if (ModConfig.Instance.GetSetting <bool>(SettingKeys.FilterMessages)) { filterService.HandleNewMessage(message); } } catch (Exception ex) { logger.LogException(ex); throw; } }
private void ManagerOnMNewMessages(IChirperMessage message) { try { var msg = new ChirperMessage { SenderID = (int)message.senderID, SenderName = message.senderName, Text = message.text }; _messages.Add(msg); } catch (Exception ex) { OnLogMessage(ex.ToString()); } }
public void AddEntry(IChirperMessage message, bool noAudio) { if (this.m_NotificationSound != null && !noAudio) { Singleton <AudioManager> .instance.PlaySound(this.m_NotificationSound, this.m_ChirperAudioVolume.value); } if (!this.m_Showing) { this.m_NewMessageCount++; this.m_Counter.Show(); this.m_Counter.text = this.m_NewMessageCount.ToString(); } int childCount = this.m_Container.childCount; UIPanel uIPanel; if (childCount + 1 > this.m_MessageBufferSize && childCount > 0) { uIPanel = (this.m_Container.components[0] as UIPanel); } else { GameObject asGameObject = UITemplateManager.GetAsGameObject(kChirpTemplate); uIPanel = (this.m_Container.AttachUIComponent(asGameObject) as UIPanel); } UIButton uIButton = uIPanel.Find <UIButton>("Sender"); uIButton.objectUserData = new InstanceID { Citizen = message.senderID }; uIButton.eventClick += new MouseEventHandler(this.OnTargetClick); UILabel uILabel = uIPanel.Find <UILabel>("Content"); uIPanel.FitTo(uIPanel.parent, LayoutDirection.Horizontal); uIButton.text = message.senderName; uILabel.text = message.text; uIPanel.objectUserData = message; uIPanel.FitChildrenVertically(10f); uIPanel.zOrder = 2147483647; this.m_Container.ScrollToBottom(); }
public void OnNewMessage(IChirperMessage msg) { if (!chiperChecked) { cpanel.ClearMessages(); chiperChecked = true; if (chirpContainer == null) { chirperDestroyed = true; } } if (!chirperDestroyed) { CitizenMessage cm = msg as CitizenMessage; if (cm != null) { FilterContainer fc = new FilterContainer(cm, chirpContainer.transform.childCount); filter(fc); recentMessages.Add(fc); } } }
public void HandleNewMessage(IChirperMessage message) { logger.Info("New message: {0}", message.text); var citizenMessage = message as CitizenMessage; if (citizenMessage == null) { return; } logger.Info("Is citizen message: Id: {0} tag: {1}, key: {2}, sender id: {3}, sender name: {4}", citizenMessage.m_messageID, citizenMessage.m_tag, citizenMessage.m_keyID, citizenMessage.senderID, citizenMessage.senderName); if (filteredMessages.Contains(citizenMessage.m_messageID)) { logger.Info("Message marked for removal"); MessagesToRemove.Add(message); chirpPanel.RemoveNotificationSound(); } }
public void HandleNewMessage(IChirperMessage message) { logger.Info("New message: " + message.text); var citizenMessage = message as CitizenMessage; if (citizenMessage == null) { return; } logger.Info("Message id: " + citizenMessage.m_messageID); if (AllowedMessages.Contains(citizenMessage.m_messageID)) { return; } logger.Info("Message marked for removal"); MessagesToRemove.Add(message); chirpPanel.RemoveNotificationSound(); }
//Thread: Main public override void OnNewMessage(IChirperMessage message) { // To make mute collapsing work better. userOpened = chirpPane.isShowing; newMsgIn = true; DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Message received"); if (!isMuted) { // Cast message and check whether it should be filtered. CitizenMessage cm = message as CitizenMessage; ChirpMessage storedMessage = new ChirpMessage(message.senderName, message.text, message.senderID); bool filter = ChirpFilter.FilterMessage(cm.m_messageID); if (cm != null) { // Check if message is garbage // Check if we should make noise chirpPane.m_NotificationSound = ((isFiltered && filter) ? null : SuperChirperLoader.MessageSound); // TODO: Change to ChirpMessage in dictionary, to make compatible with hashtag removal. messageFilterMap.Add(storedMessage, filter); } else { // Default to unfiltered messages. messageFilterMap.Add(storedMessage, false); } hashTaggedMessages.Add(storedMessage); messageMap.Add(storedMessage, message); } }
public void OnNewMessage(IChirperMessage message) { if (message != null && theBannerPanel != null) { try { string citizenMessageID = string.Empty; CitizenMessage cm = message as CitizenMessage; if (cm != null) { //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("found citmess MessageID: {0} GetText: {1}", cm.m_messageID, cm.GetText())); citizenMessageID = cm.m_messageID; } if (!string.IsNullOrEmpty(citizenMessageID)) { // Integrate with ChirpFilter if (ChirpFilter_FilterModule == null) { GameObject ChirpFilter_GameObject = GameObject.Find("ChirperFilterModule"); if (ChirpFilter_GameObject != null) { ChirpFilter_FilterModule = ChirpFilter_GameObject.GetComponent("ChirpFilter.FilterModule"); } } if (ChirpFilter_FilterModule != null) { bool bIsBlacklisted = false; if (ChirpFilter_FilterModule is IFormattable) { IFormattable ifs = ChirpFilter_FilterModule as IFormattable; string sresult = ifs.ToString(citizenMessageID, null); if (string.IsNullOrEmpty(sresult) || sresult == "false") { bIsBlacklisted = false; } else if (sresult == "true") { bIsBlacklisted = true; } } // see if ChirpFilter wants us to filter (not show) the message if (bIsBlacklisted) { //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("msgid {0} msg {1} blacklisted", citizenMessageID, message.text)); return; } } } } catch (Exception ex) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("ChirpBanner.OnNewMessage threw Exception: {0}", ex.Message)); } // use rich styled text // Colossal markup uses sliiiiiightly different tags than unity. // munge our config strings to fit string nameColorTag = CurrentConfig.NameColor; string textColorTag = CurrentConfig.MessageColor; if (nameColorTag.Length == 9) // ie: #001122FF { nameColorTag = nameColorTag.Substring(0, 7); // drop alpha bits } if (textColorTag.Length == 9) // ie: #001122FF { textColorTag = textColorTag.Substring(0, 7); // drop alpha bits } //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("chirp! {0}", message.text)); string str = String.Format("<color{0}>{1}</color> : <color{2}>{3}</color>", nameColorTag, message.senderName, textColorTag, message.text); theBannerPanel.CreateBannerLabel(str, message.senderID); } }
public void OnNewMessage(IChirperMessage message) { }
public void AddMessage(IChirperMessage message) { this.AddMessage(message, true); }
public void AddMessage(IChirperMessage message, bool show = true) { m_Chirpy.AddMessage(message, show); }
public void OnNewMessage(IChirperMessage message) { bool important = false; if (message != null && theBannerPanel != null) { try { string citizenMessageID = string.Empty; CitizenMessage cm = message as CitizenMessage; if (cm != null) { //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("found citmess MessageID: {0} GetText: {1}", cm.m_messageID, cm.GetText())); citizenMessageID = cm.m_messageID; } if (!string.IsNullOrEmpty(citizenMessageID)) { // TODO: Do stuff if the Chirper message is actually important. // Hope is to mimic SimCity's ticker. // List of LocaleIDs available here: https://github.com/cities-skylines/Assembly-CSharp/wiki/LocaleID important = FilterMessage(cm.m_messageID); } } catch (Exception ex) { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("ChirpBanner.OnNewMessage threw Exception: {0}", ex.Message)); } // use rich styled text // Colossal markup uses sliiiiiightly different tags than unity. // munge our config strings to fit string nameColorTag = MyConfig.ConfigHolder.Config.NameColor; string textColorTag = MyConfig.ConfigHolder.Config.MessageColor; if (nameColorTag.Length == 9) // ie: #001122FF { nameColorTag = nameColorTag.Substring(0, 7); // drop alpha bits } if (textColorTag.Length == 9) // ie: #001122FF { textColorTag = textColorTag.Substring(0, 7); // drop alpha bits } // Check for CurrentConfig.ColorChirps if (MyConfig.ConfigHolder.Config.ColorChirps) { // If chirp is important, and ColorChirps is enabled, make the chirp name and message red. if (important) { //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("Chirp is important: {0}", message.text)); //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("CurrentConfig.NameColor: {0}", CurrentConfig.NameColor)); //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("CurrentConfig.MessageColor: {0}", CurrentConfig.MessageColor)); textColorTag = "#FF0000"; nameColorTag = "#FF0000"; } } string str = String.Format("<color{0}>{1}</color> : <color{2}>{3}</color>", nameColorTag, message.senderName, textColorTag, message.text); // Check for CurrentConfig.FilterChirps if (MyConfig.ConfigHolder.Config.FilterChirps) { // If Chirp is deemed not important as a result of above LocaleIDs, just return, do nothing if (!important) { //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("Chirp is not important: {0}", message.text)); return; } // Otherwise, do something if (important) { //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("Chirp is important: {0}", message.text)); //theBannerPanel.CreateBannerLabel (str, message.senderID); ChirpMoverThread.addTask2Main(() => { theBannerPanel.CreateBannerLabel(str, message.senderID); }); } } else { //theBannerPanel.CreateBannerLabel (str, message.senderID); ChirpMoverThread.addTask2Main(() => { theBannerPanel.CreateBannerLabel(str, message.senderID); }); } //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("textColorTag: {0}", textColorTag)); //DebugOutputPanel.AddMessage (ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format ("nameColorTag: {0}", nameColorTag)); //DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("chirp! {0}", message.text)); //MyIThreadingExtension.addTask2Main(() => { theBannerPanel.CreateBannerLabel(str, message.senderID); }); //MyIThreadingExtension.addTask2Main(() => { DebugOutputPanel.AddMessage(ColossalFramework.Plugins.PluginManager.MessageType.Message, string.Format("chirp! {0}", message.text)); }); } }
public void OnNewMessage(IChirperMessage message) { ChirpLog.Info("Chirper chirped: " + message.ToString()); }
public void DeleteMessage(IChirperMessage chirperMessage) { MessageManager.instance.DeleteMessage(chirperMessage); }