Exemplo n.º 1
0
 public UserLeftHandler(DiscordSocketClient client, Logger logger, InternalStatistics internalStatistics, IServiceProvider provider)
 {
     Client             = client;
     Logger             = logger;
     InternalStatistics = internalStatistics;
     Provider           = provider;
 }
Exemplo n.º 2
0
 public UserJoinedHandler(DiscordSocketClient client, IOptions <Configuration> config, Logger logger, InternalStatistics internalStatistics)
 {
     Client             = client;
     Logger             = logger;
     InternalStatistics = internalStatistics;
     Config             = config.Value;
 }
Exemplo n.º 3
0
        private async Task OnReactionAddedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            InternalStatistics.IncrementEvent("ReactionAdded");

            using var scope = Provider.CreateScope();
            await scope.ServiceProvider.GetService <EmoteStats>().IncrementFromReactionAsync(reaction);

            if (reaction.User.IsSpecified && reaction.User.Value.IsUser())
            {
                await PaginationService.HandleReactionAsync(reaction);

                await scope.ServiceProvider.GetService <UserReactionsService>().IncrementReactionStatsAsync(reaction);

                await scope.ServiceProvider.GetService <ReminderService>().HandleRemindCopyAsync(reaction);

                if (channel is SocketTextChannel textChannel)
                {
                    await scope.ServiceProvider.GetService <PointsService>().IncrementPointsAsync(textChannel.Guild, reaction);
                }

                if (message.HasValue)
                {
                    await scope.ServiceProvider.GetService <ReminderService>().PostponeReminderAsync(message.Value, reaction);
                }
            }
        }
Exemplo n.º 4
0
        private async Task OnMessageDeletedAsync(Cacheable <IMessage, ulong> message, ISocketMessageChannel channel)
        {
            InternalStatistics.IncrementEvent("MessageDeleted");
            if (channel is IPrivateChannel || (message.HasValue && !message.Value.Author.IsUser()))
            {
                return;
            }

            SocketGuildUser user = null;

            if (message.HasValue && message.Value.Author is SocketGuildUser guildUser)
            {
                user = guildUser;
            }
            else if (MessageCache.Exists(message.Id))
            {
                var author = MessageCache.Get(message.Id).Author;
                user = author is SocketGuildUser socketGuildUser ? socketGuildUser : null;
            }

            using var scope = Provider.CreateScope();

            if (user != null)
            {
                await scope.ServiceProvider.GetService <UserMessagesService>().DecrementMessageStats(user.Guild, user, channel);
            }

            await Logger.OnMessageDelete(message, channel).ConfigureAwait(false);

            PaginationService.DeleteEmbed(message.Id);
        }
Exemplo n.º 5
0
 public UserJoinedHandler(DiscordSocketClient client, InternalStatistics internalStatistics,
                          IServiceProvider services)
 {
     Client             = client;
     InternalStatistics = internalStatistics;
     Services           = services;
 }
Exemplo n.º 6
0
 public ReactionRemovedHandler(DiscordSocketClient client, EmoteStats emoteStats, InternalStatistics internalStatistics, UserService userService)
 {
     Client             = client;
     EmoteStats         = emoteStats;
     InternalStatistics = internalStatistics;
     UserService        = userService;
 }
Exemplo n.º 7
0
        private async Task OnClientReadyAsync()
        {
            InternalStatistics.IncrementEvent("Ready");

            await InitService.InitAsync();

            await SetActivityAsync();
        }
Exemplo n.º 8
0
 public ReactionAddedHandler(DiscordSocketClient client, InternalStatistics internalStatistics, PaginationService paginationService,
                             IServiceProvider provider)
 {
     Client             = client;
     InternalStatistics = internalStatistics;
     PaginationService  = paginationService;
     Provider           = provider;
 }
        public GuildMemberUpdatedHandler(DiscordSocketClient client, Logger logger, InternalStatistics internalStatistics)
        {
            Logger             = logger;
            Client             = client;
            InternalStatistics = internalStatistics;

            Client.GuildMemberUpdated += OnGuildMemberUpdatedAsync;
        }
Exemplo n.º 10
0
        public GuildMemberUpdatedHandler(DiscordSocketClient client, InternalStatistics internalStatistics, IServiceProvider provider)
        {
            Client             = client;
            InternalStatistics = internalStatistics;
            Provider           = provider;

            Client.GuildMemberUpdated += OnGuildMemberUpdatedAsync;
        }
