internal void SendChatMsg(GuiChatLobby cl, string inMsg = "") { string text = (inMsg == "") ? _b.GUI.tb_chatMsg.Text : inMsg; ChatId id = new ChatId(); if (cl.ID == BROADCAST) { id.chat_id = ""; id.chat_type = ChatType.TYPE_GROUP; } else { id.chat_id = cl.ID; id.chat_type = ChatType.TYPE_LOBBY; } ChatMessage msg = new ChatMessage(); msg.id = id; msg.msg = text; msg.peer_nickname = _nick; msg.send_time = (uint)DateTime.Now.Second; _b.RPC.ChatSendMsg(msg); if (cl.ID != BROADCAST) // needed ?! AddMsgToLobby(cl.ID, DateTime.Now.ToLongTimeString() + " - " + _nick + " > " + text + "\n"); if (inMsg == "") _b.GUI.tb_chatMsg.Clear(); }
private void AutoAnswer(ChatMessage response, GuiChatLobby cl) { string[] msgOUT = _b.AutoResponse.Process(response, cl); if (msgOUT != null) foreach (string s in msgOUT) if (s != "") SendChatMsg(cl, s); }
internal void AddMsgToLobby(string ID, ChatMessage response) { System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: PrintMsgToLobby ID: " + response.id); if (!_chatLobbies.ContainsKey(ID)) { // we don't know this lobby :S System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: ID (" + response.id + ") is unknown"); return; } GuiChatLobby cl = _chatLobbies[ID]; string msg = Processor.RemoteTags(response.msg); System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: lobby: " + cl.Lobby.lobby_name); System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: msg: " + msg + " from " + response.peer_nickname); System.Diagnostics.Debug.WriteLineIf(DEBUG, "Chat: rec: " + response.recv_time + " send: " + response.send_time); // add "*time* - *nick* > *msg*" cl.ChatText += Processor.conv_Timestamp2Date(response.send_time).ToLocalTime().ToLongTimeString() + " - " + response.peer_nickname + " > " + msg + "\n"; _chatLobbies[ID] = cl; if (_b.GUI.clb_chatLobbies.SelectedIndex == cl.Index) //SetChatText(ID); _reDrawChat = true; else { if (!cl.Unread) { cl.Unread = true; _b.GUI.clb_chatLobbies.SetItemCheckState(cl.Index, CheckState.Indeterminate); _chatLobbies[ID] = cl; } } //AutoAnswer(Processor.RemoteTags(response.msg.msg)); AutoAnswer(response, cl); }