Beispiel #1
0
        private void Client_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            var ircMessage = new IrcMessage(e.Message);

            switch (ircMessage.Command)
            {
            case "001":
                OnLoggedIn();
                break;

            case "JOIN":
            {
                string userName = ircMessage.GetUserName();
                string channel  = ircMessage.GetChannel();

                if (UserName.Equals(userName))
                {
                    OnChannelJoined(channel);
                }
                else
                {
                    OnUserJoined(userName, channel);
                }
                break;
            }

            case "PART":
            {
                string userName = ircMessage.GetUserName();
                string channel  = ircMessage.GetChannel();

                if (UserName.Equals(userName))
                {
                    OnChannelParted(channel);
                }
                else
                {
                    OnUserParted(userName, channel);
                }
                break;
            }

            case "PING":
                string serverAddress = ircMessage.GetParameterByIndex(0);
                OnPingReceived(serverAddress);
                break;

            case "MODE":
                var channelMode = new ChannelMode(ircMessage);
                OnChannelModeReceived(channelMode);
                break;

            default:
                OnUnprocessedIrcMessageReceived(ircMessage);
                break;
            }
            OnIrcMessageReceived(ircMessage);
        }
Beispiel #2
0
        public TwitchChannelHost(IrcMessage message)
        {
            HostingChannel = message.GetChannel();

            string[] parameters = message.GetParameterByIndex(1).Split(' ');
            if (!parameters[0].Equals("-"))
            {
                TargetChannel = $"#{parameters[0]}";
            }
            if (int.TryParse(parameters[1], out int numberOfViewers))
            {
                NumberOfViewers = numberOfViewers;
            }
        }
Beispiel #3
0
        public TwitchHostedChannel(IrcMessage message)
        {
            string channel = message.GetChannel();

            TargetChannel = $"#{channel}";

            string jtvMessage = message.GetParameterByIndex(1);

            IsAutohost = jtvMessage.Contains("auto hosting");

            string[] parameters = jtvMessage.Split(' ');
            if (int.TryParse(parameters[parameters.Length - 1], out int numberOfViewers))
            {
                NumberOfViewers = numberOfViewers;
            }
            HosterDisplayName = parameters[0];
        }