Browse Source

Switch from partial match to exact match

Stuart Johnson 2 years ago
parent
commit
526e6b75c8
2 changed files with 40 additions and 52 deletions
  1. 23 44
      .vs/TFA-Bot/xs/UserPrefs.xml
  2. 17 8
      TFA-Bot/DiscordBot/clsBotClient.cs

+ 23 - 44
.vs/TFA-Bot/xs/UserPrefs.xml

@@ -1,58 +1,37 @@
 <Properties StartupConfiguration="{25609AB4-A77A-4B47-AAB8-B2DB39464A3F}|Default">
+  <MonoDevelop.Ide.ItemProperties.TFA-Bot PreferredExecutionTarget="MonoDevelop.Default" />
   <MonoDevelop.Ide.Workbench ActiveDocument="TFA-Bot Status">
     <Files>
-      <File FileName="TFA-Bot/DiscordBot/Commands/IBotCommand.cs" Line="16" Column="9" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsHelp.cs" Line="22" Column="63" />
-      <File FileName="TFA-Bot/DiscordBot/clsCommands.cs" Line="113" Column="31" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsAlarm.cs" Line="54" Column="65" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsBotControl.cs" Line="64" Column="65" />
-      <File FileName="TFA-Bot/clsColumnDisplay.cs" Line="82" Column="1" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsCall.cs" Line="26" Column="54" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsFembot.cs" Line="1" Column="1" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsGitCommand.cs" Line="54" Column="73" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsGoodAfternoon.cs" Line="1" Column="1" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsGoodnight.cs" Line="1" Column="1" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsListNodes.cs" Line="21" Column="63" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsMTR.cs" Line="82" Column="44" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsSkyNet.cs" Line="1" Column="1" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsUsers.cs" Line="37" Column="48" />
-      <File FileName="TFA-Bot/DiscordBot/Commands/clsVersion.cs" Line="35" Column="2" />
-      <File FileName="TFA-Bot/DataClasses/clsNode.cs" Line="250" Column="114" />
-      <File FileName="TFA-Bot/Program.cs" Line="233" Column="14" />
-      <File FileName="TFA-Bot/Spreadsheet/clsSpreadsheet.cs" Line="1" Column="1" />
-      <File FileName="TFA-Bot/clsAlarmManager.cs" Line="1" Column="1" />
+      <File FileName="TFA-Bot/DiscordBot/Commands/clsNetworks.cs" Line="1" Column="1" />
+      <File FileName="TFA-Bot/DiscordBot/Commands/clsListNodes.cs" Line="1" Column="1" />
+      <File FileName="TFA-Bot/DataClasses/clsNode.cs" Line="29" Column="25" />
+      <File FileName="TFA-Bot/DataClasses/clsNetwork.cs" Line="50" Column="21" />
+      <File FileName="TFA-Bot/clsExtenstions.cs" Line="84" Column="38" />
+      <File FileName="TFA-Bot/DataClasses/clsNodeGroup.cs" Line="51" Column="43" />
+      <File FileName="TFA-Bot/DiscordBot/Commands/clsEmail.cs" Line="16" Column="44" />
+      <File FileName="TFA-Bot/DiscordBot/clsCommands.cs" Line="72" Column="1" />
+      <File FileName="TFA-Bot/DataClasses/clsSetting.cs" Line="28" Column="1" />
+      <File FileName="TFA-Bot/DataClasses/clsNotificationPolicy.cs" Line="30" Column="23" />
+      <File FileName="TFA-Bot/Spreadsheet/clsSpreadsheetReader.cs" Line="105" Column="1" />
+      <File FileName="TFA-Bot/Program.cs" Line="205" Column="9" />
+      <File FileName="TFA-Bot/Spreadsheet/ISpreadsheet.cs" Line="7" Column="14" />
+      <File FileName="TFA-Bot/Dialler/clsDialler.cs" Line="81" Column="83" />
+      <File FileName="TFA-Bot/DiscordBot/Commands/clsCall.cs" Line="21" Column="24" />
+      <File FileName="TFA-Bot/Dialler/clsDiallerSIP.cs" Line="53" Column="48" />
+      <File FileName="TFA-Bot/clsAlarm.cs" Line="113" Column="18" />
+      <File FileName="TFA-Bot/Dialler/clsDiallerTwilio.cs" Line="14" Column="25" />
+      <File FileName="TFA-Bot/DiscordBot/clsBotClient.cs" Line="249" Column="43" />
+      <File FileName="TFA-Bot/DiscordBot/Commands/clsMTR.cs" Line="34" Column="37" />
+      <File FileName="TFA-Bot/Dialler/IDialler.cs" Line="9" Column="14" />
       <File FileName="TFA-Bot Status" />
     </Files>
