예제 #1
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();
        }
예제 #2
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 = "";
        }
예제 #3
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);
     }
 }