コード例 #1
0
        private TwitchChannel JoinChannel(TwitchConnection twitch, string name)
        {
            var channel = twitch.Create(name);

            channel.ModeratorJoined += ModJoined;
            channel.UserChatCleared += UserClearChatHandler;
            channel.MessageReceived += ChatMessageReceived;
            channel.MessageSent += ChatMessageReceived;
            channel.StatusMessageReceived += JtvMessageReceived;
            channel.ActionReceived += ChatActionReceived;
            channel.UserSubscribed += SubscribeHandler;
            channel.ChatCleared += ChatCleared;
            channel.SlowModeBegin += SlowModeHandler;
            channel.SlowModeEnd += SlowModeEndHandler;
            channel.SubModeBegin += SubModeBeginHandler;
            channel.SubModeEnd += SubModeEndHandler;
            channel.ModListReceived += ModListReceived;
            
            return channel;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: carriercomm/TwitchLib
        static async Task<TwitchChannel[]> ConnectAsync(params string[] channelNames)
        {
            TwitchConnection twitch = new TwitchConnection();

            string[] loginData = File.ReadLines("login.txt").Take(2).ToArray();

            var connectResult = await twitch.ConnectAsync(loginData[0], loginData[1]);
            if (connectResult != ConnectResult.Connected)
            {
                Console.WriteLine("Failed to login.");
                return null;
            }

            //TwitchChannel result = Create(channel);
            //await result.JoinAsync();
            //return result;



            TwitchChannel[] channels = (from channelName in channelNames select twitch.Create(channelName)).ToArray();
            Task[] channelTasks = (from channel in channels select channel.JoinAsync()).ToArray();

            var result = new TwitchChannel[channelTasks.Length];

            for (int i = 0; i < result.Length; ++i)
                await channelTasks[i];

            return channels;
        }