コード例 #1
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();
     }
 }
コード例 #2
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);
        }
コード例 #3
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 = "";
        }
コード例 #4
0
ファイル: TwitchCommands.cs プロジェクト: Solferrun/RazBot2
 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);
     }
 }