An immutable struct that provides information about a single PoE message.
Exemplo n.º 1
0
		void ProcessMessage(MessageData obj) {
			if (obj.MessageType == LogMessageType.Party && !Settings.Default.LogPartyMessages)
				return;
			if (Settings.Default.NotifyMinimizedOnly && IsPoeActive()) {
				if(!IdleManager.IsUserIdle) {
					// If the user isn't idle, replay the message if they do go idle.
					IdleManager.AddIdleAction(() => ProcessMessage(obj));
					return;
				}
				// Otherwise, they are idle, so process the message anyways.
			}
			string StampedMessage = "[" + obj.Date.ToShortTimeString() + "]" + (obj.Sender == null ? "" : (" " + LogMonitor.ChatSymbolForMessageType(obj.MessageType) + obj.Sender)) + ": " + obj.Message;
			string Title = "Path of Exile " + obj.MessageType;
			Invoke(new Action(() => AppendMessage(StampedMessage)));
			if(Settings.Default.TrayNotifications) {
				Invoke(new Action(() => {
					NotificationIcon.Visible = true;
					NotificationIcon.ShowBalloonTip(5000, Title, (obj.Sender == null ? "" : (obj.Sender + ": ")) + obj.Message, ToolTipIcon.Info);
				}));
			}
			if (Settings.Default.EnableSound) {
				try {
					this.SoundPlayer.Play();
				} catch (Exception ex) {
					AppendMessage("<Error playing sound. This usually occurs due to the Content folder being missing.\r\n  Additional Info: " + ex.Message + ">");
				}
			}
			if(Settings.Default.EnableSmtpNotifications) {
				// Feels wasteful to always reload, but really it should only take a millisecond or less.
				var SmtpSettings = SmtpDetails.LoadFromSettings();
				var SmtpAct = CheckedAction("SMTP", () => SendSmtpNotification(SmtpSettings, StampedMessage));
				if (!SmtpSettings.NotifyOnlyIfIdle)
					SmtpAct();
				else
					IdleManager.AddIdleAction(SmtpAct);
			}
			if(Settings.Default.EnablePushbullet) {
				var PbSettings = PushBulletDetails.LoadFromSettings();
				var PbAct = CheckedAction("PushBullet", () => {
					var Client = new PushBulletClient(PbSettings);
					Client.SendPush(Title, StampedMessage);
				});
				if (!PbSettings.NotifyOnlyIfIdle)
					PbAct();
				else
					IdleManager.AddIdleAction(PbAct);
			}
		}
Exemplo n.º 2
0
		private bool TryParseDisconnect(string Line, out MessageData Data) {
			Data = default(MessageData);
			try {
				var Match = DisconnectRegex.Match(Line);
				if (!Match.Success || Match.Groups.Count != 2)
					return false;
				string Reason = Match.Groups[1].Value.Trim();
				Data = new MessageData(DateTime.Now, null, "Abnormal disconnection: " + Reason, LogMessageType.Disconnect);
				return true;
			} catch {
				return false;
			}
		}
Exemplo n.º 3
0
		private bool TryParseChat(string Line, out MessageData Data) {
			Data = default(MessageData);
			try {
				var Match = ChatRegex.Match(Line);
				if(!Match.Success || Match.Groups.Count != 4)
					return false;
				string ChatSymbol = Match.Groups[1].Value.FirstOrDefault().ToString();
				string Username = Match.Groups[2].Value;
				string Contents = Match.Groups[3].Value;
				if(String.IsNullOrWhiteSpace(Username) || String.IsNullOrWhiteSpace(Contents))
					return false;
				Username = Username.Trim();
				var MessageType = MessageTypeForChatSymbol(ChatSymbol);
				Data = new MessageData(DateTime.Now, Username, Contents, MessageType);
				return true;
			} catch {
				return false;
			}
		}
Exemplo n.º 4
0
 private bool TryParseLine(string Line, out MessageData Data)
 {
     Data = default(MessageData);
     try {
         var Match = WhisperRegex.Match(Line);
         if(!Match.Success || Match.Groups.Count != 3)
             return false;
         string Username = Match.Groups[1].Value;
         string Contents = Match.Groups[2].Value;
         if(String.IsNullOrWhiteSpace(Username) || String.IsNullOrWhiteSpace(Contents))
             return false;
         Data = new MessageData(DateTime.Now, Username, Contents);
         return true;
     } catch {
         return false;
     }
 }