-    <Pads>
-      <Pad Id="ProjectPad">
-        <State name="__root__">
-          <Node name="TFA-Bot" expanded="True">
-            <Node name="TFA-Bot" expanded="True">
-              <Node name="Data" expanded="True" />
-              <Node name="DataClasses" expanded="True" />
-              <Node name="Dialler" expanded="True">
-                <Node name="clsDiallerSIP.cs" selected="True" />
-              </Node>
-              <Node name="DiscordBot" expanded="True">
-                <Node name="Commands" expanded="True" />
-              </Node>
-              <Node name="Git" expanded="True" />
-              <Node name="Properties" expanded="True" />
-              <Node name="Spreadsheet" expanded="True" />
-              <Node name="Utils" expanded="True" />
-            </Node>
-          </Node>
-        </State>
-      </Pad>
-    </Pads>
   </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
   <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
   <MonoDevelop.Ide.DebuggingService.Breakpoints>
     <BreakpointStore>
       <Breakpoint file="/HOME/Projects/TFA-Bot/TFA-Bot/clsCaller.cs" relfile="TFA-Bot/clsCaller.cs" line="144" column="1" />
     </BreakpointStore>
   </MonoDevelop.Ide.DebuggingService.Breakpoints>
-  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
-  <MonoDevelop.Ide.ItemProperties.TFA-Bot PreferredExecutionTarget="MonoDevelop.Default" />
   <MultiItemStartupConfigurations />
 </Properties>

+ 17 - 8
TFA-Bot/DiscordBot/clsBotClient.cs

@@ -216,30 +216,39 @@ namespace DiscordBot
         void ProcessFactomAlarm(String message)
         {
             bool emergency = message.Contains("EMERGENCY");
+            var messageSplit = message.Split(' ');
             
             List<string> keywordUsed = new List<string>();
             List<string> toCall = new List<string>();
             
+            //Loop through all OnDuty users
             foreach(var user in Program.UserList.Values.Where(x=>x.KeywordAlert!=null && x.OnDuty))
             {
-                foreach (var keyword in user.KeywordAlert)
+                foreach (var word in messageSplit)
                 {
-                    if (emergency && keyword=="E" || (keyword !="E" && message.Contains(keyword)))
+                    foreach (var keyword in user.KeywordAlert)
                     {
-                        if (!keywordUsed.Contains(keyword)) keywordUsed.Add(keyword);
-                        if (!toCall.Contains(user.Name)) toCall.Add(user.Name);
+                        if (emergency && keyword=="E" || (keyword !="E" && word == keyword))
+                        {
+                            if (!keywordUsed.Contains(keyword)) keywordUsed.Add(keyword);
+                            if (!toCall.Contains(user.Name)) toCall.Add(user.Name);
+                        }
                     }
                 }
             }
             
+            //Loop through OffDuty users, triggering keywords that have not been picked up by OnDuty users
             foreach(var user in Program.UserList.Values.Where(x=>x.KeywordAlert!=null && !x.OnDuty))
             {
-                foreach (var keyword in user.KeywordAlert.Where(x=>!keywordUsed.Contains(x)))
+                foreach (var word in messageSplit)
                 {
-                    if (emergency && keyword=="E" || (keyword !="E" && message.Contains(keyword)))
+                    foreach (var keyword in user.KeywordAlert.Where(x=>!keywordUsed.Contains(x)))
                     {
-                        if (!keywordUsed.Contains(keyword)) keywordUsed.Add(keyword);
-                        if (!toCall.Contains(user.Name)) toCall.Add(user.Name);
+                        if (emergency && keyword=="E" || (keyword !="E" && word == keyword))
+                        {
+                            if (!keywordUsed.Contains(keyword)) keywordUsed.Add(keyword);
+                            if (!toCall.Contains(user.Name)) toCall.Add(user.Name);
+                        }
                     }
                 }
             }