public static void WriteInfo(ConversationInfo info) { string infoPath = info.InfoPath; string infoStr = JsonConvert.SerializeObject(info); File.WriteAllText(infoPath, infoStr); }
public static IMessageActivity Welcome(ConversationInfo info, string memberName) { var heroCard = NewHeroCard(); string messageText = $"Hi {memberName}, I'm Ringo! 👋 To get started, open Spotify and start playing music. Then click / tap / type \"Play\"."; heroCard.Buttons.Add( new CardAction { Title = "Spotify is Playing! Play", Value = "play", Type = ActionTypes.ImBack, }); // TODO: Uncomment when feature enabled to choose station on `join` //if (info.IsGroup) //{ // messageText += " Or click/tap \"Join\" to join in with others!"; // heroCard.Buttons.Add( // new CardAction // { // Title = "Join", // Value = "join", // Type = ActionTypes.ImBack, // }); //} messageText += " Also, you can type \"`help`\" at any time for help."; return(MessageAttachment(heroCard, messageText)); }
public static ConversationInfo ReadInfo(string path) { string info = File.ReadAllText(path); ConversationInfo conversationInfo = (ConversationInfo)JsonConvert.DeserializeObject(info); return(conversationInfo); }
public mst_bot_response AskEducationEngine() { var jsonString = Request.Content.ReadAsStringAsync().Result; var botRequest = JsonConvert.DeserializeObject <mst_bot_request>(jsonString); dynamic q = botRequest.data["query"]; dynamic u = botRequest.data["userid"]; string question = q.text; string userId = u.text; log.Info("userid: " + userId + "; query: " + question); ConversationInfo resp = dm.Answer(userId, question); oaskills_textanswer answer = new oaskills_textanswer(); answer.answer = resp.answer; //answer.userid = userId; //answer.query = question; answer.contextinfo = ""; if (resp.context != null) { answer.contextinfo = JsonConvert.SerializeObject(resp.context);//resp.context.ToString(); } var map = new mst_map(); map.Add("answer", answer); return(new mst_bot_response() { result = map }); }
//取消呼叫 private void CanCall() { //发送视频呼叫回复指令,dwErrcode=100101 AnyChatCoreSDK.VideoCallControl(AnyChatCoreSDK.BRAC_VIDEOCALL_EVENT_REPLY, ConversationMode.TuserId, AC_ERROR_VIDEOCALL_CANCEL, 0, 0, ""); ConversationMode = null; InitFaceAfterEndCall(Properties.Resources._20, "已经取消呼叫"); }
public async void sendProactiveMessage(ConversationInfo conversation, String messageText) { // Use the data stored previously to create the required objects. var userAccount = new ChannelAccount(conversation.ToId, conversation.ToName); var botAccount = new ChannelAccount(conversation.FromId, conversation.FromName); var connector = new ConnectorClient(new Uri(conversation.ServiceUrl)); // Create a new message. IMessageActivity message = Activity.CreateMessageActivity(); if (!string.IsNullOrEmpty(conversation.ConversationId) && !string.IsNullOrEmpty(conversation.ChannelId)) { // If conversation ID and channel ID was stored previously, use it. message.ChannelId = conversation.ChannelId; } else { // Conversation ID was not stored previously, so create a conversation. // Note: If the user has an existing conversation in a channel, this will likely create a new conversation window. conversation.ConversationId = (await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount)).Id; } // Set the address-related properties in the message and send the message. message.From = botAccount; message.Recipient = userAccount; message.Conversation = new ConversationAccount(id: conversation.ConversationId); message.Text = messageText; message.Locale = "en-us"; await connector.Conversations.SendToConversationAsync((Activity)message); }
// 拒绝视频呼叫邀请 void btn_refuse_Click(object sender, EventArgs e) { //发送视频呼叫回复指令,dwErrcode=100104 AnyChatCoreSDK.VideoCallControl(AnyChatCoreSDK.BRAC_VIDEOCALL_EVENT_REPLY, ConversationMode.SuserId, AC_ERROR_VIDEOCALL_REJECT, 0, 0, ""); ConversationMode = null; InitFaceAfterEndCall(Properties.Resources._5, "已经拒绝会话..."); }
public void EncodeId_UpperCaseChannelId_EncodedSameAsLowerCaseChannelId() { // arrange const string userId = "27:abc1234XYZ"; var lower = new ConversationInfo { ChannelId = "msteams", ChannelTeamId = "abc123" }; var upper = new ConversationInfo { ChannelId = "MSTEAMS", ChannelTeamId = "abc123" }; var expected = User.EncodeIds(lower, userId); // act var actual = User.EncodeIds(upper, userId); // assert Assert.AreEqual(expected, actual); }
public static IMessageActivity NowPlayingStation(ConversationInfo info, Station station) { var heroCard = NewHeroCard(); var images = station.Album?.Images ?? station.Playlist?.Images; if (images != null && images.Any()) { heroCard.Images.Add( new CardImage { Url = images[0].Url, Alt = station.Name }); } string messageText = info.IsGroup ? $"@{info.FromName} is now playing \"{station.Name}\" {station.HashtagHandle} 📢" : $"Now playing \"{station.Name}\". Friends can type `\"join @{RingoBotHelper.ToHashtag(info.FromName)}\"` to join in! 🎉"; if (info.IsGroup) { heroCard.Buttons.Add( new CardAction { Title = $"Join {station.HashtagHandle}", Value = $"join {station.HashtagHandle}", Type = ActionTypes.ImBack, }); } return(MessageAttachment(heroCard, messageText)); }
private void OnPeerAcceptFromServerEventHandler(ConversationInfo info, BaseSocket clientSock) { Console.WriteLine("server accepted"); ChatViewModel chatViewModel = new ChatViewModel(new ChatNetworkService(clientSock, info)); chatViewModel.OnPeerDisconnectedEvent += OnPeerDisconnectedEventHandler; CurrentPageViewModel = chatViewModel; }
public async Task <Station> GetChannelStation(ConversationInfo info, string conversationName = null) { if (!info.IsGroup && string.IsNullOrEmpty(conversationName)) { throw new ArgumentException("Must provide conversationName if not in group chat", nameof(conversationName)); } return(await _stationData.GetStation(Station.EncodeIds(info, RingoBotHelper.ToHashtag(conversationName)))); }
public static string WriteImage(ImageDataMessage image, ConversationInfo info) { string imagePath = info.ImagePath; string fullpath = imagePath + image.extension; Console.WriteLine(fullpath); File.WriteAllBytes(fullpath, image.ImageBytes()); return(fullpath); }
private void AddNewConversationInfo(ConversationInfo info) { var serializableInfo = JsonConvert.SerializeObject(info); if (!_conversationInfoSerializableList.Contains(serializableInfo)) { _conversationInfoSerializableList.Add(serializableInfo); } }
private void OnPeerAcceptFromClientEventHandler(ConversationInfo info, BaseSocket serverSock) { ChatViewModel chatViewModel = new ChatViewModel(new ChatNetworkService(serverSock, info)); //NetworkChatViewModel chatViewModel = new NetworkChatViewModel(syncServerSocket, username); chatViewModel.OnPeerDisconnectedEvent += OnPeerDisconnectedEventHandler; CurrentPageViewModel = chatViewModel; Console.WriteLine("client accepted"); }
private void Awake() { if (instance != null) { Destroy(this.gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } interviewArray = Resources.LoadAll <InterviewData>("InterviewObjects"); transcriptionSpreadsheet = Resources.Load <TextAsset>("TranscriptionInformation"); TranscriptionDataDictionary = new Dictionary <string, ConversationInfo>(); string[] rowEntries = transcriptionSpreadsheet.text.Split('\n'); foreach (string row in rowEntries) { string[] rowCells = row.Split('\t'); int cellCount = 0; for (int i = 1; i < rowCells.Length; i++) { if (rowCells[i].Trim() != "") { cellCount++; } } Chunk[] chunkClassArray = new Chunk[cellCount]; for (int i = 0; i < cellCount; i++) { Chunk thisChunk = new Chunk(); string[] cellContents = rowCells[i + 1].Split('|'); // call the function that return a specific enum value based on switch statement thisChunk.Speaker = getSpeakerNameFromString(cellContents[0]); //check if something went wrong and the name did not get assigned Debug.Assert(thisChunk.Speaker != Chunk.speakerName.none); //parse the timestamp from the spreadsheet and make it a float float myTimestamp; bool successfulParse = float.TryParse(cellContents[1], out myTimestamp); //this will only log an error if it returns false Debug.Assert(successfulParse); thisChunk.speakerTimestamp = myTimestamp; //assign the actual text to be printed as transcription thisChunk.speakerText = cellContents[2]; chunkClassArray[i] = thisChunk; } ConversationInfo thisConversationInfo = new ConversationInfo(); thisConversationInfo.chunks = chunkClassArray; string conversationName = rowCells[0].Trim().ToLower(); thisConversationInfo.interviewData = getCorrectInterviewData(conversationName); TranscriptionDataDictionary.Add(conversationName, thisConversationInfo); } }
private async Task SaveConversationInfoAsync(Conversation conversation, string userkey, string watermark, DateTimeOffset timeout) { conversationinfo = new ConversationInfo { coversation = conversation, id = userkey, timestamp = timeout, watermark = watermark }; await sessionService.SetInfoAsync(conversationinfo); }
public static List <Message> ReadMessages(ConversationInfo info) { string messages = File.ReadAllText(info.MessagesPath); List <Message> msgs = (List <Message>)JsonConvert.DeserializeObject(messages, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); return(msgs); }
public ChatNetworkService(BaseSocket socket, ConversationInfo info) : base(info) // string username { this.socket = socket; socket.OnMessageRecieved += OnMessageRecievedHandler; socket.OnSocketDisconnect += OnDisconnectHandler; socket.OnMessageParseException += OnMessageParseExceptionHandler; //socket.OnSocketDisconnect += () => //{ // OnServiceDisconnect?.Invoke(); //}; }
public static void WriteMessages(List <Message> messages, ConversationInfo info) { // Directory.CreateDirectory(fullpath); string messagesText = JsonConvert.SerializeObject(messages, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); Console.WriteLine(info.MessagesPath); File.WriteAllText(info.MessagesPath, messagesText); }
//视频呼叫回复 private void VideoCall_Reply_Handler(int userId, int dwErrorCode, int wParam, string lpStr) { if (this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } RemoveCallButton(); intCallTimer = 3; ShowCallMessage(Properties.Resources._18, "会话已结束..."); ConversationMode = null; switch (dwErrorCode) { case 0: ConversationMode = new ConversationInfo(); ConversationMode.SuserId = m_UserId; ConversationMode.TuserId = userId; VideoCall_WaitCall_Handler(); break; case AC_ERROR_VIDEOCALL_CANCEL: ShowCallMessage(Properties.Resources._20, "对方取消呼叫..."); break; case AC_ERROR_VIDEOCALL_REJECT: ShowCallMessage(Properties.Resources._5, "对方拒绝会话..."); break; case AC_ERROR_VIDEOCALL_BUSY: ShowCallMessage(Properties.Resources._8, "目标用户正忙,请稍后重试..."); break; case AC_ERROR_VIDEOCALL_OFFLINE: ShowCallMessage(Properties.Resources._18, "对方已离线..."); break; case AC_ERROR_VIDEOCALL_TIMEOUT: ShowCallMessage(Properties.Resources._1, "会话请求已超时..."); break; case AC_ERROR_VIDEOCALL_DISCONNECT: ShowCallMessage(Properties.Resources._18, "对方网络断开..."); break; } if (dwErrorCode != 0) { timer_call.Start(); } Log.SetLog("VideoCall_Reply_Handler" + dwErrorCode); }
public ConversationInfoItem(ConversationInfo conversationInfo) { SerialID = conversationInfo.SerialID; RecordReference = conversationInfo.RecordReference; StartRecordTime = conversationInfo.StartRecordTime; Offset = conversationInfo.Offset; Extension = conversationInfo.Extension; Direction = conversationInfo.Direction; RowNumber = conversationInfo.RowNumber; Content = conversationInfo.Content; EndRecordTime = conversationInfo.EndRecordTime; //结束位置的偏移量 = 开始位置偏移量+该条句子的录音长度 EndOffset = Offset + Convert.ToInt64((EndRecordTime - StartRecordTime).TotalMilliseconds); StrOffset = Converter.MilliSecond2Time(conversationInfo.Offset); }
public async Task SetInfoAsync(ConversationInfo info) { var items = await DocumentDBRepository <ConversationInfo> .GetItemsAsync(d => d.id == info.id); var item = items.FirstOrDefault(); if (item == null) { await DocumentDBRepository <ConversationInfo> .CreateItemAsync(info); } else { await DocumentDBRepository <ConversationInfo> .UpdateItemAsync(info.id, info); } }
public static ConversationInfo NormalizedConversationInfo(ITurnContext turnContext) { var activity = turnContext.Activity; var info = new ConversationInfo { ChannelId = activity.ChannelId.ToLower(), ChannelTeamId = null, FromId = activity.From.Id, FromName = activity.From.Name, RecipientId = activity.Recipient.Id, RecipientName = activity.Recipient.Name, ConversationId = activity.Conversation?.Id, ConversationName = activity.Conversation?.Name, IsGroup = activity.Conversation?.IsGroup ?? false }; // channel specific overrides switch (info.ChannelId) { case ChannelIdSlack: string[] ids = activity.Conversation.Id.Split(':'); if (ids.Length < 2) { throw new InvalidOperationException("Expecting Conversation Id like BBBBBBBBB:TTTTTTTTTT:CCCCCCCCCC"); } // ChannelTeamId info.ChannelTeamId = ids[1]; // ConversationId if (ids.Length > 2) { info.ConversationId = ids[2]; } break; case ChannelIdTeams: dynamic teamsChannelData = activity.ChannelData; info.ChannelTeamId = teamsChannelData.tenant?.id; break; } return(info); }
public static IMessageActivity NotPlayingAnything(ConversationInfo info) { var heroCard = NewHeroCard(); heroCard.Buttons.Add( new CardAction { Title = "Spotify is playing - Try again!", Value = $"{RingoBotHelper.RingoHandleIfGroupChat(info)}play", Type = ActionTypes.ImBack, }); return(MessageAttachment( heroCard, "You are not currently playing anything 🤔 Play some music in Spotify and try again.")); }
public static IMessageActivity AuthHasBeenReset(ConversationInfo info) { var heroCard = NewHeroCard(); heroCard.Buttons.Add( new CardAction { Title = "Authorize", Value = "auth", Type = ActionTypes.ImBack, }); return(MessageAttachment( heroCard, "Spotify authorization has been reset. You can type `\"auth\"` at any time to authorize Spotify again.")); }
public static IMessageActivity SpotifyError(ConversationInfo info, SpotifyApiErrorException ex, string command) { var heroCard = NewHeroCard(); heroCard.Buttons.Add( new CardAction { Title = $"Try again", Value = $"{RingoBotHelper.RingoHandleIfGroupChat(info)}{command}", Type = ActionTypes.ImBack, }); return(MessageAttachment( heroCard, $"Ringo can't talk to Spotify right now 🤔 Please try again in a minute. Spotify says: \"{ex.Message}\"")); }
public static IMessageActivity NowPlayingNoContext(ConversationInfo info) { var heroCard = NewHeroCard(); heroCard.Buttons.Add( new CardAction { Title = "Try again!", Value = $"{RingoBotHelper.RingoHandleIfGroupChat(info)}play", Type = ActionTypes.ImBack, }); return(MessageAttachment( heroCard, "Unfortunately Ringo does not support playing single Tracks or endless Playlists (including Daily Mixes) 😢 Play a Playlist or an Album in Spotify and try again.")); }
public override long SaveConversation(ConversationInfo conversation, IDbTransaction transaction) { var sqlParam = new DynamicParameters(); sqlParam.Add("@BookingID", conversation.BookingID); sqlParam.Add("@IsCustomerQuery", conversation.IsCustomerQuery); sqlParam.Add("@Resolved", conversation.Resolved); sqlParam.Add("@UpdatedBy", conversation.UpdatedBy); sqlParam.Add("@Text", conversation.Text); sqlParam.Add("@IdentityReturn", dbType: DbType.Int64, direction: ParameterDirection.Output); transaction.Connection.Execute("[dbo].[ConversationInsert]", sqlParam, transaction, null, CommandType.StoredProcedure); return(sqlParam.Get <long>("IdentityReturn")); }
public static IMessageActivity StationNoLongerPlaying(ConversationInfo info, Station station) { var heroCard = NewHeroCard(); string uri = station.Album?.Uri ?? station.Playlist?.Uri; heroCard.Buttons.Add( new CardAction { Title = $"Play {station.Name}", Value = $"{RingoBotHelper.RingoHandleIfGroupChat(info)}play {uri}", Type = ActionTypes.ImBack, }); return(MessageAttachment( heroCard, $"{station.HashtagHandle} is no longer playing. Would you like to play \"{station.Name}\"?")); }
private static string TeamChannelPart(ConversationInfo info) { if (info == null) { throw new ArgumentNullException(nameof(info)); } if (string.IsNullOrEmpty(info.ChannelId)) { throw new ArgumentNullException(nameof(info.ChannelId)); } string teamChannel = CryptoHelper.Base62Encode(info.ChannelId); if (!string.IsNullOrEmpty(info.ChannelTeamId)) { teamChannel += $"/{CryptoHelper.Base62Encode(info.ChannelTeamId)}"; } return(teamChannel); }