private void UnRegisterChatCommand(string module, string[] param)
        {
            if (param != null && param.Length > 1)
            {
                string commandstring = param[1];
                SharedInformationalChatCommand cmd = null;

                lock (triggerResponses)
                {
                    if (triggerResponses.ContainsKey(commandstring))
                    {
                        cmd = triggerResponses[commandstring];
                    }
                }
                if (cmd != null)
                {
                    cmd.IsActive = 0;
                    cmd          = storagePlugin.ConcreteChatCommandSave(cmd);
                    DeactivateConcreteCommand(cmd);
                    BotOutput.Instance.ChatMessage(chan.Channel, string.Format("Command {0} deactivated", commandstring));
                }
                else
                {
                    BotOutput.Instance.ChatMessage(chan.Channel, "Unknown command, please try again with an actual command Kappa.  For a list of all commands, type help General.");
                }
            }
            else
            {
                BotOutput.Instance.ChatMessage(chan.Channel, "Invalid Parameters - Please provide the command that you want to remove. To get help, type help !remcommand");
            }
        }
示例#2
0
 public void ConcreteChatCommandDelete(SharedInformationalChatCommand ChatCommand)
 {
     lock (this)
     {
         string sql = DeleteConcreteChatCommandSQL;
         m_context.Database.ExecuteSqlCommand(sql, new SQLiteParameter[] { new SQLiteParameter(":commandid", ChatCommand.CommandId) });
     }
 }
 private void ActivateConcreteCommand(SharedInformationalChatCommand cmd)
 {
     if (!triggerResponses.ContainsKey(cmd.CommandTrigger))
     {
         triggerResponses.Add(cmd.CommandTrigger, cmd);
         CommandServer.AddCommand(chan.Channel, CommandPermissions.Unknown, "General", false, cmd.CommandTrigger, string.Empty, string.Empty, HandleConcreteCommand, cmd.CoolDownSeconds);
     }
 }
 private void ActivateConcreteCommand(SharedInformationalChatCommand cmd)
 {
     //if (!triggerResponses.ContainsKey(cmd.CommandTrigger))
     //{
     // triggerResponses.Add(cmd.CommandTrigger, cmd);
     CommandServer.AddCommand(chan.Channel, CommandPermissions.Unknown | CommandPermissions.Viewer | CommandPermissions.VIP | CommandPermissions.Bits1000p | CommandPermissions.Follower | CommandPermissions.BroadCaster | CommandPermissions.Subscriber | CommandPermissions.Bits100p, "General", false, cmd.CommandTrigger, string.Empty, string.Empty, HandleConcreteCommand, cmd.CoolDownSeconds);
     //}
 }
 private void DeactivateConcreteCommand(SharedInformationalChatCommand cmd)
 {
     lock (triggerResponses)
     {
         if (triggerResponses.ContainsKey(cmd.CommandTrigger))
         {
             triggerResponses.Remove(cmd.CommandTrigger);
             //triggerResponses.Remove(cmd.CommandTrigger, cmd);
             //CommandServer.(CommandPermissions.Unknown, "General", false, cmd.CommandTrigger, string.Empty, string.Empty, HandleConcreteCommand);
             CommandServer.RemCommand(chan.Channel, CommandPermissions.Unknown, "General", false, cmd.CommandTrigger, string.Empty, string.Empty, HandleConcreteCommand);
         }
     }
 }
 private void HandleConcreteCommand(string module, string[] command)
 {
     if (command != null && command.Length > 0)
     {
         SharedInformationalChatCommand cmd = null;
         lock (triggerResponses)
         {
             if (triggerResponses.ContainsKey(command[0]))
             {
                 cmd = triggerResponses[command[0]];
             }
         }
         BotOutput.Instance.ChatMessage(chan.Channel, cmd.CommandResponse);
     }
 }
