Ejemplo n.º 1
0
        public bool Parse(UserMessage message)
        {
            Match match = Regex.Match(message.Message, RegexString);
            var isAdminChannel = message.Channel.Name == _chat.Channels["mods"];

            return match.Success && isAdminChannel;
        }
Ejemplo n.º 2
0
        public bool Parse(UserMessage message)
        {
            Match match = Regex.Match(message.Message, "!([a-zA-Z0-9_]+)$");
            var cooldownPassed = _lastUsed < DateTime.Now - TimeSpan.FromSeconds(15);

            return match.Success && cooldownPassed;
        }
Ejemplo n.º 3
0
        public void Execute(UserMessage userMessage)
        {
            var search = userMessage.From.Nick;

            var reply = GetQuoteFromDatabase(search);
            if (reply == null) return;

            _chat.SendMessage(userMessage.Channel.Name, reply);
        }
Ejemplo n.º 4
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string message = match.Groups[1].ToString();

            string reply = AddQuoteToDatabase(userMessage.From.Nick, message);
            _chat.SendMessage(userMessage.Channel.Name, reply);
        }
Ejemplo n.º 5
0
        public TomeReply Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, "!([a-zA-Z0-9_]+)$");

            string command = match.Groups[1].ToString();

            var message = GetCommandFromDatabase(command);
            return new TomeReply(userMessage.Channel, message);
        }
Ejemplo n.º 6
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string description = match.Groups[1].ToString();

            HighlightIn30Minutes(userMessage.From.Nick, DateTime.Now.ToString("t"), description);
            _chat.SendMessage(userMessage.Channel.Name, DefaultReplies.Confirmation());
        }
Ejemplo n.º 7
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string search = match.Groups[1].ToString();

            var message = GetInfoFromDatabase(search);

            _chat.SendMessage(userMessage.Channel.Name, "/me :: " + message);
        }
Ejemplo n.º 8
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string name = match.Groups[1].ToString();
            int count = int.Parse(match.Groups[2].ToString());

            var reply = AddVoteToDatabase(userMessage.From.Nick, name, count);
            _chat.SendMessage(userMessage.Channel.Name, reply);
        }
Ejemplo n.º 9
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string trigger = match.Groups[1].Value.ToLower();
            string message = match.Groups[2].Value;

            var reply = AddReplyToDatabase(userMessage.From.Nick, trigger, message);
            _chat.SendMessage(userMessage.Channel.Name, reply);
        }
Ejemplo n.º 10
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string table = match.Groups[1].ToString();
            string id = match.Groups[2].ToString();

            var message = GetTableEntry(table, id);
            _chat.SendMessage(userMessage.Channel.Name, "/me :: " + message);
        }
Ejemplo n.º 11
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string tableName = match.Groups[1].Value.ToLower();
            string id = match.Groups[2].Value;

            var message = DeleteEntryFromDatabase(tableName, id);
            _chat.SendMessage(userMessage.Channel.Name, "/me :: " + message);
        }
Ejemplo n.º 12
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string addedBy = userMessage.From.Nick;
            string trigger = match.Groups[1].ToString();
            string reply = match.Groups[2].ToString();

            var message = AddCommandToDatabase(addedBy, trigger, reply);
            _chat.SendMessage(userMessage.Channel.Name, "/me :: " + message);
        }
Ejemplo n.º 13
0
        public void Execute(UserMessage userMessage)
        {
            var search = userMessage.Message;

            var reply = GetReplyFromDatabase(search);
            if (reply == "") return;

            reply = ReplaceWildcards(userMessage.From.Nick, reply);

            _chat.SendMessage(userMessage.Channel.Name, reply);
        }
Ejemplo n.º 14
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            string type = match.Groups[1].Value.ToLower();
            string id = match.Groups[2].Value;
            string toReplace = match.Groups[3].Value;
            string replaceWith = match.Groups[4].Value;

            var message = EditEntry(type, id, toReplace, replaceWith);
            _chat.SendMessage(userMessage.Channel.Name, "/me :: " + message);
        }
