Exemplo n.º 1
0
        protected void HandleTokenizedMessagesReceived(Twitch.Chat.ChatTokenizedMessage[] messages)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < messages.Length; ++i)
            {
                Twitch.Chat.ChatTokenizedMessage msg = messages[i];
                sb.Append(msg.DisplayName).Append(": ");

                for (int t = 0; t < msg.Tokens.Length; ++t)
                {
                    Twitch.Chat.ChatMessageToken token = msg.Tokens[t];
                    switch (token.Type)
                    {
                    case Twitch.Chat.TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_TEXT:
                    {
                        Twitch.Chat.ChatTextMessageToken mt = token as Twitch.Chat.ChatTextMessageToken;
                        sb.Append(mt.Message);
                        break;
                    }

                    case Twitch.Chat.TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_IMAGE:
                    {
                        Twitch.Chat.ChatImageMessageToken mt = token as Twitch.Chat.ChatImageMessageToken;
                        sb.Append("[emoticon]");
                        break;
                    }
                    }
                }
                sb.AppendLine();

                mChatMessagesTextbox.Text = mChatMessagesTextbox.Text + sb.ToString();
                sb.Clear();
            }
        }
Exemplo n.º 2
0
        protected void HandleTokenizedMessagesReceived(string channelName, Twitch.Chat.ChatTokenizedMessage[] messages)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < messages.Length; ++i)
            {
                Twitch.Chat.ChatTokenizedMessage msg = messages[i];
                sb.Append(msg.DisplayName).Append(": ");

                for (int t = 0; t < msg.Tokens.Length; ++t)
                {
                    Twitch.Chat.ChatMessageToken token = msg.Tokens[t];
                    switch (token.Type)
                    {
                    case Twitch.Chat.TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_TEXT:
                    {
                        Twitch.Chat.ChatTextMessageToken mt = token as Twitch.Chat.ChatTextMessageToken;
                        sb.Append(mt.Message);
                        break;
                    }

                    case Twitch.Chat.TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_TEXTURE_IMAGE:
                    {
                        Twitch.Chat.ChatTextureImageMessageToken mt = token as Twitch.Chat.ChatTextureImageMessageToken;
                        sb.Append(string.Format("[{0},{1},{2},{3},{4}]", mt.SheetIndex, mt.X1, mt.Y1, mt.X2, mt.Y2));
                        break;
                    }

                    case Twitch.Chat.TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_URL_IMAGE:
                    {
                        Twitch.Chat.ChatUrlImageMessageToken mt = token as Twitch.Chat.ChatUrlImageMessageToken;
                        sb.Append("[").Append(mt.Url).Append("]");
                        break;
                    }
                    }
                }
                sb.AppendLine();

                mChatMessagesTextbox.Text = mChatMessagesTextbox.Text + sb.ToString();
                sb.Clear();
            }
        }