Пример #1
0
        public static void ROOMSTATE(RawMessage rawMessage)
        {
            RoomState roomState = TwitchConnection.RoomStates.ContainsKey(rawMessage.ChannelName) ?
                                  TwitchConnection.RoomStates[rawMessage.ChannelName] :
                                  new RoomState(rawMessage.ChannelName);

            var tags = Parsers.ParseTags(rawMessage.Message);

            roomState.ID = tags["room-id"];

            string lang = tags.GetValue("broadcaster-lang");

            if (lang != null)
            {
                roomState.Language = lang;
            }

            string emoteOnly = tags.GetValue("emote-only");

            if (emoteOnly != null)
            {
                roomState.EmoteOnly = emoteOnly == "1";
            }

            string subsOnly = tags.GetValue("subs-only");

            if (subsOnly != null)
            {
                roomState.SubsOnly = subsOnly == "1";
            }

            string followersOnly = tags.GetValue("followers-only");

            if (followersOnly != null)
            {
                roomState.FollowersOnly = Convert.ToInt32(followersOnly);
            }

            string slowMode = tags.GetValue("slow");

            if (slowMode != null)
            {
                roomState.SlowMode = Convert.ToUInt16(slowMode);
            }

            string r9k = tags.GetValue("r9k");

            if (r9k != null)
            {
                roomState.R9K = r9k == "1";
            }

            TwitchConnection.RoomStates[rawMessage.ChannelName] = roomState;
            TwitchConnection.OnRoomStateChange?.Invoke(TwitchConnection.Instance, roomState);
        }
Пример #2
0
 private void OnRoomStateChangedTask(TwitchConnection obj, RoomState roomstate)
 {
     foreach (KeyValuePair <string, RegisteredPlugin> kvp in RegisteredPlugins)
     {
         try
         {
             kvp.Value.OnRoomStateChanged(obj, roomstate);
         }
         catch (Exception e)
         {
             Console.WriteLine($"An exception occured while trying to call OnRoomStateChanged for plugin {kvp.Key} (Exception: {e.ToString()})");
         }
     }
 }
Пример #3
0
        public void JoinRoom(string channel)
        {
            if (channel != String.Empty)
            {
                channel = channel.ToLower();
            }
            if (RoomStates.ContainsKey(channel))
            {
                return;
            }

            RoomState newRoomState = new RoomState();

            RoomStates[channel] = newRoomState;
            SendRawMessage("JOIN #" + channel);

            Task.Run(() => OnChannelJoinedTask(channel));
        }
Пример #4
0
 public void OnRoomStateChanged(TwitchConnection obj, RoomState roomstate)
 {
     _onRoomStateChanged?.Invoke(obj, roomstate);
 }