From 6445d01a9059985da66bad5a0c5691f68495a370 Mon Sep 17 00:00:00 2001 From: ryan sainty Date: Thu, 29 Mar 2018 13:20:11 +0100 Subject: [PATCH] Implemented a number of changes/features suggested by https://github.com/kaimi. --- .vs/MixerSmiteCodeRedeemer/v14/.suo | Bin 245248 -> 243712 bytes SmiteMixerCodeGrabberGUI/Classes/AllCodes.cs | 6 ++++-- SmiteMixerCodeGrabberGUI/Classes/Common.cs | 16 ++++++++++------ SmiteMixerCodeGrabberGUI/MainForm.cs | 19 ++++++++++++++++--- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.vs/MixerSmiteCodeRedeemer/v14/.suo b/.vs/MixerSmiteCodeRedeemer/v14/.suo index 1c1c85f84e6ab3f4542bc17c34569a205624c68a..daef31bcb369c65fd44b15c47d66d6f271c4302e 100644 GIT binary patch delta 1733 zcmcJPe{54#6vy9vuU-4-C|#LlKV)>JTiKlbfr#bD#-L@uj6;XQl({iROs$K7(3lKy z?TRjt&A9YVADCdEB#Xubp|1fF_(L}njfsMQM2VRp{uo4K$TCoLKm4B3hNAJuKi=e% zbM86k-h1Bn-ZnB}j9fSNH?et~#pfK~KEaIrld+afA6;N;1VMPejqeiIai7k^dej>^ z1{R))=;ZXBF$GtH7)2JRts!k4uvTCKdEh}HgIu5kS}-5n4@y8jm<`;(3}|l;>;s@0 z;N0+ZDV$31DHDV;*cISDKn>Voji4A*fQJBW(u3Ni@C(60upG<}T@Fc{Z;-&I8h27*~`#rEPgICh?DV1#;Wr^IY%=02byTME8 zR2Vh_{&{K4I4m=Isq`ATwc5(vqMnZ%&&rHG2kWzV?e zetjz<^Rl-Kt>}x}#YBNmBd4A!z4J^5YRKHj;w73y{xFkMkCuL6nXI-6la0Kys6w^b zN90)WOVbxQ{bru`>+mn)HCNKH&dW{J`FtWcmiN{5!Cl_^&Y|7Gv8}Gnt9u2$W3o)O zyT8`)h{MKh_C{?KUpc}bJNz*Bx1Ql!4*Ox3$Cqljx!QcvoREHI32%V0RrFu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ggE>t{7e*yGBe}HKLm9_H61A7$usa_i&h(C!*SY5I_ Vv%n85a0cYh7Pu+7aB$dU{u{Y|kP-j@ diff --git a/SmiteMixerCodeGrabberGUI/Classes/AllCodes.cs b/SmiteMixerCodeGrabberGUI/Classes/AllCodes.cs index 5c17cee..2d7b08c 100644 --- a/SmiteMixerCodeGrabberGUI/Classes/AllCodes.cs +++ b/SmiteMixerCodeGrabberGUI/Classes/AllCodes.cs @@ -24,8 +24,10 @@ public static void AddCodeToCodeList(string code, bool isActive) _AllCodes.Add(new SmiteCode(code)); if (Properties.Settings.Default.notificationSetting) DisplayNotification("New potential code added to active codes: \n" + code); - } - else + if (Properties.Settings.Default.notificationSound) + PlayNotificationSound(); + } + else { Console.WriteLine("Added Expried code: " + code + " to the code list."); _AllCodes.Add(new SmiteCode(code, isActive)); diff --git a/SmiteMixerCodeGrabberGUI/Classes/Common.cs b/SmiteMixerCodeGrabberGUI/Classes/Common.cs index 82e1e5a..c2440e7 100644 --- a/SmiteMixerCodeGrabberGUI/Classes/Common.cs +++ b/SmiteMixerCodeGrabberGUI/Classes/Common.cs @@ -14,14 +14,18 @@ class Common { public static void DisplayNotification(string msg) { - if (Properties.Settings.Default.notificationSound) + MessageBox.Show(msg, "Smite Code Grabber Notification", MessageBoxButtons.OK); + } + + public static void PlayNotificationSound() + { + try { - try { - System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Settings.Default.notificationSoundFilePath); - player.Play(); - } catch { Console.WriteLine("Unable to play notification sound (invalid file format/path)."); } + System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Settings.Default.notificationSoundFilePath); + player.Play(); } - MessageBox.Show(msg, "Smite Code Grabber Notification", MessageBoxButtons.OK); + catch { Console.WriteLine("Unable to play notification sound (invalid file format/path)."); } + } } } diff --git a/SmiteMixerCodeGrabberGUI/MainForm.cs b/SmiteMixerCodeGrabberGUI/MainForm.cs index 47364d7..c1a7c6d 100644 --- a/SmiteMixerCodeGrabberGUI/MainForm.cs +++ b/SmiteMixerCodeGrabberGUI/MainForm.cs @@ -71,12 +71,12 @@ private static void Chat_OnMessageReceived(ChatMessageEventArgs e) { if (!Properties.Settings.Default.whitelistOnly) { - if (e.Message.Contains("AP")) + if (e.Message.Contains(Properties.Settings.Default.codesStartWith)) { var m = e.Message; try { - var code = m.Substring(m.IndexOf(Properties.Settings.Default.codesStartWith), 17); + var code = m.Substring(m.IndexOf(Properties.Settings.Default.codesStartWith), Properties.Settings.Default.codeLength); if (GetActiveCodes().Find(x => x.GetCode() == code) == null && GetExpiredCodes().Find(x => x.GetCode() == code) == null && !code.Contains(" ")) { @@ -101,7 +101,7 @@ private static void Chat_OnMessageReceived(ChatMessageEventArgs e) var m = e.Message; try { - var code = m.Substring(m.IndexOf("AP"), 17); + var code = m.Substring(m.IndexOf(Properties.Settings.Default.codesStartWith), Properties.Settings.Default.codeLength); if (GetActiveCodes().Find(x => x.GetCode() == code) == null && GetExpiredCodes().Find(x => x.GetCode() == code) == null && !code.Contains(" ")) { @@ -109,6 +109,8 @@ private static void Chat_OnMessageReceived(ChatMessageEventArgs e) Write("Code: " + code + " added to active codes (Grabbed from whitelisted user: " + e.User + "."); if (Properties.Settings.Default.notificationSetting) DisplayNotification("New potential code added to active codes: \n" + code); + if (Properties.Settings.Default.notificationSound) + PlayNotificationSound(); } else { @@ -120,6 +122,15 @@ private static void Chat_OnMessageReceived(ChatMessageEventArgs e) } catch { } } + else + { + try + { + var m = e.Message; + var code = m.Substring(m.IndexOf(Properties.Settings.Default.codesStartWith), Properties.Settings.Default.codeLength); + Write("Code matching specified criteria was observed: " + code + " posted by user: " + e.User); + } catch { } + } } } @@ -188,6 +199,8 @@ private void checkbox_AFKMode_CheckedChanged(object sender, EventArgs e) private void button_sendTestEmail_Click(object sender, EventArgs e) { DisplayNotification("This is a test notification."); + if (Properties.Settings.Default.notificationSound) + PlayNotificationSound(); } private void numberbox_codeLength_ValueChanged(object sender, EventArgs e) {