Exemplo n.º 1
0
        public bool Run(IApiClient sender, GenericEventArgs args)
        {
            switch (args)
            {
            case FriendMessageEventArgs friendMessage:
            {
                var banned = _service.IsBanned(friendMessage.User.Identity, out var reason);
                if (banned)
                {
                    _logger.LogInformation("Message rejected ({}) for {}", friendMessage.Message.ToString(),
                                           reason);
                }

                return(!banned);
            }

            case GroupMessageEventArgs groupMessage:
            {
                var banned = _service.IsBanned(groupMessage.User.Identity, out var reason);
                if (banned)
                {
                    _logger.LogInformation("Message rejected: ({}) for {}", groupMessage.Message.ToString(),
                                           reason);
                }

                return(!banned);
            }

            default:
                return(true);
            }
        }
Exemplo n.º 2
0
 public async Task Check(Friend friend, long who)
 {
     _ = _service.IsBanned(who, out var reason);
     await friend.SendPlainAsync($"{who} has been banned for {reason}.");
 }
Exemplo n.º 3
0
 public static bool IsBanned(this User user)
 {
     return(service.IsBanned(user.Identity, out _));
 }