Exemplo n.º 1
0
        public void Deny(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            value = value.Trim();

            if (!TwitchUsers.IsValidUserName(value))
            {
                sender.SendResponse(Importance.Med, "{0}: Usage: !deny [user]", user.Name);
                return;
            }

            var target = sender.Users.GetUser(value);

            if (target.IsModerator)
            {
                return;
            }

            if (m_permit.Contains(target))
            {
                m_permit.Remove(target);
            }

            m_denyList.Add(target);
            sender.SendResponse(Importance.High, "{0}: {1} is no longer allowed to post links.", user.Name, target.Name);
        }
Exemplo n.º 2
0
 protected override IEnumerable <TwitchUser> Deserialize(IEnumerable <string> lines)
 {
     foreach (var line in lines.Select(l => l.Trim()))
     {
         if (!string.IsNullOrWhiteSpace(line) && TwitchUsers.IsValidUserName(line))
         {
             yield return(Bot.Users.GetUser(line));
         }
     }
 }
Exemplo n.º 3
0
        private void SetRegular(WinterBot sender, string cmd, string value, bool regular)
        {
            value = value.Trim();
            if (!TwitchUsers.IsValidUserName(value))
            {
                sender.WriteDiagnostic(DiagnosticFacility.UserError, "{0}: Invalid username '{1}.", cmd, value);
                return;
            }

            TwitchUser target = sender.Users.GetUser(value);

            target.IsRegular = regular;
            sender.SendResponse(Importance.Med, "{0} {1} the regular list.", target.Name, regular ? "added to " : "removed from");
        }
Exemplo n.º 4
0
        public void Permit(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            Debug.Assert(m_winterBot == sender);

            value = value.Trim();
            if (!TwitchUsers.IsValidUserName(value))
            {
                m_winterBot.WriteDiagnostic(DiagnosticFacility.UserError, "{0}: Invalid username '{1}.", cmd, value);
                return;
            }

            var target = sender.Users.GetUser(value);

            if (target.IsModerator)
            {
                return;
            }

            bool removed = m_denyList.TryRemove(target);

            if (removed)
            {
                if (m_urlOptions.ShouldEnforce(target))
                {
                    m_winterBot.SendResponse(Importance.Med, "{0}: {1} was removed from the deny list.", user.Name, target.Name);
                }
                else
                {
                    m_winterBot.SendResponse(Importance.Med, "{0}: {1} can now post links again.", user.Name, target.Name);
                }
            }
            else
            {
                if (m_urlOptions.ShouldEnforce(target))
                {
                    m_permit.Add(target);
                    m_winterBot.SendResponse(Importance.Med, "{0} -> {1} has been granted permission to post a single link.", user.Name, target.Name);
                }
                else
                {
                    m_winterBot.SendResponse(Importance.Low, "{0}: {1} can posts links.", user.Name, target.Name);
                }
            }
        }
Exemplo n.º 5
0
        void UserFollowedHandler(string channel, IEnumerable <string> users)
        {
            if (!channel.Equals(m_channel, StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }

            var evt = UserFollowed;

            if (evt != null)
            {
                foreach (var user in users)
                {
                    if (TwitchUsers.IsValidUserName(user))
                    {
                        evt(this, Users.GetUser(user));
                    }
                }
            }
        }
Exemplo n.º 6
0
        public TwitchUser GetUser()
        {
            MovePastWhitespace();

            string name = GetOneWord(' ');

            if (name == null)
            {
                Error = "Expected twitch user.";
                return(null);
            }
            else if (!TwitchUsers.IsValidUserName(name))
            {
                Error = string.Format("{0} is not a valid twitch user.", name);
                return(null);
            }

            MovePastWhitespace();

            return(m_users.GetUser(name));
        }