public Chat ConvertToChat() { string RawMessage = ""; string Message = ""; string Name = ""; string UID = ""; string type = ""; DateTime Date = new DateTime(); string pattern = "(\\(\\d+\\)\\s<[\\s\\S]+>)"; if (Regex.IsMatch(args[0], pattern)) { UID = ((args[0].Substring(0, args[0].IndexOf(')'))).Replace("(", "").Replace(")", "").Replace("[", "")).Replace(" ", ""); Name = (args[0].Substring(args[0].IndexOf('<') + 1, args[0].IndexOf('>') - (args[0].IndexOf('<') + 1))); RawMessage = args[0].Substring(args[0].IndexOf('>') + 2); if (args[0][0] == '[') { Message = args[0].Substring(args[0].IndexOf("]") + 2); string[] parts = RawMessage.Split(' '); if (parts[0] == "→" || parts[1] == "→") { if (parts[1] == "@mods" || parts[2] == "@mods") { type = "mods"; } else type = "pm"; } } else { Message = RawMessage; } if (type == "") { Date = DateTime.Parse(args[1].Replace("T", " ").Replace("Z", "")); Date += (DateTime.Now - DateTime.UtcNow); } else { Date = DateTime.Now; } Chat tmp = new Chat(); tmp.Message = Message; tmp.UID = UID; tmp.User = Name; tmp.Date = Date; tmp.RawMessage = RawMessage; tmp.Type = type; return tmp; } else { string stmp = args[0]; RawMessage = args[0]; stmp = stmp.Substring(1); UID = stmp.Substring(0, stmp.IndexOf(")")); stmp = stmp.Substring(stmp.IndexOf(")")+2); stmp = stmp.Substring(stmp.IndexOf("*")+2); name = stmp.Substring(0, stmp.IndexOf(" ")); stmp = stmp.Substring(stmp.IndexOf(" ") +1); Message = stmp; Date = DateTime.Now; Chat tmp = new Chat(); tmp.Message = Message; tmp.UID = UID; tmp.User = Name; tmp.Date = Date; tmp.RawMessage = RawMessage; tmp.Type = "me"; return tmp; } }
void JD_OnOldChat(Chat chat) { /*string AppendedMessages = chat.Date.ToShortTimeString() + " (" + chat.UID + ") "; if (chat.Type == "pm") { AppendedMessages += "<" + chat.User + "> -> "; if (chat.UID == JD.uid) { AppendedMessages += "PM"; } else { AppendedMessages += "ME"; } } else if (chat.Type == "me") { AppendedMessages += "* " + chat.User; } else if (chat.Type == "mod") { AppendedMessages += "<" + chat.User + "> -> <mods>"; } else { AppendedMessages += "<" + chat.User + ">"; } AppendedMessages += " " + chat.Message;*/ //AppendMessage(AppendedMessages); ch.OnChat(chat); }
public Chat ConvertToChat(string Date) { Chat tmp = new Chat(); tmp.Date = jdInstance.ToDateTime(Date); string[] msg = txt.Split(' '); tmp.Message = txt; tmp.UID = user; tmp.User = name; return tmp; }
void Instance_OnChat(Chat chat) { ReceivedChatMessage(chat.Date.ToShortTimeString() +" ("+chat.UID+") <"+chat.User+"> "+ chat.RawMessage); }