예제 #1
0
        private string GetIntent()
        {
            string description = "";
            double confidence  = 0;

            if (!String.IsNullOrEmpty(Message))
            {
                var intent = Wit.GetIntent(Message.ToLower());
                if (intent.Count() > 0)
                {
                    description = intent["description"];
                    confidence  = intent["confidence"];
                }
            }

            if (!String.IsNullOrEmpty(description) && confidence >= BotTools.Settings["intent_thresshold"])
            {
                return(description);
            }
            else
            {
                BotTools.NewUtterances.Add(Message.ToLower());
                return(null);
            }
        }
예제 #2
0
 private void WitTrainerForm_VisibleChanged(object sender, EventArgs e)
 {
     if (Visible)
     {
         lbNewUtterances.DataSource = BotTools.NewUtterances.ToList();
         lbKnownIntents.DataSource  = Wit.ListIntents().Select(i => TwitchBot.Commands.Map.Keys.Contains(i) ? $"*{i}" : i).ToList();
     }
 }
예제 #3
0
        private void PerformTraining()
        {
            string newUtterance = $"{lbNewUtterances.SelectedItem}";
            string targetIntent = $"{lbKnownIntents.SelectedItem}".Replace("*", "");

            BotTools.NewUtterances.Remove(newUtterance);
            Wit.TrainUtterance(newUtterance, targetIntent);
            lbNewUtterances.DataSource = BotTools.NewUtterances.ToList();
        }
예제 #4
0
        private void RemoveIntent()
        {
            string targetToken = $"{lbKnownIntents.SelectedItem}";

            TwitchBot.Commands.CustomMap.Remove(targetToken);
            lbKnownIntents.DataSource = Wit.ListIntents().Select(i => TwitchBot.Commands.Map.Keys.Contains(i) ? $"*{i}" : i).ToList <string>();
            TwitchBot.Commands.SaveCustomCommands();
            Wit.DeleteIntent(targetToken);
        }
예제 #5
0
 private string[] RemoveCommand(TwitchMessage message)
 {
     if (message.HasModPrivileges && !string.IsNullOrEmpty(message.ArgsString))
     {
         string targetToken = message.ArgsString;
         if (TwitchBot.Commands.CustomMap.Keys.Contains(targetToken))
         {
             TwitchBot.Commands.CustomMap.Remove(targetToken);
             TwitchBot.Commands.SaveCustomCommands();
             Wit.DeleteIntent(targetToken);
             return(new string[] { $"Removed command: {targetToken}" });
         }
     }
     return(null);
 }
예제 #6
0
        private void OnAddCommandButtonClick(object sender, EventArgs e)
        {
            string newToken    = rtbToken.Text;
            string commandBody = rtbCommandBody.Text;

            if (!Wit.ListIntents().Contains(newToken))
            {
                Wit.AddIntent(newToken);
                Wit.TrainUtterance($"!{newToken}", newToken);
            }

            TwitchBot.Commands.CustomMap[newToken] = commandBody;
            lbKnownIntents.DataSource = Wit.ListIntents().Select(i => TwitchBot.Commands.Map.Keys.Contains(i) ? $"*{i}": i).ToList <string>();
            TwitchBot.Commands.SaveCustomCommands();
            rtbToken.Text       = "";
            rtbCommandBody.Text = "";
        }
예제 #7
0
 private string[] AddCommand(TwitchMessage message)
 {
     if (message.HasModPrivileges)
     {
         if (message.Args != null && message.Args.Count() > 1)
         {
             string newToken = message.Args[0].ToLower();
             if (Char.IsLetter(newToken[0]) && newToken.All(c => Char.IsLetterOrDigit(c) || c == '_'))
             {
                 string commandBody = String.Join(" ", message.Args.Skip(1));
                 var    intentList  = Wit.ListIntents();
                 if (!intentList.Contains(newToken))
                 {
                     // Save local
                     CustomMap[newToken] = commandBody;
                     SaveCustomCommands();
                     // Teach to wit
                     Wit.AddIntent(newToken);
                     Wit.TrainUtterance($"!{newToken}", newToken);
                     return(new string[] { $"Added command: !{newToken}" });
                 }
                 else
                 {
                     return(new string[] { $"Command already exists: !{newToken}" });
                 }
             }
             else
             {
                 return(new string[] { $"Command tokens should start with a letter, and contain only letters numbers or underscores." });
             }
         }
         else
         {
             return(new string[] { "Add command format: !add mycommand This is what my command returns!" });
         }
     }
     else
     {
         return(null);
     }
 }