Ejemplo n.º 1
0
        public override string TryToExecute(CommandReceivedEventArgs eventArgs)
        {
            var    chatUser    = eventArgs.ChatUser;
            string channelName = eventArgs.Arguments?.ElementAtOrDefault(1);

            if (chatUser.CanUserRunCommand(UserRole.Mod))
            {
                if (string.IsNullOrWhiteSpace(channelName))
                {
                    return($"Please specify a valid channel name, @{chatUser.DisplayName}");
                }

                StreamerEntity entity = _repository.Single(StreamerEntityPolicy.ByChannel(channelName));
                if (entity == null)
                {
                    _repository.Create(new StreamerEntity {
                        ChannelName = channelName
                    });
                    return($"Added {channelName} to our list of streams! Thanks, {chatUser.DisplayName} !");
                }

                return($"We already have {channelName} in our list of streams!");
            }

            return($"You aren't allowed to add new streams, @{chatUser.DisplayName}.");
        }
Ejemplo n.º 2
0
        public override string TryToExecute(CommandReceivedEventArgs eventArgs)
        {
            var    chatUser    = eventArgs.ChatUser;
            string channelName = eventArgs.Arguments?.ElementAtOrDefault(1);

            if (chatUser.IsInThisRoleOrHigher(UserRole.Mod))
            {
                if (string.IsNullOrWhiteSpace(channelName))
                {
                    return($"Please specify a valid channel name, @{chatUser.DisplayName}");
                }

                StreamerEntity entity = _repository.Single(StreamerEntityPolicy.ByChannel(channelName));
                if (entity != null)
                {
                    _repository.Remove(entity);
                    return($"Removed {channelName} from our list of streams!");
                }

                return($"We don't have {channelName} in our list of streams! Check the spelling?");
            }

            return($"You aren't allowed to remove streams, @{chatUser.DisplayName}.");
        }