Exemplo n.º 1
0
 public ReactionRemovedHandler(DiscordSocketClient client, EmoteStats emoteStats, InternalStatistics internalStatistics, UserService userService)
 {
     Client             = client;
     EmoteStats         = emoteStats;
     InternalStatistics = internalStatistics;
     UserService        = userService;
 }
Exemplo n.º 2
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.º 3
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.º 4
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.º 5
0
 public MessageReceivedHandler(DiscordSocketClient client, CommandService commands, IOptions <Configuration> config, IServiceProvider services,
                               ChannelStats channelStats, AutoReplyService autoReply, EmoteChain emoteChain, CalledEventStats calledEventStats, Statistics statistics,
                               EmoteStats emoteStats)
 {
     Client           = client;
     Commands         = commands;
     Services         = services;
     ChannelStats     = channelStats;
     AutoReply        = autoReply;
     EmoteChain       = emoteChain;
     CalledEventStats = calledEventStats;
     Statistics       = statistics;
     EmoteStats       = emoteStats;
     Config           = config.Value;
 }
Exemplo n.º 6
0
        private async Task OnMessageReceivedAsync(SocketMessage message)
        {
            InternalStatistics.IncrementEvent("MessageReceived");

            if (!TryParseMessage(message, out SocketUserMessage userMessage))
            {
                return;
            }

            var context = new SocketCommandContext(Client, userMessage);

            if (context.IsPrivate)
            {
                return;
            }

            int argPos = 0;

            if (userMessage.HasStringPrefix(Config.CommandPrefix, ref argPos) || userMessage.HasMentionPrefix(Client.CurrentUser, ref argPos))
            {
                await Commands.ExecuteAsync(context, userMessage.Content.Substring(argPos), Services).ConfigureAwait(false);

                if (context.Guild != null)
                {
                    EmoteChain.CleanupAsync((SocketGuildChannel)context.Channel);
                }
            }
            else
            {
                if (context.Guild != null)
                {
                    UserService.IncrementMessage(context.User as SocketGuildUser, context.Guild, context.Channel as SocketGuildChannel);
                    await AutoReply.TryReplyAsync(context.Guild, userMessage).ConfigureAwait(false);
                }

                await EmoteChain.ProcessChainAsync(context).ConfigureAwait(false);

                EmoteStats.AnylyzeMessageAndIncrementValues(context);
            }
        }
Exemplo n.º 7
0
 public EmoteStatsController(EmoteStats emoteStats)
 {
     EmoteStats = emoteStats;
 }
Exemplo n.º 8
0
 private async Task OnReactionAddedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
 {
     CalledEventStats.Increment("ReactionAdded");
     await EmoteStats.IncrementFromReaction(reaction).ConfigureAwait(false);
 }
Exemplo n.º 9
0
 public ReactionAddedHandler(DiscordSocketClient client, EmoteStats emoteStats, CalledEventStats calledEventStats)
 {
     Client           = client;
     EmoteStats       = emoteStats;
     CalledEventStats = calledEventStats;
 }
Exemplo n.º 10
0
 private async Task OnReactionRemovedAsync(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
 {
     InternalStatistics.IncrementEvent("ReactionRemoved");
     EmoteStats.DecrementFromReaction(reaction);
     UserService.DecrementReaction(reaction);
 }
Exemplo n.º 11
0
        private async Task OnMessageReceivedAsync(SocketMessage message)
        {
            CalledEventStats.Increment("MessageReceived");

            var messageStopwatch = new Stopwatch();

            messageStopwatch.Start();

            try
            {
                if (!TryParseMessage(message, out SocketUserMessage userMessage))
                {
                    return;
                }

                var commandStopwatch = new Stopwatch();
                var context          = new SocketCommandContext(Client, userMessage);

                if (message.Channel is IPrivateChannel && !Config.IsUserBotAdmin(userMessage.Author.Id))
                {
                    return;
                }

                int argPos = 0;
                if (userMessage.HasStringPrefix(Config.CommandPrefix, ref argPos) || userMessage.HasMentionPrefix(Client.CurrentUser, ref argPos))
                {
                    await LogCommandAsync(userMessage, context, argPos).ConfigureAwait(false);

                    commandStopwatch.Start();
                    var result = await Commands.ExecuteAsync(context, userMessage.Content.Substring(argPos), Services).ConfigureAwait(false);

                    commandStopwatch.Stop();

                    if (!result.IsSuccess && result.Error != null)
                    {
                        switch (result.Error.Value)
                        {
                        case CommandError.UnknownCommand: return;

                        case CommandError.UnmetPrecondition:
                        case CommandError.ParseFailed:
                            await context.Channel.SendMessageAsync(result.ErrorReason.PreventMassTags()).ConfigureAwait(false);

                            break;

                        case CommandError.BadArgCount:
                            await SendCommandHelp(context, argPos).ConfigureAwait(false);

                            break;

                        default:
                            throw new BotException(result);
                        }
                    }

                    var command = message.Content.Split(' ')[0];
                    Statistics.LogCall(command, commandStopwatch.ElapsedMilliseconds);
                    await EmoteChain.CleanupAsync(context.Channel, true).ConfigureAwait(false);
                }
                else
                {
                    await ChannelStats.IncrementCounterAsync(userMessage.Channel).ConfigureAwait(false);

                    await AutoReply.TryReplyAsync(userMessage).ConfigureAwait(false);

                    await EmoteChain.ProcessChainAsync(context).ConfigureAwait(false);

                    await EmoteStats.AnylyzeMessageAndIncrementValuesAsync(context).ConfigureAwait(false);
                }
            }
            finally
            {
                messageStopwatch.Stop();
                Statistics.ComputeAvgReact(messageStopwatch.ElapsedMilliseconds);
            }
        }
Exemplo n.º 12
0
 public EmoteManagerModule(EmoteStats emoteStats)
 {
     EmoteStats = emoteStats;
 }
Exemplo n.º 13
0
 public EmoteManagerModule(EmoteStats emoteStats, PaginationService pagination) : base(paginationService: pagination)
 {
     EmoteStats = emoteStats;
 }
Exemplo n.º 14
0
 public EmoteStatsController(DcUserAuthorization auth, EmoteStats emoteStats)
 {
     Auth       = auth;
     EmoteStats = emoteStats;
 }