Ejemplo n.º 1
0
        public static void Init(BaseSocketClient client, IConfiguration config)
        {
            VkApi.Init(config);
            _posts = new List <VkApi.GroupPost>();

            foreach (var guild in client.Guilds)
            {
                foreach (var channel in guild.Channels)
                {
                    if (channel.Name.Equals("streamer-feed"))
                    {
                        _channel = client.GetChannel(channel.Id) as IMessageChannel;
                    }
                }
            }

            _groups = new List <Group>();
            try
            {
                using var sr = new StreamReader("vk_groups.json");
                var text = sr.ReadToEnd();
                var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(text);
                foreach (var(key, value) in dict)
                {
                    _groups.Add(new Group(key, value));
                }
            }
            catch (Exception e)
            {
                Logger.Fatal($"Can't load vk_groups.json: {e}");
            }

            _isRunning = true;
        }
Ejemplo n.º 2
0
        public async Task StartAsync()
        {
            if (_statusMessage == null)
            {
                await UpdateStatuses();

                var channel = (IMessageChannel)_discord.GetChannel(_config.GetValue <ulong>("StatusChannelId"));
                _statusMessage = await channel.SendMessageAsync("", false, GenerateEmbed());
            }

            if (_statusUpdateTimer != null)
            {
                throw new StatusException("Already started");
            }

            _statusUpdateTimer = new Timer(UpdateAsync, null, 0, Timeout.Infinite);
        }
Ejemplo n.º 3
0
        public static void Init(BaseSocketClient client, IConfiguration config)
        {
            foreach (var guild in client.Guilds)
            {
                foreach (var channel in guild.TextChannels)
                {
                    if (channel.Name.Equals("anime-feed"))
                    {
                        _channel = client.GetChannel(channel.Id) as IMessageChannel;
                    }
                }
            }

            _animeRepository = new AnimeRepository(config["db_anime"]);

            _torrentDownload = new TorrentDownload(config);
        }
Ejemplo n.º 4
0
        public static void Init(BaseSocketClient client, IConfiguration config)
        {
            var configuration = config;

            Api = new TwitchAPI();
            Api.Settings.ClientId    = configuration["client_id"];
            Api.Settings.AccessToken = configuration["client_token"];

            foreach (var guilds in client.Guilds)
            {
                foreach (var channel in guilds.Channels)
                {
                    if (channel.Name.Equals("streamer-feed"))
                    {
                        _channel = client.GetChannel(channel.Id) as IMessageChannel;
                    }
                }
            }

            _streamers = new List <StreamerInfo>();
        }
Ejemplo n.º 5
0
 /// <summary>Retrieves a <see cref="ISocketMessageChannel"/> from the given client.
 /// The value will be null if the channel doesn't exist, is not accesible, or isn't a message channel.</summary>
 public static ISocketMessageChannel GetMessageChannel(this BaseSocketClient client, ulong id)
 {
     return(client.GetChannel(id) as ISocketMessageChannel);
 }
Ejemplo n.º 6
0
 IMessageChannel GetKotmapChannel() => (IMessageChannel)_discord.GetChannel(_kotmapChannelId);
        public virtual ISocketChannelWrapper?GetChannel(ulong id)
        {
            var rawChannel = _baseSocketClient.GetChannel(id);

            return(rawChannel != null ? new SocketChannelWrapper(rawChannel) : null);
        }