Ejemplo n.º 1
0
        private async Task HandleCommandAsync(SocketMessage arg)
        {
            var message = arg as SocketUserMessage;

            if (message is null || message.Author.IsBot)
            {
                return;
            }

            if (message.Content == ".acro")
            {
                if (IsAcroRunning((message.Author as SocketGuildUser).Guild))
                {
                    await(arg.Channel as ISocketMessageChannel).SendMessageAsync("acro already running!!!");
                    return;
                }
                Logger.Info("Acro initiated (" + (message.Author as SocketGuildUser).Guild.Name + ")");


                Acro instance = new Acro((arg.Channel as SocketGuildChannel).Guild, (arg.Channel as SocketChannel));

                acroInstances.Add(instance);
                instance.StartSubmissionTimer();
                //instance.SubmissionTimerElapsed += Instance_SubmissionTimerElapsed;
                instance.VoteTimerElapsed += Instance_VoteTimerElapsed;
            }
            //controllo se il messaggio è una potenziale acro submission per questo server o un voto
            else if (acroInstances.Count > 0)
            {
                for (int i = 0; i < acroInstances.Count; i++)
                {
                    if (acroInstances[i].GetChannel().Id == message.Channel.Id)
                    {
                        if (!acroInstances[i].IsVoteTimerEnabled() && acroInstances[i].IsSubmissionTimerEnabled() && acroInstances[i].RegisterSubmission(arg.Content, arg.Author))
                        {
                            Logger.Info(arg.Author + " submitted");
                            await arg.DeleteAsync();
                        }
                        else if (!acroInstances[i].IsSubmissionTimerEnabled() && acroInstances[i].RegisterVote(arg.Content, arg.Author))
                        {
                            Logger.Info(arg.Author + " voted");
                            await arg.DeleteAsync();
                        }
                        else
                        {
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void Instance_SubmissionTimerElapsed(Acro acroInstance)
 {
     //acroInstances.Remove(acroInstance);
 }
Ejemplo n.º 3
0
 private void Instance_VoteTimerElapsed(Acro acroInstance)
 {
     acroInstances.Remove(acroInstance);
 }