Example #1
0
 public void SilentMode(WinterBot bot, TwitchUser user, string cmd, string value)
 {
     bot.Silent = !bot.Silent;
     bot.SendUnconditional("Silent mode now {0}.", bot.Silent ? "enabled" : "disabled");
 }
Example #2
0
        void CheckMessage(WinterBot bot, TwitchUser user, string text)
        {
            if (user.IsModerator)
            {
                return;
            }


            if (CheckAndTimeoutSpam(bot, user, text))
            {
                return;
            }

            string     clearReason = null;
            RegexMatch banWord     = null;

            Url[] urls;
            if (HasUrls(text, out urls))
            {
                // Check bans.
                if (MatchesAny(urls, m_urlBanlist))
                {
                    m_winterBot.Ban(user);
                    if (!string.IsNullOrEmpty(m_urlOptions.BanMessage))
                    {
                        bot.SendUnconditional("{0}: {1}", user.Name, m_urlOptions.BanMessage);
                    }

                    m_winterBot.WriteDiagnostic(DiagnosticFacility.Ban, "Banned {0} for {1}.", user.Name, string.Join(", ", urls.Select(url => url.FullUrl)));
                }
                else if ((m_urlOptions.ShouldEnforce(user) || m_denyList.Contains(user)) && (!MatchesAll(urls, m_urlWhitelist) || MatchesAny(urls, m_urlBlacklist)))
                {
                    if (m_permit.Contains(user))
                    {
                        m_permit.Remove(user);
                    }
                    else
                    {
                        clearReason = m_urlOptions.Message;
                    }
                }
            }
            else if (m_banWordOptions.ShouldEnforce(user) && HasBannedWord(text, out banWord))
            {
                clearReason = EnforceBannedWord(bot, user, banWord.String);
            }
            else if (m_symbolOptions.ShouldEnforce(user) && HasSpecialCharacter(text))
            {
                clearReason = m_symbolOptions.Message;
            }
            else if (m_capsOptions.ShouldEnforce(user) && TooManyCaps(user, text))
            {
                clearReason = m_capsOptions.Message;
            }
            else if (m_emoteOptions.ShouldEnforce(user) && TooManyEmotes(user, text))
            {
                clearReason = m_emoteOptions.Message;
            }
            else if (m_lengthOptions.ShouldEnforce(user) && MessageTooLong(user, text))
            {
                clearReason = m_lengthOptions.Message;
            }

            if (clearReason != null)
            {
                ClearChat(bot, user, clearReason);
            }
            else if (!user.IsModerator && !user.IsStreamer)
            {
                m_lastMsgs[m_currMsg++ % m_lastMsgs.Length] = new Tuple <TwitchUser, string>(user, text.ToLower());
            }
        }
        void CheckMessage(WinterBot bot, TwitchUser user, string text)
        {
            if (user.IsModerator)
                return;

            if (CheckAndTimeoutSpam(bot, user, text))
                return;

            string clearReason = null;
            RegexMatch banWord = null;

            Url[] urls;
            if (HasUrls(text, out urls))
            {
                // Check bans.
                if (MatchesAny(urls, m_urlBanlist))
                {
                    m_winterBot.Ban(user);
                    if (!string.IsNullOrEmpty(m_urlOptions.BanMessage))
                        bot.SendUnconditional("{0}: {1}", user.Name, m_urlOptions.BanMessage);

                    m_winterBot.WriteDiagnostic(DiagnosticFacility.Ban, "Banned {0} for {1}.", user.Name, string.Join(", ", urls.Select(url => url.FullUrl)));
                }
                else if ((m_urlOptions.ShouldEnforce(user) || m_denyList.Contains(user)) && (!MatchesAll(urls, m_urlWhitelist) || MatchesAny(urls, m_urlBlacklist)))
                {
                    if (m_permit.Contains(user))
                        m_permit.Remove(user);
                    else
                        clearReason = m_urlOptions.Message;
                }
            }
            else if (m_banWordOptions.ShouldEnforce(user) && HasBannedWord(text, out banWord))
            {
                clearReason = EnforceBannedWord(bot, user, banWord.String);
            }
            else if (m_symbolOptions.ShouldEnforce(user) && HasSpecialCharacter(text))
            {
                clearReason = m_symbolOptions.Message;
            }
            else if (m_capsOptions.ShouldEnforce(user) && TooManyCaps(user, text))
            {
                clearReason = m_capsOptions.Message;
            }
            else if (m_emoteOptions.ShouldEnforce(user) && TooManyEmotes(user, text))
            {
                clearReason = m_emoteOptions.Message;
            }
            else if (m_lengthOptions.ShouldEnforce(user) && MessageTooLong(user, text))
            {
                clearReason = m_lengthOptions.Message;
            }

            if (clearReason != null)
                ClearChat(bot, user, clearReason);
            else if (!user.IsModerator && !user.IsStreamer)
                m_lastMsgs[m_currMsg++ % m_lastMsgs.Length] = new Tuple<TwitchUser, string>(user, text.ToLower());
        }
Example #4
0
 public void QuietMode(WinterBot bot, TwitchUser user, string cmd, string value)
 {
     bot.Quiet = !bot.Quiet;
     bot.SendUnconditional("Quiet mode now {0}.", bot.Quiet ? "enabled" : "disabled");
 }