Exemplo n.º 11
0
        private async Task OnUserLeftAsync(SocketGuildUser user)
        {
            InternalStatistics.IncrementEvent("UserLeft");
            await Logger.OnUserLeft(user).ConfigureAwait(false);

            using var scope = Provider.CreateScope();
            await scope.ServiceProvider.GetService <UnverifyService>().OnUserLeftGuildAsync(user);
        }
Exemplo n.º 12
0
 public CommandExecutedHandler(CommandService commandService, IServiceProvider services, ILogger <CommandExecutedHandler> logger,
                               InternalStatistics internalStatistics)
 {
     CommandService     = commandService;
     Services           = services;
     Logger             = logger;
     InternalStatistics = internalStatistics;
 }
Exemplo n.º 13
0
 public MessageDeletedHandler(DiscordSocketClient client, InternalStatistics internalStatistics,
                              PaginationService paginationService, IMessageCache messageCache, IServiceProvider provider)
 {
     Client             = client;
     InternalStatistics = internalStatistics;
     PaginationService  = paginationService;
     MessageCache       = messageCache;
     Provider           = provider;
 }
Exemplo n.º 14
0
        private async Task OnUserUnbannedAsync(SocketUser user, SocketGuild guild)
        {
            InternalStatistics.IncrementEvent("UserUnbanned");

            using var scope = ServiceProvider.CreateScope();
            var auditService = scope.ServiceProvider.GetService <AuditService>();

            await auditService.RunTaskAsync(ActionType.Unban, guild);
        }
Exemplo n.º 15
0
 public ReportsController(BotStatusService statusService, InternalStatistics internalStatistics, ApiStatistics apiStatistics,
                          DiscordSocketClient discordClient, IHostApplicationLifetime applicationLifetime)
 {
     StatusService       = statusService;
     InternalStatistics  = internalStatistics;
     ApiStatistics       = apiStatistics;
     DiscordClient       = discordClient;
     ApplicationLifetime = applicationLifetime;
 }
Exemplo n.º 16
0
 public AdminController(BotStatusService service, InternalStatistics internalStatistics, ConfigRepository configRepository, DiscordSocketClient discordSocket,
                        TeamSearchService teamSearchService)
 {
     StatusService      = service;
     InternalStatistics = internalStatistics;
     ConfigRepository   = configRepository;
     DiscordClient      = discordSocket;
     TeamSearchService  = teamSearchService;
 }
Exemplo n.º 17
0
        private async Task OnReactionAddedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            InternalStatistics.IncrementEvent("ReactionAdded");

            EmoteStats.IncrementFromReaction(reaction);
            await PaginationService.HandleReactionAsync(reaction);

            UserService.IncrementReaction(reaction);
        }
Exemplo n.º 18
0
 public ReactionAddedHandler(DiscordSocketClient client, EmoteStats emoteStats, InternalStatistics internalStatistics,
                             PaginationService paginationService, UserService userService)
 {
     Client             = client;
     EmoteStats         = emoteStats;
     InternalStatistics = internalStatistics;
     PaginationService  = paginationService;
     UserService        = userService;
 }
Exemplo n.º 19
0
        private async Task OnUserJoinedOnServerAsync(SocketGuildUser user)
        {
            InternalStatistics.IncrementEvent("UserJoined");

            using var scope = Services.CreateScope();

            await scope.ServiceProvider.GetService <AuditService>().LogUserJoinAsync(user);

            await scope.ServiceProvider.GetService <InviteTrackerService>().OnUserJoinedAsync(user);
        }
Exemplo n.º 20
0
        private async Task OnReactionRemovedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            InternalStatistics.IncrementEvent("ReactionRemoved");

            using var scope = Provider.CreateScope();

            await scope.ServiceProvider.GetService <EmoteStats>().DecrementFromReactionAsync(reaction);

            await scope.ServiceProvider.GetService <UserReactionsService>().DecrementReactionStatsAsync(reaction);
        }
Exemplo n.º 21
0
        private async Task OnUserJoinedOnServerAsync(SocketGuildUser user)
        {
            InternalStatistics.IncrementEvent("UserJoined");

            await Logger.OnUserJoined(user).ConfigureAwait(false);

            using var scope = Services.CreateScope();
            var inviteTracker = scope.ServiceProvider.GetService <InviteTrackerService>();
            await inviteTracker.OnUserJoinedAsync(user);
        }
Exemplo n.º 22
0
 public MessageDeletedHandler(DiscordSocketClient client, Logger logger, InternalStatistics internalStatistics,
                              PaginationService paginationService, IMessageCache messageCache, UserService userService)
 {
     Client             = client;
     Logger             = logger;
     InternalStatistics = internalStatistics;
     PaginationService  = paginationService;
     MessageCache       = messageCache;
     UserService        = userService;
 }
