Esempio n. 1
0
        public ChatRelay(ZkLobbyServer zkServer, List <string> channels)
        {
            this.channels = channels;
            this.server   = zkServer;

            discord = new DiscordClient();

            springRelay = new SpringRelaySource(channels);
            sources.Add(springRelay);
            zklsRelay = new ZklsRelaySource(zkServer);
            sources.Add(zklsRelay);
            discordZkRelay = new DiscordRelaySource(discord, DiscordZkServerID, SaySource.Discord);
            sources.Add(discordZkRelay);
            discordSpringRelay = new DiscordRelaySource(discord, DiscordSpringServerID, SaySource.DiscordSpring);
            sources.Add(discordSpringRelay);


            restrictedSources.Add(zklsRelay);
            restrictedSources.Add(discordZkRelay);

            discord.Connect(new Secrets().GetNightwatchDiscordToken(), TokenType.Bot);

            foreach (var s in sources)
            {
                s.OnChatRelayMessage += OnAnySourceMessage;
            }

            timer = new Timer(TimerCallback, this, 1000, 2000);
        }
Esempio n. 2
0
        public ChatRelay(ZkLobbyServer zkServer, List <string> channels)
        {
            this.channels = channels;
            this.server   = zkServer;

            discord = new DiscordSocketClient();


            springRelay = new SpringRelaySource(channels);
            sources.Add(springRelay);
            zklsRelay = new ZklsRelaySource(zkServer);
            sources.Add(zklsRelay);

            discordZkRelay = new DiscordRelaySource(discord, DiscordZkServerID, SaySource.Discord);
            sources.Add(discordZkRelay);
            discordSpringRelay = new DiscordRelaySource(discord, DiscordSpringServerID, SaySource.DiscordSpring);
            sources.Add(discordSpringRelay);


            restrictedSources.Add(zklsRelay);
            restrictedSources.Add(discordZkRelay);

            var token = new Secrets().GetNightwatchDiscordToken();

            Task.Factory.StartNew(async() =>
            {
                try
                {
                    await discord.StartAsync();
                    await discord.LoginAsync(TokenType.Bot, token);
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error initializing discord connection/relay: {0}", ex);
                }
            }).Wait();


            foreach (var s in sources)
            {
                s.OnChatRelayMessage += OnAnySourceMessage;
            }

            timer = new Timer(TimerCallback, this, 1000, 2000);
        }