Ejemplo n.º 15
0
        public string Execute(UserMessage userMessage)
        {
            string type = "";
            string args = null;

            Match match = Regex.Match(userMessage.Message, RegexString2);

            if (match.Success) // first case: two arguments (for commands such as reply)
            {
                type = match.Groups[1].Value;
                args = match.Groups[2].Value;
            }
            else // Check if request follows 1 argument syntax
            {
                match = Regex.Match(userMessage.Message, RegexString1);

                if (match.Success)
                {
                    //_chat.SendStatus(Main.chatMods, "currently not functional");
                    type = match.Groups[1].Value;
                }
            }

            switch (type)
            {
                case "reply":
                    CheckReplies(args);
                    break;
                case "quote":
                    CheckQuotes(args);
                    break;
                case "command":
                    CheckCommand(args);
                    break;
                case "question":
                    CheckQuestion(args);
                    break;
                case "special":
                    CheckSpecial(args);
                    break;
                case "repeat":
                    CheckRepeat(args);
                    break;
                default:
                    //_chat.SendStatus(Main.chatMods, "Type " + type + " not found.");
                    break;
            }

            return "";
        }
Ejemplo n.º 16
0
        public void Execute(UserMessage userMessage)
        {
            Match match = Regex.Match(userMessage.Message, RegexString);

            var search = match.Groups[1].ToString();
            if (search == "") search = match.Groups[2].ToString();

            var reply = GetReplyFromDatabase(search);
            if (reply == null) return;

            reply = ReplaceWildcards(userMessage.From.Nick, reply);

            _chat.SendMessage(userMessage.Channel.Name, reply);
        }
Ejemplo n.º 17
0
        public bool Parse(UserMessage message)
        {
            var user = message.From.Nick;

            //If user hasn't been seen for an over hour, remove from the list.
            if (_seenInLastHour.ContainsKey(user) && _seenInLastHour[user] < DateTime.Now - TimeSpan.FromHours(1))
                _seenInLastHour.Remove(message.From.Nick);

            bool seen = _seenInLastHour.ContainsKey(user);
            bool random = r.Next(0, 100) < 10;

            _seenInLastHour[user] = DateTime.Now;

            return random && !seen;
        }
Ejemplo n.º 18
0
        public string Execute(UserMessage userMessage)
        {
            if (userMessage.Channel != _chat.ModChannel)
                return "";

            Match match = Regex.Match(userMessage.Message, RegexString);

            if (match.Success)
            {
                string username = match.Groups[1].Value;
                DateTime duration = DateTime.Now + TimeSpan.FromMinutes(Double.Parse(match.Groups[2].Value));

                // only process the command if the user isnt already timed out
                if (!_blacklist.ContainsKey(username)) _blacklist.Add(username, duration);
            }

            //_chat.SendStatus(Main.chatMods, "SYNTAX: '@tomeout A B' where A is a username, and B is a duration in minutes.");

            return "";
        }
Ejemplo n.º 19
0
        protected override void OnMessage(TwitchIrcChannel channel, TwitchChannelUser from, string message)
        {
            var userMessage = new UserMessage(channel, from, message);
            ReceivedMessages.Add(userMessage);
            //TODO: If user is either opted out or blacklisted, return void here.

            //If a user message can be parsed into a command, print a reply message and ignore everything else.
            foreach (var command in _commands)
            {
                if (command.Parse(userMessage))
                {
                    try
                    {
                        ExecuteCommand(command, userMessage);
                    }
                    catch (Exception ex)
                    {
                        var x = ex;
                    }
                    return;
                }
            }
        }
Ejemplo n.º 20
0
 private void ExecuteCommand(ICommand command, UserMessage userMessage)
 {
     command.Execute(userMessage);
 }
Ejemplo n.º 21
0
 public bool Parse(UserMessage userMessage)
 {
     Match match = Regex.Match(userMessage.Message, RegexString);
     return match.Success;
 }
Ejemplo n.º 22
0
        public bool Parse(UserMessage message)
        {
            var random = r.Next(0, 100) < 5;

            return random;
        }
Ejemplo n.º 23
0
 private void ExecuteCommand(ICommand command, UserMessage userMessage)
 {
     command.Execute(userMessage);
 }