Esempio n. 1
0
 public UserLeftHandler(DiscordSocketClient client, Logger logger, InternalStatistics internalStatistics, IServiceProvider provider)
 {
     Client             = client;
     Logger             = logger;
     InternalStatistics = internalStatistics;
     Provider           = provider;
 }
Esempio n. 2
0
 public UserJoinedHandler(DiscordSocketClient client, IOptions <Configuration> config, Logger logger, InternalStatistics internalStatistics)
 {
     Client             = client;
     Logger             = logger;
     InternalStatistics = internalStatistics;
     Config             = config.Value;
 }
Esempio 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);
                }
            }
        }
        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);
        }
Esempio n. 5
0
 public UserJoinedHandler(DiscordSocketClient client, InternalStatistics internalStatistics,
                          IServiceProvider services)
 {
     Client             = client;
     InternalStatistics = internalStatistics;
     Services           = services;
 }
Esempio n. 6
0
 public ReactionRemovedHandler(DiscordSocketClient client, EmoteStats emoteStats, InternalStatistics internalStatistics, UserService userService)
 {
     Client             = client;
     EmoteStats         = emoteStats;
     InternalStatistics = internalStatistics;
     UserService        = userService;
 }
Esempio n. 7
0
        private async Task OnClientReadyAsync()
        {
            InternalStatistics.IncrementEvent("Ready");

            await InitService.InitAsync();

            await SetActivityAsync();
        }
Esempio 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;
        }
        public GuildMemberUpdatedHandler(DiscordSocketClient client, InternalStatistics internalStatistics, IServiceProvider provider)
        {
            Client             = client;
            InternalStatistics = internalStatistics;
            Provider           = provider;

            Client.GuildMemberUpdated += OnGuildMemberUpdatedAsync;
        }
Esempio 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);
        }
Esempio n. 12
0
 public CommandExecutedHandler(CommandService commandService, IServiceProvider services, ILogger <CommandExecutedHandler> logger,
                               InternalStatistics internalStatistics)
 {
     CommandService     = commandService;
     Services           = services;
     Logger             = logger;
     InternalStatistics = internalStatistics;
 }
Esempio 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;
 }
Esempio 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);
        }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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);
        }
Esempio 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;
 }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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;
        }
Esempio 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;
        }
        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;
        }
Esempio 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);
            }
        }