Exemplo n.º 5
0
 void ProcessMessage(MessageData obj)
 {
     if (Settings.Default.NotifyMinimizedOnly && IsPoeActive()) {
         if(!IdleManager.IsUserIdle) {
             // If the user isn't idle, replay the message if they do go idle.
             IdleManager.AddIdleAction(() => ProcessMessage(obj));
             return;
         }
         // Otherwise, they are idle, so process the message anyways.
     }
     string StampedMessage = "[" + obj.Date.ToShortTimeString() + "] " + obj.Sender + ": " + obj.Message + "\r\n";
     string Title = "Path of Exile Whisper";
     Invoke(new Action(() => rtbHistory.AppendText(StampedMessage)));
     if(Settings.Default.TrayNotifications) {
         Invoke(new Action(() => {
             NotificationIcon.Visible = true;
             NotificationIcon.ShowBalloonTip(5000, Title, obj.Sender + ": " + obj.Message, ToolTipIcon.Info);
         }));
     }
     if(Settings.Default.EnableSound)
         this.SoundPlayer.Play();
     if(Settings.Default.EnableSmtpNotifications) {
         // Feels wasteful to always reload, but really it should only take a millisecond or less.
         var SmtpSettings = SmtpDetails.LoadFromSettings();
         var SmtpAct = CheckedAction("SMTP", () => SendSmtpNotification(SmtpSettings, StampedMessage));
         if (!SmtpSettings.NotifyOnlyIfIdle)
             SmtpAct();
         else
             IdleManager.AddIdleAction(SmtpAct);
     }
     if(Settings.Default.EnablePushbullet) {
         var PbSettings = PushBulletDetails.LoadFromSettings();
         var PbAct = CheckedAction("PushBullet", () => {
             var Client = new PushBulletClient(PbSettings);
             Client.SendPush(Title, StampedMessage);
         });
         if (!PbSettings.NotifyOnlyIfIdle)
             PbAct();
         else
             IdleManager.AddIdleAction(PbAct);
     }
 }
Exemplo n.º 6
0
 private void PlayNotificationsForMessage(MessageData Message, bool AssumeInactive)
 {
     if (Settings.Default.NotifyMinimizedOnly && IsPoeActive())
     {
         if (!IdleManager.IsUserIdle)
         {
             // If the user isn't yet idle, replay the message if they do go idle.
             IdleManager.AddIdleAction(() => PlayNotificationsForMessage(Message, AssumeInactive));
             return;
         }
         // Otherwise, they are idle, so process the message anyways.
     }
     if (Settings.Default.TrayNotifications)
     {
         NotificationIcon.Visible = true;
         NotificationIcon.ShowBalloonTip(5000, Message.Title, (Message.Sender == null ? "" : (Message.Sender + ": ")) + Message.Message, ToolTipIcon.Info);
     }
     if (Settings.Default.EnableSound)
     {
         try {
             this.SoundPlayer.Play();
         } catch (Exception ex) {
             LogMessage("<Error playing sound. This usually occurs due to the Content folder being missing.\r\n  Additional Info: " + ex.Message + ">", null, LogMessageType.Status);
         }
     }
     if (Settings.Default.EnableSmtpNotifications)
     {
         var SmtpSettings = SmtpDetails.LoadFromSettings();
         var SmtpAct      = CheckedAction("SMTP", () => SendSmtpNotification(SmtpSettings, Message.DisplayMessage));
         if (!SmtpSettings.NotifyOnlyIfIdle || AssumeInactive)
         {
             SmtpAct();
         }
         else
         {
             IdleManager.AddIdleAction(SmtpAct);
         }
     }
     if (Settings.Default.EnablePushbullet)
     {
         var   PbSettings = PushBulletDetails.LoadFromSettings();
         Regex Pattern    = null;
         Match Matches    = null;
         if (!String.IsNullOrWhiteSpace(PbSettings.NotifyOnlyIfMatches))
         {
             Pattern = new Regex(PbSettings.NotifyOnlyIfMatches);
             Matches = Pattern.Match(Message.Message);
         }
         if (Pattern == null || ((Pattern != null) && Matches.Success))
         {
             var PbAct = CheckedAction("PushBullet", () => {
                 var Client = new PushBulletClient(PbSettings);
                 Client.SendPush(Message.Title, Message.DisplayMessage);
             });
             if (AssumeInactive || !PbSettings.NotifyOnlyIfIdle)
             {
                 PbAct();
             }
             else
             {
                 IdleManager.AddIdleAction(PbAct);
             }
         }
     }
     if (Settings.Default.FlashTaskbar && (!IsPoeActive() || AssumeInactive))
     {
         var PoeProcess = GetPoeProcess();
         if (PoeProcess != null)
         {
             var FlashAct = CheckedAction("Taskbar Flash", () => WindowFlasher.FlashWindow(PoeProcess.MainWindowHandle, FlashStyle.All));
             FlashAct();
         }
         else
         {
             LogMessage("<Could not find the PoE process to flash the taskbar>", null, LogMessageType.Status);
         }
     }
 }
Exemplo n.º 7
0
 void ProcessMessage(MessageData obj)
 {
     Invoke(new Action(() => HandleMessage(obj, false)));
 }
Exemplo n.º 8
0
        private void testNotificationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var Message = new MessageData(DateTime.Now, "Tester", "This is a fake whisper for testing notifications.", LogMessageType.Whisper);

            HandleMessage(Message, true);
        }