示例#7
0
        public SharedInformationalChatCommand ConcreteChatCommandSave(SharedInformationalChatCommand ChatCommand)
        {
            SQLiteParameter[] sQLiteParameters = new SQLiteParameter[]
            {
                new SQLiteParameter(":channelname", ChatCommand.ChannelName),
                new SQLiteParameter(":commandtrigger", ChatCommand.CommandTrigger),
                new SQLiteParameter(":commandresponse", ChatCommand.CommandResponse),
                new SQLiteParameter(":usercreated", ChatCommand.UserCreated),
                new SQLiteParameter(":datecreated", ChatCommand.DateCreated),
                new SQLiteParameter(":usermodified", ChatCommand.UserModified),
                new SQLiteParameter(":datemodified", ChatCommand.DateModified),
                new SQLiteParameter(":commandpermissionrequired", ChatCommand.CommandPermissionRequired),
                new SQLiteParameter(":cooldownseconds", ChatCommand.CoolDownSeconds),
                new SQLiteParameter(":isactive", ChatCommand.IsActive),
                new SQLiteParameter(":commandid", ChatCommand.CommandId)
            };
            if (ChatCommand.CommandId != 0)
            {
                // Update
                SharedInformationalChatCommand result = ChatCommand;
                lock (this)
                {
                    string sql = UpdateConcreteChatCommandSQL + " CommandId=:commandid";
                    m_context.Database.ExecuteSqlCommand(sql, sQLiteParameters);
                }
                result = GetCommandByCommandTrigger(ChatCommand.CommandTrigger);


                return(result);
            }
            else
            {
                // Insert
                SharedInformationalChatCommand result = ChatCommand;
                //lock (this)
                //{
                string sql = InsertConcreteChatCommandSQL;
                m_context.Database.ExecuteSqlCommand(sql, sQLiteParameters);
                //}
                int resultid = m_context.Database.SqlQuery <int>(GetLastInsertedConcreteChatCommandSQL, new SQLiteParameter[] { }).FirstOrDefault();
                result = GetCommandByCommandTrigger(ChatCommand.CommandTrigger);
                return(result);
            }
        }
示例#8
0
        public SharedInformationalChatCommand GetCommandByCommandTrigger(string CommandTrigger)
        {
            if (string.IsNullOrEmpty(CommandTrigger) || string.IsNullOrWhiteSpace(CommandTrigger))
            {
                return(null);
            }

            SharedInformationalChatCommand ChatCommand = null;

            lock (this)
            {
                string sql = "select " + SelectConcreteChatCommandSQLFields + " from InformationalChatCommand where CommandTrigger=:commandtrigger;";
                ChatCommand = m_context.Database.SqlQuery <SharedInformationalChatCommand>(sql,
                                                                                           new SQLiteParameter[]
                {
                    new SQLiteParameter(":commandtrigger", CommandTrigger)
                }).FirstOrDefault();
            }
            return(ChatCommand);
        }
        private void RegisterChatCommand(string module, string[] param)
        {
            if (param != null && param.Length > 3)
            {
                string commandstring = param[1];
                string timeout       = param[2];
                int    intTimeout    = 0;
                Int32.TryParse(param[2], out intTimeout);

                StringBuilder sb = new StringBuilder();
                for (int i = 3; i < param.Length; i++)
                {
                    sb.AppendFormat("{0} ", param[i]);
                }

                string responsestring = sb.ToString().Trim();

                SharedInformationalChatCommand cmd = new SharedInformationalChatCommand()
                {
                    ChannelName = chan.Channel,
                    CommandPermissionRequired = CommandPermissions.Unknown.ToString(),
                    CoolDownSeconds           = intTimeout,
                    CommandResponse           = responsestring,
                    CommandTrigger            = commandstring,
                    DateCreated = DateTime.UtcNow,
                    UserCreated = "chat",
                    IsActive    = 1
                };
                cmd = storagePlugin.ConcreteChatCommandSave(cmd);
                ActivateConcreteCommand(cmd);
                BotOutput.Instance.ChatMessage(chan.Channel, string.Format("Command {0} activated", commandstring));
            }
            else
            {
                BotOutput.Instance.ChatMessage(chan.Channel, "Invalid Parameters - Please provide the command and the reponse for the command you want to add. To get help, type help !addcommand");
            }
        }
示例#10
0
 public void ConcreteChatCommandDelete(SharedInformationalChatCommand ChatCommand)
 {
     data.ConcreteChatCommandDelete(ChatCommand);
 }
示例#11
0
 public SharedInformationalChatCommand ConcreteChatCommandSave(SharedInformationalChatCommand ChatCommand)
 {
     return(data.ConcreteChatCommandSave(ChatCommand));
 }