Пример #1
0
        internal override void ObserveCommand(TwitchUser speaker, string message)
        {
            if (enabled)
            {
                message = message?.Trim();
                string reqestedCommandName = message?.GetBefore(" ");
                if (reqestedCommandName == null)
                {
                    reqestedCommandName = message;
                }

                if (reqestedCommandName != null)
                {
                    bool match = reqestedCommandName.Equals(commandName, StringComparison.CurrentCultureIgnoreCase);
                    if (!match)
                    {
                        if (aliases != null)
                        {
                            foreach (var alias in aliases)
                            {
                                if (reqestedCommandName.Equals(alias, StringComparison.CurrentCultureIgnoreCase))
                                {
                                    match = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (match)
                    {
                        if (!modOnly || speaker.id.Equals(room.twitchConnection.channel.user.id))
                        {
                            ulong id = 0;
                            if (throttlePerUser)
                            {
                                id = speaker.id;
                            }
                            if (throttle == null || throttle.ExecuteIfReady(id))
                            {
                                string additionalText = message.GetAfter(" ")?.Trim();
                                action(speaker, additionalText);
                            }
                            else
                            {
                                room.SendWhisper(speaker, "Too soon... wait at least " + throttle.TimeRemaining(id).ToSimpleString() + " before running !" + commandName + " again.");
                            }
                        }
                        else
                        {
                            room.SendWhisper(speaker, "Sorry, !" + commandName + " is for mods only.");
                        }
                    }
                }
            }
        }