public ChatForm(string[] args) { InitializeComponent(); this.versionCmbBx.DataSource = Enum.GetValues(typeof (RoomVersion)); this._chatClient = new ChatClient(args, this.outputTxtBx, this.messageToolStripSatusLbl); this._chatStatus = ChatStatus.Disconnected; }
public void SimpeTest(string message, ChatStatus expected) { var databse = new MockDataBase(); var botLogic = new BotLogic(databse); var userRequest = telegramHandler.ParseUserMessageText(telegramUser, message); botLogic.Execute(userRequest); Assert.AreEqual(expected, databse.Users[telegramUser.Id].ChatStatus); }
public async Task <bool> UpdateChatStatus(int id, ChatStatus chatStatus) { var chat = await FindChat(id); chat.chatStatus = chatStatus; _db.Entry(chat).State = EntityState.Modified; int retValue = await _db.SaveChangesAsync(); if (retValue > 0) { return(true); } return(false); }
public static String GetChatStatusText(this ChatStatus status) { switch (status) { case ChatStatus.Sent: return(AppResources.ChatStatusSent); case ChatStatus.Delivered: return(AppResources.ChatStatusDelivered); case ChatStatus.Received: return(AppResources.ChatStatusReceived); case ChatStatus.Error: default: return(AppResources.ChatStatusError); } }
/// <summary> /// 开始新的会话 /// </summary> /// <param name="status"></param> /// <param name="userinfoDic">记录用户信息,key为信息名称,value为信息具体内容 eg:eg:手机号:13600000000;微信号:wechatnumber</param> /// <returns></returns> public static ChatLog AddNewLog(string openid, ChatStatus status, Dictionary <string, string> userinfoDic) { var cl = new ChatLog { StartDate = DateTime.Now, Status = status, HasReaded = status == ChatStatus.Chatting ? true : false, UserInfoDic = userinfoDic, Openid = openid, }; var db = new ModelContext(); db.ChatLogSet.Add(cl); db.SaveChanges(); return(cl); }
private void JoinToRoom() { if (string.IsNullOrEmpty(this.nickTxtBx.Text)) { MessageBox.Show(Resources.ChatForm_joinLeaveBtn_Click_Nick_cannot_be_empty, Resources.ChatForm_Chatroom); return; } if (string.IsNullOrEmpty(this.topicTxtBx.Text)) { MessageBox.Show(Resources.ChatForm_joinLeaveBtn_Click_Topic_cannot_be_empty, Resources.ChatForm_Chatroom); return; } try { this._chatClient.Join(this.nickTxtBx.Text, this.topicTxtBx.Text, this.versionCmbBx.Text.ConvertTo<RoomVersion>()); } catch (IChatException chatException) { MessageBox.Show(chatException.Reason, Resources.ChatForm_Chat_Exception); } catch (Ice.Exception exception) { MessageBox.Show(exception.Message, Resources.ChatForm_Chat_Exception); return; } this.joinLeaveBtn.Text = Resources.ChatForm_joinLeaveBtn_Click_Leave; this._chatStatus = ChatStatus.Connected; this.toolStripStatusLbl.Text = ChatStatus.Connected.ToString(); this.nickTxtBx.Enabled = false; this.topicTxtBx.Enabled = false; this.messageTxtBx.Enabled = true; this.sendBtn.Enabled = true; switch (this.versionCmbBx.Text.ConvertTo<RoomVersion>()) { case RoomVersion.V1: this.EnableRoomAdmToolbar(); break; default: this.DisableRoomAdmToolbar(); break; } }
private void LeaveRoom() { try { this._chatClient.Leave(); } catch (IllegalChatSessionException illegalChatSessionException) { MessageBox.Show( string.Concat("Reason: ", illegalChatSessionException.Reason, Environment.NewLine, "SessionId: ", illegalChatSessionException.SessionId), Resources.ChatForm_Chat_Exception); } catch (Ice.Exception exception) { MessageBox.Show(exception.Message, Resources.ChatForm_Chat_Exception); } this.joinLeaveBtn.Text = Resources.ChatForm_LeaveRoom_Join; this._chatStatus = ChatStatus.Disconnected; this.toolStripStatusLbl.Text = ChatStatus.Disconnected.ToString(); this.nickTxtBx.Enabled = true; this.topicTxtBx.Enabled = true; this.messageTxtBx.Text = string.Empty; this.messageTxtBx.Enabled = false; this.sendBtn.Enabled = false; this.DisableRoomAdmToolbar(); }
public LeagueStatus(string message, ChatStatus ingame) { Message = message; GameStatus = ingame; }
/// <summary> /// Handler for when the user has chosen a menu entry. /// </summary> protected virtual void OnSelectEntry(int entryIndex) { if (chat.affectedStates != null) StateManager.Instance.ModifyStates(chat.affectedStates); if (answers == null || answers.Count == 0) { this.ExitScreen(); return; } switch (status) { case ChatStatus.NpcText: if (nextLine < chat.text.Count) { currentText = chat.text[nextLine++]; break; } if (answers.Count == 1) { status = ChatStatus.PlayerText; InitializeChat(answers[0]); } else status = ChatStatus.PlayerAnswer; break; case ChatStatus.PlayerText: if (nextLine < chat.text.Count) { currentText = chat.text[nextLine++]; return; } status = ChatStatus.NpcText; InitializeChat(answers[0]); break; case ChatStatus.PlayerAnswer: status = ChatStatus.NpcText; List<Chat> nextAnswers = new List<Chat>(); if (answers[entryIndex] != null) { FilterAnswers(answers[entryIndex], nextAnswers); if (nextAnswers.Count > 0) InitializeChat(nextAnswers[0]); else this.ExitScreen(); } break; default: this.ExitScreen(); break; } }