Пример #1
0
			public virtual bool Parse (SSvChatMessage chat_msg, string[] texts, out ChatTagData[] tag_data)
			{
				tag_data = null;
				
				if (IsElemCountOk (texts)) {
					
					if(msgs == null) msgs = GetMessages();
					
					tag_data = new ChatTagData[msgs.Length];
					
					int txt_index = 1;
					for(int i=0; i<tag_data.Length; i++)
					{
						tag_data[i] = new ChatTagData();
						
						string msg = msgs[i];
					
						if(ContainsFormtaTag(msg)) {
							GetParseTag(txt_index)(chat_msg, texts[txt_index], ref tag_data[i]);
							txt_index++;
						} else {
							tag_data[i].message = msg;
							
						}
					}
					return true;
				}
				return false;
			}
Пример #2
0
	static public ChatTagData[] Parse(string message)
	{
		if(!is_inied)
			Initialize ();

		parse_data.Clear ();
		tag_work.Clear ();

		MatchCollection match_collection = regex.Matches(message);
		foreach (Match match in match_collection) 
		{
			string tag = match.Groups["tag"].Value;
			tag_work.Enqueue(_Parse(tag));
			message = message.Replace(match.Value, ",${tag}$,");
		}

		string[] split = message.Split(',');

		foreach (string text in split) {

			if(string.IsNullOrEmpty(text)) continue;

			if(text.StartsWith("${"))
			{
				parse_data.Add(tag_work.Dequeue());
			}
			else {
				ChatTagData data = new ChatTagData ();
				data.tag_type = ChatTagType.Normal;
				data.message = text;
				parse_data.Add(data);
			}
		}
		return parse_data.ToArray();
	}
Пример #3
0
			protected static void ParseUserTag(SSvChatMessage chat_msg, string text, ref ChatTagData tag_data)
			{
				tag_data.tag_type = ChatTagType.User;
				tag_data.id = chat_msg.user_id;
				tag_data.message = "USER_" + chat_msg.user_id;
			}
Пример #4
0
			static void ParseQuestTag(SSvChatMessage chat_msg, string text, ref ChatTagData tag_data)
			{
				tag_data.tag_type = ChatTagType.Quest;
				tag_data.id = int.Parse (text);
				tag_data.message = text;
			}
Пример #5
0
	static ChatTagData _Parse(string tag)
	{
		ChatTagData data = new ChatTagData ();

		string[] split = tag.Split(':');
		if (split [0] == "u") {
			data.tag_type = ChatTagType.Friend;
			data.id = int.Parse(split[1]);
			data.message = split[2];
		} 
		else if(split[0] == "h" )
		{
			data.tag_type = ChatTagType.Friend;
			data.id = int.Parse(split[1]);
			data.message = "Valter";
		}
		return data;
	}
Пример #6
0
	static public void Build(ChatTagData tag_datas)
	{
	}