Beispiel #1
0
        public void JukeBoxCommand(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            if (!m_enabled)
            {
                if (!sender.CanUseCommand(user, AccessLevel.Mod))
                {
                    if (m_lastMessage.Elapsed().TotalSeconds <= 30)
                        return;

                    m_lastMessage = DateTime.Now;
                    sender.SendResponse(Importance.Low, "The jukebox is CLOSED. No additional requests are being accepted.");
                    return;
                }

                value = value.Trim().ToLower();

                if (value == "on")
                {
                    m_enabled = true;
                    m_lastMessage = DateTime.Now;
                    sender.SendResponse(Importance.Med, "Jukebox activated.  Use '!JukeboxMode off' to deactivate.");
                }
                else if (value == "off")
                {
                    sender.SendResponse(Importance.Med, "Jukebox mode is off.");
                }
                else
                {
                    sender.SendResponse(Importance.Low, "Usage: '!jukebox on' and '!jukebox off'.  Mod only.");
                }
            }
            else
            {
                if (sender.CanUseCommand(user, AccessLevel.Mod))
                {
                    if (value == "on")
                    {
                        sender.SendResponse(Importance.Low, "Jukebox mode is already enabled.");
                    }
                    else if (value == "off")
                    {
                        sender.SendResponse(Importance.High, "The jukebox is shutting down for the night. Please hold your song requests for next time.");
                        m_enabled = false;
                    }
                    else
                    {
                        SendMessage(sender);
                    }
                }
                else
                {
                    if (m_lastMessage.Elapsed().TotalSeconds <= 10)
                        return;

                    m_lastMessage = DateTime.Now;
                    SendMessage(sender);
                }
            }
        }
Beispiel #2
0
        void UnknownCommandReceived(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            if (!m_options.UserCommandsEnabled)
            {
                return;
            }

            cmd = cmd.ToLower();
            UserCommand command;

            if (m_commands.TryGetValue(cmd, out command))
            {
                if (sender.CanUseCommand(user, command.AccessRequired))
                {
                    // Keep user commands from spamming chat, only one once every 20 seconds (unless you are a mod).
                    if (m_lastMessage.Elapsed().TotalSeconds >= m_options.UserCommandDelay || sender.CanUseCommand(user, AccessLevel.Mod))
                    {
                        sender.SendResponse(Importance.Low, command.Value);
                        m_lastMessage = DateTime.Now;
                    }
                }
            }
        }
        void UnknownCommandReceived(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            cmd = cmd.ToLower();
            Command command;

            lock (m_sync)
                if (!m_commands.TryGetValue(cmd, out command))
                    return;

            if (!sender.CanUseCommand(user, command.AccessLevel))
            {
                WinterBotSource.Log.DenyCommand(user.Name, cmd, "access");
                return;
            }

            if (CanSendCommand(user, cmd))
            {
                sender.SendResponse(Importance.Low, command.Text);
                m_sent.AddLast(new Tuple<string, DateTime>(cmd, DateTime.Now));
            }
        }