Пример #1
0
        async Task MainAsync(string[] args)
        {
            client = new DiscordClient(new DiscordConfiguration {
                Token                 = Tokens.QUIPCORD,
                TokenType             = TokenType.Bot,
                UseInternalLogHandler = true,
                LogLevel              = LogLevel.Debug
            });
            client.MessageCreated += async e => {
                try {
                    switch (e.Message.Content)
                    {
                    case "!save":
                        PeriodicSave();
                        break;

                    case "!exit":
                        PeriodicSave();
                        Environment.Exit(0);
                        break;
                    }
                    await acro.Handle(e);

                    await markov.Handle(e);

                    await paint.Handle(e);

                    await quip.Handle(e);

                    await quote.Handle(e);
                } catch (Exception ex) {
                    PeriodicSave();
                    //e.Channel.SendMessageAsync("Oops");
                    throw ex;
                }
            };
            acro   = Load <Acrolash>() ?? new Acrolash();
            markov = Load <Markovlash>() ?? new Markovlash();
            paint  = Load <Paintlash>() ?? new Paintlash();
            quip   = Load <Quiplash>() ?? new Quiplash();
            quote  = Load <Quotelash>() ?? new Quotelash();

            acro.OnLoad(this);
            markov.OnLoad(this);
            paint.OnLoad(this);
            quip.OnLoad(this);
            quote.OnLoad(this);

            PeriodicSave();
            await client.ConnectAsync();

            await Task.Delay(-1);
        }
Пример #2
0
 public void OnLoad(Program p)
 {
     this.client = p.client;
     quote       = p.quote;
 }