Esempio n. 1
0
        public void TestMessageParsing(MessageTest data)
        {
            var message = IRCMessage.Parse(data.Input);
            var atoms   = data.Atoms;

            Assert.Equal(atoms.Source ?? "", message.Source);
            Assert.Equal(atoms.Verb.ToUpperInvariant(), message.Verb);
            Assert.Equal(atoms.Params ?? (IEnumerable <string>)ImmutableArray <string> .Empty,
                         message.Parameters);
            Assert.Equal(atoms.Tags, message.Tags, new NullFriendlyDictionaryComparer());
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            //while (true)
            {
                var raw     = "@badge-info=;badges=global_mod/1,turbo/1;color=#0D4200;display-name=dallas;emotes=25:0-4,12-16/1902:6-10;id=b34ccfc7-4977-403a-8a94-33c6bac34fb8;mod=0;room-id=1337;subscriber=0;tmi-sent-ts=1507246572675;turbo=1;user-id=1337;user-type=global_mod :[email protected] PRIVMSG #dallas :Kappa Keepo Kappa";
                var message = new IRCMessage();
                message.Parse(raw);

                PrintReflection(message);
            }
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            var user          = new UserConsole();
            var authUser      = args.Length > 0 ? new UserFile(args[0]) : (UserAbstract)user;
            var clientId      = authUser.ReadInput("Client-Id");
            var redirectURI   = authUser.ReadInput("Redirect-URI");
            var nickName      = authUser.ReadInput("Nickname").ToLowerInvariant();
            var authorization = Auth(clientId, redirectURI);

            using (var client = new TwitchChatClient())
            {
                client.Type     = ProtocolType.WebSocket;
                client.Security = ProtocolSecurity.Default;
                client.OAuth    = authorization.AccessToken;
                client.Nick     = nickName;
                client.Capabilities.Add(KnownCapabilities.Commands);
                client.Capabilities.Add(KnownCapabilities.Membership);
                client.Capabilities.Add(KnownCapabilities.Tags);
                client.Connect();

                new Thread(() =>
                {
                    while (true)
                    {
                        var input   = user.ReadInput();
                        var message = new IRCMessage();
                        message.Parse(input);

                        client.Send(message);
                    }
                }).Start();

                var program = new Program(user, client);
                program.Run();
            }
        }