Exemplo n.º 23
0
 public ReportsController(BotStatusService statusService, InternalStatistics internalStatistics, DiscordSocketClient discordClient,
                          BackgroundTaskQueue backgroundTaskQueue, AuditService auditService, UserService userService)
 {
     StatusService       = statusService;
     InternalStatistics  = internalStatistics;
     DiscordClient       = discordClient;
     BackgroundTaskQueue = backgroundTaskQueue;
     AuditService        = auditService;
     UserService         = userService;
 }
Exemplo n.º 24
0
 public MessageReceivedHandler(DiscordSocketClient client, CommandService commands, IServiceProvider services,
                               EmoteChain emoteChain, InternalStatistics internalStatistics, ConfigurationService configurationService,
                               BotState botState)
 {
     Client               = client;
     Commands             = commands;
     Services             = services;
     EmoteChain           = emoteChain;
     InternalStatistics   = internalStatistics;
     ConfigurationService = configurationService;
     BotState             = botState;
 }
Exemplo n.º 25
0
 public ReportsController(BotStatusService statusService, InternalStatistics internalStatistics, ApiStatistics apiStatistics,
                          DiscordSocketClient discordClient, IHostApplicationLifetime applicationLifetime, BackgroundTaskQueue backgroundTaskQueue,
                          AuditService auditService, UserService userService)
 {
     StatusService       = statusService;
     InternalStatistics  = internalStatistics;
     ApiStatistics       = apiStatistics;
     DiscordClient       = discordClient;
     ApplicationLifetime = applicationLifetime;
     BackgroundTaskQueue = backgroundTaskQueue;
     AuditService        = auditService;
     UserService         = userService;
 }
Exemplo n.º 26
0
 public MessageReceivedHandler(DiscordSocketClient client, CommandService commands, IOptions <Configuration> config, IServiceProvider services,
                               AutoReplyService autoReply, EmoteChain emoteChain, InternalStatistics internalStatistics, EmoteStats emoteStats, UserService userService)
 {
     Client             = client;
     Commands           = commands;
     Services           = services;
     AutoReply          = autoReply;
     EmoteChain         = emoteChain;
     InternalStatistics = internalStatistics;
     EmoteStats         = emoteStats;
     Config             = config.Value;
     UserService        = userService;
 }
Exemplo n.º 27
0
        public GrillBotService(IServiceProvider services, DiscordSocketClient client, CommandService commands, IOptions <Configuration> config,
                               InternalStatistics internalStatistics, InitService initService, ILogger <GrillBotService> logger)
        {
            Services           = services;
            Client             = client;
            Commands           = commands;
            Config             = config.Value;
            InternalStatistics = internalStatistics;
            InitService        = initService;
            Logger             = logger;

            Client.Ready += OnClientReadyAsync;
        }
Exemplo n.º 28
0
        public GrillBotService(IServiceProvider services, DiscordSocketClient client, CommandService commands, InternalStatistics internalStatistics,
                               InitService initService, BotState botState, ConfigurationService configurationService)
        {
            Services             = services;
            Client               = client;
            Commands             = commands;
            InternalStatistics   = internalStatistics;
            InitService          = initService;
            BotState             = botState;
            ConfigurationService = configurationService;

            Client.Ready += OnClientReadyAsync;
        }
Exemplo n.º 29
0
        private async Task OnGuildMemberUpdatedAsync(SocketGuildUser guildUserBefore, SocketGuildUser guildUserAfter)
        {
            if (LastEventAt != DateTime.MinValue && (DateTime.UtcNow - LastEventAt).TotalSeconds < 1.0D)
            {
                return;
            }

            InternalStatistics.IncrementEvent("GuildMemberUpdated");

            using var scope = Provider.CreateScope();
            await scope.ServiceProvider.GetService <AuditService>().ProcessBoostChangeAsync(guildUserBefore, guildUserAfter);

            LastEventAt = DateTime.UtcNow;
        }
Exemplo n.º 30
0
        private async Task OnMessageUpdatedAsync(Cacheable <IMessage, ulong> messageBefore, SocketMessage messageAfter, ISocketMessageChannel channel)
        {
            InternalStatistics.IncrementEvent("MessageUpdated");

            if (!messageAfter.Author.IsUser() || channel is IPrivateChannel)
            {
                return;
            }
            if (channel is SocketGuildChannel guildChannel)
            {
                using var scope = Provider.CreateScope();

                await scope.ServiceProvider.GetService <AuditService>().LogMessageEditedAsync(messageBefore, messageAfter, channel, guildChannel.Guild);
            }
        }