private void AssignConnectors(DialogueEntry entry, Conversation conversation, HashSet<string> alreadyConnected, HashSet<int> entriesVisited, int level) { // Sanity check to prevent infinite recursion: if (level > 10000) return; // Set non-connectors: foreach (Link link in entry.outgoingLinks) { if (link.originConversationID == link.destinationConversationID) { string destination = string.Format("{0}.{1}", link.destinationConversationID, link.destinationDialogueID); if (alreadyConnected.Contains(destination)) { link.isConnector = true; } else { link.isConnector = false; alreadyConnected.Add(destination); } } } // Then process each child: foreach (Link link in entry.outgoingLinks) { if (link.originConversationID == link.destinationConversationID) { if (!entriesVisited.Contains(link.destinationDialogueID)) { entriesVisited.Add(link.destinationDialogueID); var childEntry = conversation.GetDialogueEntry(link.destinationDialogueID); if (childEntry != null) { AssignConnectors(childEntry, conversation, alreadyConnected, entriesVisited, level + 1); } } } } }
public void BeginCinematic(Type CinematicType) { // Disable player input // Hide castle UI // Handle enum types switch(CinematicType) { case Type.HoarderConversation: // NOTE (zesty): For special types, always use index 0, the list is used for other types that have // a randomization feature Conv = GameData.Cinematics[CinematicType][0]; break; case Type.RandomExclamation: Conv = GameData.Cinematics[CinematicType][Random.Range(0, GameData.Cinematics[CinematicType].Count)]; break; } // TESTING //Conv = GameData.Cinematics[Type.RandomExclamation][3]; LetterDelay = Conv.LetterDelay; TimeToNextLetter = LetterDelay; SentenceIndex = 0; LetterIndex = 0; CurSentence = Conv.Sentences[SentenceIndex]; CurTextBox = GetTextBox(CurSentence.OwningTextBox); SetTextBoxVisible(CurTextBox, true); bSentenceComplete = false; if(Conv.PauseGame) App.inst.SpawnController.PauseEnemiesForCinematic(); }
// Testing Conversation class void testConversation () { Conversation conversation = new Conversation("Text/SampleDialogue"); Debug.Log(conversation.GetCurrentDialogue()); }
public WhisperWindow(Conversation conversation, Participant participant, SeriousBusinessCat seriousBusiness, string info) { this.conversation = conversation; this.participant = participant; this.seriousBusiness = seriousBusiness; InitializeComponent(); this.DataContext = this; InitCommands(); this.Activated += (s,e) => { FlashWindow.Stop(this); }; lbWhispers.ItemsSource = _whispers; string bob = "neighbor cat"; if (participant != null) { bob = participant.Contact.GetContactInformation(ContactInformationType.DisplayName).ToString(); } textBlock.Text = bob; if (!string.IsNullOrEmpty(info)) { textBlock.ToolTip = info; } this.Title = $"Whispering with {bob}"; FocusManager.SetFocusedElement(this, tbMessage); }
private IEnumerator RunConversationCoroutine(Conversation conversation) { IsInProgress = true; Coroutine alignCoroutine = conversation.alignCharacters ? StartCoroutine(AlignCharactersCoroutine()) : null; if (conversation.controlCamera) camera.target = conversationTarget; foreach(DialogCard card in conversation.Cards()) { dialog.SetDialogQueue(card); dialog.DisplayNextCard(); while (dialog.IsDisplaying()) yield return null; yield return null; } if (alignCoroutine != null) StopCoroutine(alignCoroutine); camera.target = teaganFollowTarget; IsInProgress = false; }
public IHttpActionResult Post(ConversationRequestModel model) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var topic = this.data.Conversations.Select(x => x.Topic).FirstOrDefault(); var text = this.data.Conversations.Select(x => x.Text).FirstOrDefault(); var startedOn = this.data.Conversations.Select(x => x.StartedOn).FirstOrDefault(); var currentUserName = this.User.Identity.Name; var currentUser = this.data.Users.Where(u => u.UserName == currentUserName).FirstOrDefault(); var conversationToAdd = new Conversation { Topic = model.Topic, Text = model.Text, StartedOn = model.StartedOn, Author = currentUser }; this.data.Conversations.Add(conversationToAdd); this.data.SaveChanges(); PubNubNotificationProvider.Notify(conversationToAdd.Topic); return this.Ok(conversationToAdd.Id); }
private void EstablishCall() { // Create a new Conversation. Conversation conversation = new Conversation(_appEndpoint); // Create a new IM call. _imCall = new InstantMessagingCall(conversation); try { // Establish the IM call. _imCall.BeginEstablish(_destinationSipUri, new CallEstablishOptions(), result => { try { // Finish the asynchronous operation. _imCall.EndEstablish(result); } catch (RealTimeException ex) { // Catch and log exceptions. _logger.Log("Failed establishing IM call", ex); } }, null ); } catch (InvalidOperationException ioex) { _logger.Log("Failed establishing IM call", ioex); } }
private void Hyperlink_Click(object sender, RoutedEventArgs e) { BusinessLayer.ConversationManager cm = new BusinessLayer.ConversationManager(); EntityLayer.Conversation c; if(AddNum.Text.Length > 0) { c = cm.getConversationsFromContact(AddNum.Text); if (c == null) { cm.AddConversation(new EntityLayer.Contact(AddNum.Text)); IList<EntityLayer.Conversation> convs = cm.getConversations(); ViewModel.Conversation.ConversationsModelView cmv = new ViewModel.Conversation.ConversationsModelView(convs); parent.ListConversations.DataContext = cmv; } if (!parent.findConvos(AddNum.Text)) { Conversation cw = new Conversation(parent, AddNum.Text); parent.addConv(cw); cw.Show(); } this.Close(); } }
public GetSituation(Conversation conversation) { if (conversation == null){ Debug.LogError("GetSituation.GetSituation(): NULL CONVERSATION!"); } this.conversation = conversation; }
public void Write_TwoMessagesOnDifferentDays_TwoDaysGenerated() { var writer = new MoqWriter(); var message1 = Factory.Create<Message>(); var message2 = Factory.Create<Message>(); message1.Date = message2.Date.AddDays( 1 ); var conversation = new Conversation { ContactName = Factory.Create<string>(), PhoneNumber = Factory.Create<string>(), Messages = new List<Message> { message1, message2 } }; ConversationFile file = new ConversationFile( conversation, Factory.Create<string>() ); file.Write( writer ); string expectedResult = string.Concat( Common.GetExpectedHead( conversation.ContactName ), GetExpectedPageHeader( conversation ), "<div class='day'>", GetExpectedDayTitle( message1.Date ), GetExpectedMessageBody( message1 ), "</div><div class='day'>", GetExpectedDayTitle( message2.Date ), GetExpectedMessageBody( message2 ), "</div></body></html>" ); Assert.AreEqual( expectedResult, writer.Data ); }
void OnGUI() { if(conversation == null) return; GUIStyle guiStyle = GUI.skin.box; guiStyle.wordWrap = true; guiStyle.font = GUI.skin.font; GUI.Box(new Rect(Screen.width/2-width/2,Screen.height/2-height/2,width,height), conversation.GetText(), guiStyle); int response_height = 0; foreach(DictionaryEntry response in conversation.GetResponses()) { string response_text = response.Value as string; if(GUI.Button(new Rect(Screen.width/2+width/2 + 10,Screen.height/2-height/2 + response_height,200,50), response_text)) { conversation.Respond(response.Key as Object); } response_height += 60; } if(GUI.Button(new Rect(Screen.width/2+width/2 + 10,Screen.height/2-height/2 + response_height,200,50), "(Exit)")) { conversation = null; } }
private static BooleanOperand InterpretComparison(string code, string defaultNPCName, Conversation conversation) { string comparisonOperator; int operatorIndex; if (code.Contains(">=")){ comparisonOperator = ">="; } else if (code.Contains("<=")){ comparisonOperator = "<="; } else if (code.Contains("!=")){ comparisonOperator = "!="; } else if (code.Contains("=")){ comparisonOperator = "="; } else if (code.Contains(">")){ comparisonOperator = ">"; } else if (code.Contains("<")){ comparisonOperator = "<"; } else { comparisonOperator = null; } if (comparisonOperator == null){ throw new InvalidScriptException("No comparison operator: " + code); } else { operatorIndex = code.IndexOf(comparisonOperator); string firstPart = code.Substring(0, operatorIndex); string lastPart = code.Substring(operatorIndex + comparisonOperator.Length); if (code.Contains("$")){ return InterpretStringComparison(firstPart, lastPart, comparisonOperator, operatorIndex, defaultNPCName, conversation); } else { return InterpretNumericComparison(firstPart, lastPart, comparisonOperator, operatorIndex, defaultNPCName, conversation); } } }
// Use this for initialization void Start() { mConver = transform.FindChild("Anchor_T/Conver"); if (mConver == null) return; mUIConver = mConver.GetComponent<Conversation>(); }
/// <summary> /// Starts the conversation with another game object. /// </summary> /// <param name="obj">Object.</param> public void StartConversation(GameObject obj, string reply = null) { // cannot start another conversation if we have an active one if (activeConversation != null) { return; } ConversationSet conversationSet = obj.GetComponent<ConversationSet>(); if (conversationSet != null) { activeConversation = conversationSet.GetActiveConversation(); if (reply != null && reply != "") { activeConversation.headerText = reply; } // disable rigidbody while in conversation if (_state != null) { _state.state = State.DISABLED; } obj.SendMessage(eventName, SendMessageOptions.DontRequireReceiver); if (uiPrefab != null) { // TODO: finish this _uiShown = Instantiate(uiPrefab) as GameObject; _buttons = _uiShown.GetComponentsInChildren<Button>(); for (int i = 0; i < _buttons.Length; ++i) { // Button.ButtonClickedEvent ev = new Button.ButtonClickedEvent(); // ev.AddListener( // _buttons[i].onClick += OnResponseClick; } Button button; } } }
private async Task CreateConference() { _confConversation = new Conversation(_endpoint); var options = new ConferenceJoinOptions() { JoinMode = JoinMode.TrustedParticipant, AdHocConferenceAccessLevel = ConferenceAccessLevel.Everyone, AdHocConferenceAutomaticLeaderAssignment = AutomaticLeaderAssignment.Everyone }; await _confConversation.ConferenceSession.JoinAsync(options); Console.WriteLine("New conference created"); }
private static void StoreConversation(Conversation conversation, string ConversationID) { ActiveConversations.Add(ConversationID, new ConversationContainer() { Conversation = conversation, ConversationCreated = DateTime.Now }); }
public void Copy(Choice original) { wording = original.wording; lineReference = original.lineReference; actions = original.actions; reputations = original.reputations; conversation = original.conversation; }
public Statement(string id, Conversation conversation, string text, OnReply onReply, IsVisible isVisible) { this.id = id; this.conversation = conversation; this.text = text; this.onReplyCallBack = onReply; this.isVisible = isVisible; }
public PermissionController(Conversation.IConversation conversation, AutoMapper.IMappingEngine mapper, Rhino.Security.Mgmt.Data.PermissionRepository repository, Rhino.Security.Mgmt.Infrastructure.IValidator validator, Rhino.Security.Mgmt.Infrastructure.IStringConverter<Rhino.Security.Model.Permission> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
public TranscriptRecorderSessionShutdownEventArgs(TranscriptRecorderSession trs) { _conference = trs.Conference; _conversation = trs.Conversation; _transcriptRecorderSession = trs; _sessionId = trs.SessionId; _messages = trs.Messages; }
void CreateNewConversation(object o) { string to = (string)o; Conversation c = new Conversation(api, to); conversations.Add(to, c); c.Show(); conversationStarted.Set(); }
public OrderDetailController(Conversation.IConversation conversation, AutoMapper.IMappingEngine mapper, ExtMvc.Data.OrderDetailRepository repository, Nexida.Infrastructure.IValidator validator, Nexida.Infrastructure.IStringConverter<ExtMvc.Domain.OrderDetail> stringConverter) { _conversation = conversation; _mapper = mapper; _repository = repository; _validator = validator; _stringConverter = stringConverter; }
/// <summary> /// Receives the conversation, callback to UI and the OC root object /// </summary> public ConversationService(Conversation conversation) { //stores the conversation object this.conversation = conversation; //gets the IM modality from the self participant in the conversation this.myImModality = (InstantMessageModality)conversation.SelfParticipant.Modalities[ModalityTypes.InstantMessage]; }
public IConversation BeginConversation() { Guard.Operation(CurrentConversation == null, "There is already an active conversation."); var conversation = new Conversation(_persistenceProvider, _createSessionAndTransactionManager); conversation.Disposed += ConversationDisposed; CurrentConversation = conversation; return conversation; }
public void Init(Conversation<ConversationDto> conversation, string suffix) { HandleLbl.Text += " " + conversation.Handle; SuffixLbl.Text += " " + suffix; _conversation = conversation; _subscription = _conversation.SkipErrors().ObserveOn(SynchronizationContext.Current).Subscribe(OnNext); _conversation.Send(new ConversationDto { MessageType = MessageTypes.Init, Data = suffix }); }
private void MessengerOnIMWindowCreated(object pIMWindow) { var window = (IMessengerConversationWndAdvanced)pIMWindow; var newConversation = new Conversation(window); _activeConversations.Add(newConversation); if (ConversationStarted != null) ConversationStarted(this, new EventArgs<IConversation>(newConversation)); }
public ConversationFile( Conversation conversation, string path ) : base(path) { if ( conversation == null ) { throw new ArgumentNullException( "conversation" ); } Conversation = conversation; }
public GetString(string variableName, string npcName, Conversation conversation) { this.variableName = variableName; if (npcName != null){ GameObject npc = CharacterManager.GetCharacter(npcName); variableSet = ((CharacterState)npc.GetComponent("CharacterState")).GetVariableSet(); } else { variableSet = conversation.GetVariableSet(); } }
private void StartConversation(Conversation conversation, InstantMessageModality imModality) { conversation.ParticipantAdded += conversation_ParticipantAdded; conversation.StateChanged += conversation_StateChanged; conversation.ActionAvailabilityChanged += conversation_ActionAvailabilityChanged; imModality.InstantMessageReceived += imModality_InstantMessageReceived; imModality.IsTypingChanged += imModality_IsTypingChanged; imModality.ActionAvailabilityChanged += imModality_ActionAvailabilityChanged; }
public void DefineConversation(Conversation conversation) { if (conversation.partner1 != null && conversation.partner2 != null) { conversation.initiateDistance = Mathf.Max(conversation.partner1.converseDistance, conversation.partner2.converseDistance); conversation.warningDistance = Mathf.Max(conversation.partner1.converseDistance * conversation.partner1.warningThreshold, conversation.partner2.converseDistance * conversation.partner2.warningThreshold); conversation.breakingDistance = Mathf.Max(conversation.partner1.converseDistance * conversation.partner1.breakingThreshold, conversation.partner2.converseDistance * conversation.partner2.breakingThreshold); } }
private void conversation_Click_1(object sender, RoutedEventArgs e) { Conversation chat = ((sender as StackPanel).Tag as Conversation); NavigationService.Navigate(new Uri("/Views/Chat.xaml?sip=" + Utils.ReplacePlusInUri(chat.SipAddress), UriKind.RelativeOrAbsolute)); }
public void WithDeletedConversation(Conversation conversation) { DeletedConversations.Add(conversation); }
private void DrawPrioritySituationConversations() { SituationPriorityConversations = new List <Conversation>(); int amt = MaxSitPrioConvos - SituationPriorityConversations.Count; if (amt < 0) { amt = 0; } PopulatePrioritySituations(SaidToday); for (int i = 0; i < amt; i++) { if (combo4.Count > 0 && combo4.Count < 1) { Conversation conversation = WeightedRandomizer.From(combo4).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (combo3.Count > 0 && combo3.Count < 1) { Conversation conversation = WeightedRandomizer.From(combo3).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (combo2.Count > 0 && combo2.Count < 1) { Conversation conversation = WeightedRandomizer.From(combo2).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (areaList.Count > 0 && areaList.Count < 1) { Conversation conversation = WeightedRandomizer.From(areaList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (weatherList.Count > 0 && weatherList.Count < 1) { Conversation conversation = WeightedRandomizer.From(weatherList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (timeList.Count > 0 && timeList.Count < 1) { Conversation conversation = WeightedRandomizer.From(timeList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (seasonList.Count > 0 && seasonList.Count < 1) { Conversation conversation = WeightedRandomizer.From(seasonList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } } PopulatePrioritySituations(AllConversations); for (int i = 0; i < amt; i++) { if (combo4.Count > 0 && combo4.Count < 1) { Conversation conversation = WeightedRandomizer.From(combo4).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (combo3.Count > 0 && combo3.Count < 1) { Conversation conversation = WeightedRandomizer.From(combo3).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (combo2.Count > 0 && combo2.Count < 1) { Conversation conversation = WeightedRandomizer.From(combo2).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (areaList.Count > 0 && areaList.Count < 1) { Conversation conversation = WeightedRandomizer.From(areaList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (weatherList.Count > 0 && weatherList.Count < 1) { Conversation conversation = WeightedRandomizer.From(weatherList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (timeList.Count > 0 && timeList.Count < 1) { Conversation conversation = WeightedRandomizer.From(timeList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } if (seasonList.Count > 0 && seasonList.Count < 1) { Conversation conversation = WeightedRandomizer.From(seasonList).TakeOne(); SituationPriorityConversations.Add(conversation); if (SituationPriorityConversations.Count > MaxSitConvos) { return; } } } }
public async Task StartConversationAsync() { watermark = string.Empty; conversation = await directLineClient.Conversations.StartConversationAsync(); }
public static void Add(Conversation conversation) { Instance.mConversations.Add(conversation); Instance.Validated = false; }
private async Task <Activity> HandleSystemMessage(Activity message) { if (message.Type == ActivityTypes.DeleteUserData) { // Implement user deletion here // If we handle user deletion, return a real message } else if (message.Type == ActivityTypes.ConversationUpdate) { // Handle conversation state changes, like members being added and removed // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info // Not available in all channels IConversationUpdateActivity update = message; var client = new ConnectorClient(new Uri(message.ServiceUrl), new MicrosoftAppCredentials()); if (update.MembersAdded != null && update.MembersAdded.Any()) { foreach (var newMember in update.MembersAdded) { if (newMember.Id != message.Recipient.Id) { var reply = message.CreateReply(); reply.Text = GreetingFromBot(); //$"Welcome {newMember.Name}!"; await client.Conversations.ReplyToActivityAsync(reply); reply.Text = Environment.NewLine + "- How to Change Password ?" + Environment.NewLine + "- How do I Unlock account ?" + Environment.NewLine + "- What is Rebranding?" + Environment.NewLine + "- Contact Information for _<User>_."; await client.Conversations.ReplyToActivityAsync(reply); reply.Text = "At anytime type **\"Help\"** for more information."; await client.Conversations.ReplyToActivityAsync(reply); reply.Text = "Type **\"Login\"** for login."; await client.Conversations.ReplyToActivityAsync(reply); } } } } else if (message.Type == ActivityTypes.ContactRelationUpdate) { // Handle add/remove from contact lists // Activity.From + Activity.Action represent what happened var reply = message.CreateReply(); reply.Text = GreetingFromBot(); //$"Welcome {newMember.Name}!"; var client = new ConnectorClient(new Uri(message.ServiceUrl), new MicrosoftAppCredentials()); await client.Conversations.ReplyToActivityAsync(reply); } else if (message.Type == ActivityTypes.Event) { // Send TokenResponse Events along to the Dialog stack if (message.IsTokenResponseEvent()) { await Conversation.SendAsync(message, () => new Dialogs.QnADialog()); } else { var reply = message.CreateReply(); reply.Text = GreetingFromBot(); //$"Welcome {newMember.Name}!"; var client = new ConnectorClient(new Uri(message.ServiceUrl), new MicrosoftAppCredentials()); await client.Conversations.ReplyToActivityAsync(reply); } } return(null); }
/** * Adds a conversation to the list of conversation in the game * * @param conversation * the new conversation */ public void addConversation(Conversation conversation) { conversations.Add(conversation); }
public void GiveFuncionBtns(Conversation conv) { DialogueManager.instance.SetConversation(conv, null); }
private static void LoadCustomEventsFromFile(int fileName, string regionPackFolder, Conversation self) { CustomWorldMod.Log("~~~LOAD CONVO " + fileName); string file = "Text_" + LocalizationTranslator.LangShort(CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage) + Path.DirectorySeparatorChar + fileName + ".txt"; string convoPath = CRExtras.BuildPath(regionPackFolder, CRExtras.CustomFolder.Text, file: file); if (!File.Exists(convoPath)) { CustomWorldMod.Log("NOT FOUND " + convoPath); return; } string text2 = File.ReadAllText(convoPath, Encoding.Default); if (text2[0] == '0') { CustomWorldMod.EncryptCustomDialogue(CRExtras.BuildPath(regionPackFolder, CRExtras.CustomFolder.Text), regionPackFolder); } else { CustomWorldMod.Log($"Decrypting file [{fileName}] at [{regionPackFolder}] in [{CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage}]"); text2 = Custom.xorEncrypt(text2, (int)(54 + fileName + (int)CustomWorldMod.rainWorldInstance.inGameTranslator.currentLanguage * 7)); } string[] array = Regex.Split(text2, Environment.NewLine); if (array.Length < 2) { CustomWorldMod.Log($"Corrupted conversation [{array}]", true); } try { if (Regex.Split(array[0], "-")[1] == fileName.ToString()) { CustomWorldMod.Log($"Moon conversation... [{array[1].Substring(0, Math.Min(array[1].Length, 15))}]"); for (int j = 1; j < array.Length; j++) { string[] array3 = Regex.Split(array[j], " : "); if (array3.Length == 1 && array3[0].Length > 0) { self.events.Add(new Conversation.TextEvent(self, 0, array3[0], 0)); } } } else { CustomWorldMod.Log($"Corrupted dialogue file...[{Regex.Split(array[0], "-")[1]}]", true); } } catch { CustomWorldMod.Log("TEXT ERROR"); self.events.Add(new Conversation.TextEvent(self, 0, "TEXT ERROR", 100)); } }
public void Run() { //Initalize and startup the platform. ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType); _collabPlatform = new CollaborationPlatform(clientPlatformSettings); _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform); // Get port range NetworkPortRange portRange = CollaborationPlatform.AudioVideoSettings.GetPortRange(); Console.WriteLine("Port range is from " + portRange.LocalNetworkPortMin + " to " + portRange.LocalNetworkPortMax); // Modifying port range portRange.SetRange(1500, 2000); CollaborationPlatform.AudioVideoSettings.SetPortRange(portRange); Console.WriteLine("Port range now is from " + portRange.LocalNetworkPortMin + " to " + portRange.LocalNetworkPortMax); //Sync; wait for the startup to complete. _autoResetEvent.WaitOne(); //Initalize and register the endpoint, using the credentials of the user the application will be acting as. UserEndpointSettings userEndpointSettings = new UserEndpointSettings(_userURI, _userServer); userEndpointSettings.Credential = _credential; _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings); _userEndpoint.BeginEstablish(EndEndpointEstablish, _userEndpoint); //Sync; wait for the registration to complete. _autoResetEvent.WaitOne(); //Setup the conversation and place the call. ConversationSettings convSettings = new ConversationSettings(); convSettings.Priority = _conversationPriority; convSettings.Subject = _conversationSubject; //Conversation represents a collection of modalities in the context of a dialog with one or multiple callees. Conversation conversation = new Conversation(_userEndpoint, convSettings); _audioVideoCall = new AudioVideoCall(conversation); //Call: StateChanged: Only hooked up for logging. _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(audioVideoCall_StateChanged); //Subscribe for the flow configuration requested event; the flow will be used to send the media. //Ultimately, as a part of the callback, the media will be sent/recieved. _audioVideoCall.AudioVideoFlowConfigurationRequested += this.audioVideoCall_FlowConfigurationRequested; //Place the call to the remote party; _audioVideoCall.BeginEstablish(_calledParty, null, EndCallEstablish, _audioVideoCall); //Sync; wait for the call to complete. _autoResetEvent.WaitOne(); // Shutdown the platform _collabPlatform.BeginShutdown(EndPlatformShutdown, _collabPlatform); //Wait for shutdown to occur. _autoResetShutdownEvent.WaitOne(); }
//hmm public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); // calculate something for us to return int length = (activity.Text ?? string.Empty).Length; // return our reply to the user //Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} characters"); // Activity reply = activity.CreateReply($"BeerBot"); // await connector.Conversations.ReplyToActivityAsync(reply); // Activity reply = activity.CreateReply($"Hi From BeerBot!"); /* * if (activity.Entities != null ) * { * * await connector.Conversations.ReplyToActivityAsync(activity.CreateReply($"Entity is not null, there are {activity.Entities.Count}")); * string entityValues = ""; * foreach (Entity entity in activity.Entities) * { * await connector.Conversations.ReplyToActivityAsync(activity.CreateReply($"Entity type is {entity.Type.ToString()}")); * * if (entity.Type == "Place") * { * await connector.Conversations.ReplyToActivityAsync(activity.CreateReply($"Entity is Place")); * * try * { * dynamic place = entity.Properties; * entityValues = place.geo.latitude + " " + place.geo.longitude; * } * catch { } * } * * * } * * } * else * { * * await connector.Conversations.ReplyToActivityAsync(activity.CreateReply($"Did not get location")); * * } * await connector.Conversations.ReplyToActivityAsync(activity.CreateReply($"Location logic finished")); */ await Conversation.SendAsync(activity, MakeRootDialog); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public void SpeakTo() { DialogueManager.StopConversation(); GetSituationPool(); ValidateCycleList(); Conversation chosenConversation = null; int tries = SituationPriorityConversations.Count + SituationConversations.Count + DayPriorityGenericConversations.Count + DayGenericConversations.Count; for (int i = tries; i > 0; i--) { // print("try draaaw"); //draw a conversation based on priorities if (SituationPriorityConversations.Count > 0) { int rand = Random.Range(0, SituationPriorityConversations.Count); if (!CycleList.Contains(SituationPriorityConversations[rand])) { chosenConversation = SituationPriorityConversations[rand]; SituationPriorityConversations.Remove(chosenConversation); } } if (chosenConversation == null && DayPriorityGenericConversations.Count > 0) { int rand = Random.Range(0, DayPriorityGenericConversations.Count); if (!CycleList.Contains(DayPriorityGenericConversations[rand])) { chosenConversation = DayPriorityGenericConversations[rand]; DayPriorityGenericConversations.Remove(chosenConversation); } } if (chosenConversation == null && SituationConversations.Count > 0) { int rand = Random.Range(0, SituationConversations.Count); if (!CycleList.Contains(SituationConversations[rand])) { chosenConversation = SituationConversations[rand]; SituationConversations.Remove(chosenConversation); } } if (chosenConversation == null && DayGenericConversations.Count > 0) { int rand = Random.Range(0, DayGenericConversations.Count); if (!CycleList.Contains(DayGenericConversations[rand])) { chosenConversation = DayGenericConversations[rand]; DayGenericConversations.Remove(chosenConversation); } } if (chosenConversation == null) { // print("ohno, null. Tries left: " + i); } else { break; } } if (chosenConversation == null) { // print("ayyyy"); CycleList.Clear(); GetSituationPool(); RePopulateGeneric(); ValidateConversations(SituationPriorityConversations); ValidateConversations(SituationConversations); ValidateConversations(DayGenericConversations); ValidateConversations(DayPriorityGenericConversations); tries = SituationPriorityConversations.Count + SituationConversations.Count + DayPriorityGenericConversations.Count + DayGenericConversations.Count; print(tries); for (int i = tries; i > 0; i--) { //draw a conversation based on priorities if (SituationPriorityConversations.Count > 0) { int rand = Random.Range(0, SituationPriorityConversations.Count); chosenConversation = SituationPriorityConversations[rand]; SituationPriorityConversations.Remove(chosenConversation); } if (chosenConversation == null && DayPriorityGenericConversations.Count > 0) { int rand = Random.Range(0, DayPriorityGenericConversations.Count); chosenConversation = DayPriorityGenericConversations[rand]; DayPriorityGenericConversations.Remove(chosenConversation); } if (chosenConversation == null && SituationConversations.Count > 0) { int rand = Random.Range(0, SituationConversations.Count); chosenConversation = SituationConversations[rand]; SituationConversations.Remove(chosenConversation); } if (chosenConversation == null && DayGenericConversations.Count > 0) { int rand = Random.Range(0, DayGenericConversations.Count); chosenConversation = DayGenericConversations[rand]; DayGenericConversations.Remove(chosenConversation); } if (chosenConversation == null) { // print("ohno, null. Tries left: " + i); } else { break; } } } if (chosenConversation == null) { Debug.LogWarning("NO ELIGIBLE CONVERSATION"); return; } CycleList.Add(chosenConversation); Field field = chosenConversation.fields.Find(f => string.Equals(f.title, "SaidToday")); field.value = "True"; field = chosenConversation.fields.Find(f => string.Equals(f.title, "SaidThisGame")); field.value = "True"; SaidToday.Add(chosenConversation); DialogueManager.Instance.StartConversation(chosenConversation.Title); }
public async Task <Conversation> Create(Conversation conversation) { await _context.Conversations.InsertOneAsync(conversation); return(conversation); }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity, CancellationToken cancellationToken) { var connectorClient = await BotConnectorUtility.BuildConnectorClientAsync(activity.ServiceUrl); try { if (activity.Type == ActivityTypes.Message) { // Special handling for a command to simulate a reset of the bot chat if (!(activity.Conversation.IsGroup ?? false) && (activity.Text == "/resetbotchat")) { return(await HandleResetBotChatAsync(activity, cancellationToken)); } //Set the Locale for Bot activity.Locale = TemplateUtility.GetLocale(activity); //Strip At mention from incoming request text activity = Middleware.StripAtMentionText(activity); //Convert incoming activity text to lower case, to match the intent irrespective of incoming text case activity = Middleware.ConvertActivityTextToLower(activity); // todo: enable tenant check //var unexpectedTenantResponse = await RejectMessageFromUnexpectedTenant(activity, connectorClient); //if (unexpectedTenantResponse != null) return unexpectedTenantResponse; //await Conversation.SendAsync(activity, () => ActivityHelper.IsConversationPersonal(activity) // ? (IDialog<object>)new UserRootDialog() // : new AgentRootDialog()); await Conversation.SendAsync(activity, () => ActivityHelper.GetRootDialog(activity)); //await Conversation.SendAsync(activity, () => ActivityHelper.IsConversationPersonal(activity) // ? new ExceptionHandlerDialog<object>(new UserRootDialog(), // displayException: true) // : new ExceptionHandlerDialog<object>(new AgentRootDialog(), // displayException: true)); } else if (activity.Type == ActivityTypes.MessageReaction) { var reactionsAdded = activity.ReactionsAdded; var reactionsRemoved = activity.ReactionsRemoved; var replytoId = activity.ReplyToId; Bot.Connector.Activity reply; if (reactionsAdded != null && reactionsAdded.Count > 0) { reply = activity.CreateReply(Strings.LikeMessage); await BotConnectorUtility.BuildRetryPolicy().ExecuteAsync(async() => await connectorClient.Conversations.ReplyToActivityAsync(reply)); } else if (reactionsRemoved != null && reactionsRemoved.Count > 0) { reply = activity.CreateReply(Strings.RemoveLike); await BotConnectorUtility.BuildRetryPolicy().ExecuteAsync(async() => await connectorClient.Conversations.ReplyToActivityAsync(reply)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else if (activity.Type == ActivityTypes.Invoke) // Received an invoke { // Handle ComposeExtension query if (activity.IsComposeExtensionQuery()) { WikipediaComposeExtension wikipediaComposeExtension = new WikipediaComposeExtension(); HttpResponseMessage httpResponse = null; using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity)) { var botDataStore = scope.Resolve <IBotDataStore <BotData> >(); // Handle compose extension selected item if (activity.Name == "composeExtension/selectItem") { // This handler is used to process the event when a user in Teams selects wiki item from wiki result ComposeExtensionResponse selectedItemResponse = await wikipediaComposeExtension.HandleComposeExtensionSelectedItem(activity, botDataStore); httpResponse = Request.CreateResponse <ComposeExtensionResponse>(HttpStatusCode.OK, selectedItemResponse); } else { // Handle the wiki compose extension request and returned the wiki result response ComposeExtensionResponse composeExtensionResponse = await wikipediaComposeExtension.GetComposeExtensionResponse(activity, botDataStore); httpResponse = Request.CreateResponse <ComposeExtensionResponse>(HttpStatusCode.OK, composeExtensionResponse); } var address = Address.FromActivity(activity); await botDataStore.FlushAsync(address, CancellationToken.None); } return(httpResponse); } //Actionable Message else if (activity.IsO365ConnectorCardActionQuery()) { // this will handle the request coming any action on Actionable messages return(await HandleO365ConnectorCardActionQuery(activity)); } //PopUp SignIn else if (activity.Name == "signin/verifyState") { // this will handle the request coming from PopUp SignIn return(await PopUpSignInHandler(activity)); } // Handle rest of the invoke request else { var messageActivity = (IMessageActivity)null; //this will parse the invoke value and change the message activity as well messageActivity = InvokeHandler.HandleInvokeRequest(activity); await Conversation.SendAsync(activity, () => ActivityHelper.GetRootDialog(activity)); //await Conversation.SendAsync(activity, () => ActivityHelper.IsConversationPersonal(activity) // ? (IDialog<object>) new UserRootDialog() // : new AgentRootDialog()); //await Conversation.SendAsync(messageActivity, () => ActivityHelper.IsConversationPersonal(messageActivity) // ? new ExceptionHandlerDialog<object>(new UserRootDialog(), // displayException: true) // : new ExceptionHandlerDialog<object>(new AgentRootDialog(), // displayException: true)); return(Request.CreateResponse(HttpStatusCode.OK)); } } else { await HandleSystemMessageAsync(activity, connectorClient, cancellationToken); } } catch (Exception e) { WebApiConfig.TelemetryClient.TrackException(e, new Dictionary <string, string> { { "class", "MessagesController" } }); throw; } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public async Task <bool> BuyItem(uint itemId, int maxCount, int SelectStringLine = 0) { if ((!ShopExchangeCurrency.Open && VendorNpc == null) || VendorNpc.Location.Distance(Core.Me.Location) > 5f) { await Navigation.GetTo(886, new Vector3(36.33978f, -16f, 145.3877f)); } if (!ShopExchangeCurrency.Open && VendorNpc.Location.Distance(Core.Me.Location) > 4f) { await Navigation.OffMeshMove(VendorNpc.Location); await Coroutine.Sleep(500); } if (!ShopExchangeCurrency.Open) { VendorNpc.Interact(); await Coroutine.Wait(5000, () => ShopExchangeCurrency.Open || Talk.DialogOpen || Conversation.IsOpen); if (Conversation.IsOpen) { Conversation.SelectLine((uint)SelectStringLine); await Coroutine.Wait(5000, () => ShopExchangeCurrency.Open); } } if (ShopExchangeCurrency.Open) { var items = SpecialShopManager.Items; var specialShopItem = items?.Cast <SpecialShopItem?>().FirstOrDefault(i => i.HasValue && i.Value.ItemIds.Contains(itemId)); if (!specialShopItem.HasValue) { return(false); } var count = Math.Min(CanAffordScrip(specialShopItem.Value), maxCount); if (count > 0) { Purchase(itemId, (uint)count); } await Coroutine.Wait(5000, () => SelectYesno.IsOpen); SelectYesno.ClickYes(); await Coroutine.Wait(500, () => !SelectYesno.IsOpen); await Coroutine.Wait(500, () => SelectYesno.IsOpen); if (SelectYesno.IsOpen) { SelectYesno.ClickYes(); await Coroutine.Wait(500, () => !SelectYesno.IsOpen); } await Coroutine.Sleep(1000); ShopExchangeCurrency.Close(); return(true); } return(false); }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { if (ProdSearch.Dialogs.ProdSearch_KeywordDialog.getcheck()) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); string strLuisKey = ConfigurationManager.AppSettings["LUISAPIKey"].ToString(); string strLuisAppId = ConfigurationManager.AppSettings["LUISAppId"].ToString(); string strMessage = HttpUtility.UrlEncode(activity.Text); string strLuisUrl = $"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/{strLuisAppId}?subscription-key={strLuisKey}&verbose=true&timezoneOffset=0&q={strMessage}"; // 收到文字訊息後,往LUIS送 WebRequest request = WebRequest.Create(strLuisUrl); HttpWebResponse hwresponse = (HttpWebResponse)request.GetResponse(); Stream dataStream = hwresponse.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string json = reader.ReadToEnd(); LUIS objLUISRes = JsonConvert.DeserializeObject <LUIS>(json); string strReply = "無法識別的內容"; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setLuisKWCheck_true(); if (objLUISRes.intents.Count > 0) { string strIntent = objLUISRes.intents[0].intent; if (strIntent.Equals("搜尋壽險")) { strReply = "將進行搜尋壽險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("壽險"); } else if (strIntent.Equals("搜尋投資型保險")) { strReply = "將進行搜尋投資型保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("投資"); } else if (strIntent.Equals("搜尋年金保險")) { strReply = "將進行搜尋年金保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("年金"); } else if (strIntent.Equals("搜尋小額終老保險")) { strReply = "將進行搜尋小額終老保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("小額終老"); } else if (strIntent.Equals("搜尋實物給付型保險")) { strReply = "將進行搜尋實物給付型保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("實物給付"); } else if (strIntent.Equals("搜尋長照")) { strReply = "將進行搜尋長照..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("長照專區"); } else if (strIntent.Equals("搜尋大男子保險")) { strReply = "將進行搜尋大男子保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("大男子保險"); } else if (strIntent.Equals("搜尋生死合險")) { strReply = "將進行搜尋生死合險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("生死合險"); } else if (strIntent.Equals("搜尋HER大女子保險")) { strReply = "將進行搜尋HER大女子保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("HER大女子保險"); } else if (strIntent.Equals("搜尋OIU保險")) { strReply = "將進行搜尋OIU保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("OIU專區"); } else if (strIntent.Equals("搜尋利變壽")) { strReply = "將進行搜尋利變壽..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("利變壽"); } else if (strIntent.Equals("搜尋展新人生保險")) { strReply = "將進行搜尋展新人生保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("展新人生"); } else if (strIntent.Equals("搜尋意外傷害險")) { strReply = "將進行搜尋意外傷害險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("意外傷害"); } else if (strIntent.Equals("搜尋活力系列保險")) { strReply = "將進行搜尋活力系列保險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("活力系列"); } else if (strIntent.Equals("搜尋醫療險")) { strReply = "將進行搜尋醫療險..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setKeyword("醫療"); } else { strReply = "無法識別的內容,請重新輸入..."; ProdSearch.Dialogs.ProdSearch_KeywordDialog.setLuisKWCheck_false(); } } Activity reply = activity.CreateReply(strReply); await connector.Conversations.ReplyToActivityAsync(reply); ProdSearch.Dialogs.ProdSearch_KeywordDialog.setcheck(); } else if (true) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); string strLuisKey = ConfigurationManager.AppSettings["LUISAPIKey"].ToString(); string strLuisAppId = ConfigurationManager.AppSettings["LUISAppId"].ToString(); string strMessage = HttpUtility.UrlEncode(activity.Text); string strLuisUrl = $"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/{strLuisAppId}?subscription-key={strLuisKey}&verbose=true&timezoneOffset=0&q={strMessage}"; // 收到文字訊息後,往LUIS送 WebRequest request = WebRequest.Create(strLuisUrl); HttpWebResponse hwresponse = (HttpWebResponse)request.GetResponse(); Stream dataStream = hwresponse.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string json = reader.ReadToEnd(); LUIS objLUISRes = JsonConvert.DeserializeObject <LUIS>(json); //string strReply = "無法識別的內容"; if (objLUISRes.intents.Count > 0) { string strIntent = objLUISRes.intents[0].intent; if (strIntent.Equals("回首頁選單")) { RootDialog.SetBack2home(true); } } //Activity reply = activity.CreateReply(strReply); //await connector.Conversations.ReplyToActivityAsync(reply); } await Conversation.SendAsync(activity, () => new Dialogs.RootDialog()); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
private void DrawSituationConversations() { // print("Drawing situation"); SituationConversations = new List <Conversation>(); PopulateSituations(SaidToday); //////////////////////////////// //Draw desired amount from the sorted lists, based on weighted priorities for (int i = 0; i < MaxSitConvos; i++) { if (combo4.Count > 0) { Conversation conversation = WeightedRandomizer.From(combo4).TakeOne(); SituationConversations.Add(conversation); combo4.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (combo3.Count > 0) { Conversation conversation = WeightedRandomizer.From(combo3).TakeOne(); SituationConversations.Add(conversation); combo3.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (combo2.Count > 0) { Conversation conversation = WeightedRandomizer.From(combo2).TakeOne(); SituationConversations.Add(conversation); combo2.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (areaList.Count > 0) { Conversation conversation = WeightedRandomizer.From(areaList).TakeOne(); SituationConversations.Add(conversation); areaList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (weatherList.Count > 0) { Conversation conversation = WeightedRandomizer.From(weatherList).TakeOne(); SituationConversations.Add(conversation); weatherList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (timeList.Count > 0) { Conversation conversation = WeightedRandomizer.From(timeList).TakeOne(); SituationConversations.Add(conversation); timeList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (seasonList.Count > 0) { Conversation conversation = WeightedRandomizer.From(seasonList).TakeOne(); SituationConversations.Add(conversation); seasonList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } } PopulateSituations(AllConversations); //////////////////////////////// //Draw desired amount from the sorted lists, based on weighted priorities // print("Adding from all"); for (int i = 0; i < MaxSitConvos; i++) { if (combo4.Count > 0) { Conversation conversation = WeightedRandomizer.From(combo4).TakeOne(); SituationConversations.Add(conversation); combo4.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (combo3.Count > 0) { Conversation conversation = WeightedRandomizer.From(combo3).TakeOne(); SituationConversations.Add(conversation); combo3.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (combo2.Count > 0) { Conversation conversation = WeightedRandomizer.From(combo2).TakeOne(); SituationConversations.Add(conversation); combo2.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (areaList.Count > 0) { Conversation conversation = WeightedRandomizer.From(areaList).TakeOne(); SituationConversations.Add(conversation); areaList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (weatherList.Count > 0) { Conversation conversation = WeightedRandomizer.From(weatherList).TakeOne(); SituationConversations.Add(conversation); weatherList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (timeList.Count > 0) { Conversation conversation = WeightedRandomizer.From(timeList).TakeOne(); SituationConversations.Add(conversation); timeList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } if (seasonList.Count > 0) { Conversation conversation = WeightedRandomizer.From(seasonList).TakeOne(); SituationConversations.Add(conversation); seasonList.Remove(conversation); if (SituationConversations.Count > MaxSitConvos) { return; } } } // print(SituationConversations.Count); }
public Task <bool> AddItemAsync(Conversation item) { _conversations.Add(item); return(Task.FromResult(true)); }
public HelpIntent(Conversation conversation) : base(conversation) { }
public override void ParseElement(XmlElement element) { XmlNodeList speakschar = element.SelectNodes("speak-char"), speaksplayer = element.SelectNodes("speak-player"), responses = element.SelectNodes("response"), options = element.SelectNodes("option"), effects = element.SelectNodes("effect"), gosback = element.SelectNodes("go-back"); string tmpArgVal; // Store the name string conversationName = ""; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { conversationName = tmpArgVal; } // Create a dialogue node (which will be the root node) and add it to a new tree // The content of the tree will be built adding nodes directly to the root currentNode = new DialogueConversationNode(); conversation = new TreeConversation(conversationName, currentNode); pastOptionNodes = new List <ConversationNode>(); foreach (XmlElement el in speakschar) { // Set default name to "NPC" characterName = "NPC"; audioPath = ""; // If there is a "idTarget" attribute, store it tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { characterName = tmpArgVal; } // If there is a "uri" attribute, store it as audio path tmpArgVal = el.GetAttribute("uri"); if (!string.IsNullOrEmpty(tmpArgVal)) { audioPath = tmpArgVal; } // If there is a "uri" attribute, store it as audio path tmpArgVal = el.GetAttribute("synthesize"); if (!string.IsNullOrEmpty(tmpArgVal)) { string response = tmpArgVal; if (response.Equals("yes")) { synthesizerVoice = true; } else { synthesizerVoice = false; } } // Store the read string into the current node, and then delete the string. The trim is performed so we // don't // have to worry with indentations or leading/trailing spaces ConversationLine line = new ConversationLine(characterName, el.InnerText); if (audioPath != null && !this.audioPath.Equals("")) { line.setAudioPath(audioPath); } if (synthesizerVoice != null) { line.setSynthesizerVoice(synthesizerVoice); } currentNode.addLine(line); } foreach (XmlElement el in speaksplayer) { audioPath = ""; // If there is a "uri" attribute, store it as audio path tmpArgVal = el.GetAttribute("uri"); if (!string.IsNullOrEmpty(tmpArgVal)) { audioPath = tmpArgVal; } // If there is a "uri" attribute, store it as audio path tmpArgVal = el.GetAttribute("synthesize"); if (!string.IsNullOrEmpty(tmpArgVal)) { string response = tmpArgVal; if (response.Equals("yes")) { synthesizerVoice = true; } else { synthesizerVoice = false; } } // Store the read string into the current node, and then delete the string. The trim is performed so we // don't have to worry with indentations or leading/trailing spaces ConversationLine line = new ConversationLine(ConversationLine.PLAYER, el.InnerText); if (audioPath != null && !this.audioPath.Equals("")) { line.setAudioPath(audioPath); } if (synthesizerVoice != null) { line.setSynthesizerVoice(synthesizerVoice); } currentNode.addLine(line); } foreach (XmlElement el in responses) { //If there is a "random" attribute, store is the options will be random tmpArgVal = el.GetAttribute("random"); if (!string.IsNullOrEmpty(tmpArgVal)) { if (tmpArgVal.Equals("yes")) { random = true; } else { random = false; } } //If there is a "keepShowing" attribute, keep the previous conversation line showing tmpArgVal = el.GetAttribute("keepShowing"); if (!string.IsNullOrEmpty(tmpArgVal)) { if (tmpArgVal.Equals("yes")) { keepShowing = true; } else { keepShowing = false; } } //If there is a "showUserOption" attribute, identify if show the user response at option node tmpArgVal = el.GetAttribute("showUserOption"); if (!string.IsNullOrEmpty(tmpArgVal)) { if (tmpArgVal.Equals("yes")) { showUserOption = true; } else { showUserOption = false; } } //If there is a "showUserOption" attribute, identify if show the user response at option node tmpArgVal = el.GetAttribute("preListening"); if (!string.IsNullOrEmpty(tmpArgVal)) { if (tmpArgVal.Equals("yes")) { preListening = true; } else { preListening = false; } } //If there is a "x" and "y" attributes with the position where the option node has to be painted, tmpArgVal = el.GetAttribute("preListening"); if (!string.IsNullOrEmpty(tmpArgVal)) { if (tmpArgVal.Equals("yes")) { preListening = true; } else { preListening = false; } } //If there is a "x" and "y" attributes with the position where the option node has to be painted tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } // Create a new OptionNode, and link it to the current node ConversationNode nuevoNodoOpcion = new OptionConversationNode(random, keepShowing, showUserOption, preListening, x, y); currentNode.addChild(nuevoNodoOpcion); // Change the actual node for the option node recently created currentNode = nuevoNodoOpcion; } foreach (XmlElement el in options) { currentNode = pastOptionNodes[pastOptionNodes.Count - 1]; pastOptionNodes.RemoveAt(pastOptionNodes.Count - 1); } foreach (XmlElement el in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(el); currentNode.setEffects(currentEffects); } foreach (XmlElement el in gosback) { currentNode.addChild(pastOptionNodes[pastOptionNodes.Count - 1]); } chapter.addConversation(new GraphConversation((TreeConversation)conversation)); }
/// <summary> /// Initializes class with the conversation. /// </summary> /// <param name="conversation">Conversation</param> public VisionSafeHandler(Conversation conversation) : base(conversation) { }
public RespondTransaction_InitialState(Conversation conversation, Envelope env) : base(env, conversation, null) { Request = env.Contents as TransactionRequestMessage; }
public HttpResponse(Frame frame, Conversation conversation) : base(frame, conversation, MessageType.Response) { }
public override void Send() { base.Send(); Conversation.UpdateState(new ConversationDoneState(Conversation, this)); }
public ConversationDTO(Conversation conversation, User user) { Id = conversation.Id; ToUser = new UserInfoSmallDTO(conversation.ToUser == user ? conversation.FromUser : conversation.ToUser); HasNewMessagees = conversation.ToUser == user ? conversation.FromUserHasNewMessages : conversation.ToUserHasNewMessages; }
public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) { if (turnContext.Activity.Type == ActivityTypes.Message) { var state = await _accessors.UserData.GetAsync(turnContext, () => new UserData()); var text = turnContext.Activity.Text.ToLowerInvariant(); var messageWords = text.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); switch (messageWords[0]) { case "intro": case "help": await turnContext.SendActivityAsync(INTRO_MESSAGE); break; case "sub": if (!int.TryParse(messageWords[1], out int newsMinPoints)) { await turnContext.SendActivityAsync($"sub command usage: 'sub MIN_POINTS', where MIN_POINTS - positive integer number."); break; } User user; if (state.UserId == null) { user = await _userStorage.GetUserAsync(turnContext.Activity.From.Id); if (user != null) { state.UserId = user.Id; } else { var message = turnContext.Activity.AsMessageActivity(); var conversation = new Conversation() { ToId = message.From.Id, ToName = message.From.Name, FromId = message.Recipient.Id, FromName = message.Recipient.Name, ServiceUrl = message.ServiceUrl, ChannelId = message.ChannelId, Id = message.Conversation.Id }; user = new User(turnContext.Activity.From.Id, turnContext.Activity.From.Name, conversation); await _userStorage.AddOrUpdateUserAsync(user); state.UserId = user.Id; } await _accessors.UserData.SetAsync(turnContext, state); await _accessors.ConversationState.SaveChangesAsync(turnContext); } else { user = await _userStorage.GetUserAsync(state.UserId); } user.IsSubscribedToStories = true; user.StoriesMinPointsToNotify = newsMinPoints; await _userStorage.AddOrUpdateUserAsync(user); await turnContext.SendActivityAsync($"You have been subscribed to news with more than {newsMinPoints} points."); await _userUnreadStorySender.SendToUserAsync(state.UserId); break; case "unsub": if (state.UserId == null) { await turnContext.SendActivityAsync($"You are not subscribed to news."); break; } var unsubUser = await _userStorage.GetUserAsync(state.UserId); await _userStorage.AddOrUpdateUserAsync(unsubUser); await turnContext.SendActivityAsync($"You have been successfully unsubscribed."); break; default: await turnContext.SendActivityAsync("Sorry, can't understand you. Type \"help\" to list commands."); break; } } else if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate) { if (turnContext.Activity.MembersAdded.Any()) { foreach (var member in turnContext.Activity.MembersAdded) { // Greet anyone that was not the target (recipient) of this message // the 'bot' is the recipient for events from the channel, // turnContext.Activity.MembersAdded == turnContext.Activity.Recipient.Id indicates the // bot was added to the conversation. if (member.Id != turnContext.Activity.Recipient.Id) { await turnContext.SendActivityAsync(INTRO_MESSAGE); } } } } }
/// <summary> /// Initializes class with the conversation. /// </summary> /// <param name="conversation">Conversation</param> public BaseVisionHandler(Conversation conversation) : base(conversation) { }
public TranscriptRecorderSessionChangedEventArgs(TranscriptRecorderSession trs) { _conference = trs.Conference; _conversation = trs.Conversation; _sessionId = trs.SessionId; }
public void callMeBack(Conversation c) { this.callbackC = c; }
/// <summary> /// Initializes class with the conversation. /// </summary> /// <param name="conversation">Conversation</param> public VisionSearchHandler(Conversation conversation) : base(conversation) { }