private async Task AskingInputCommentAsync(ContextState contextState, MessageEvent ev) { bool isValidMessage(out TextEventMessage textEventMessage) { if (ev.Message.Type != EventMessageType.Text) { textEventMessage = null; return(false); } textEventMessage = (TextEventMessage)ev.Message; return(LineMessages.IsYesOrNo(textEventMessage.Text)); } if (!isValidMessage(out var text)) { await contextState.Client.ReplyMessageAsync(ev.ReplyToken, LineMessages.GetConfirmMessage(LineMessages.AskCommentMessage)); SetNextCallMethod(nameof(AskingInputCommentAsync)); return; } if (LineMessages.IsYes(text.Text)) { await contextState.Client.ReplyMessageAsync(ev.ReplyToken, LineMessages.GetInputCommentMessage()); SetNextCallMethod(nameof(InputCommentAsync)); return; } else { await FinishInputAsync(contextState, ev); } }
private async Task ExecuteLocationMessageAsync(ContextState contextState, MessageEvent messageEvent) { var locationMessage = (LocationEventMessage)messageEvent.Message; var locationLog = new LocationLog { RowKey = messageEvent.Source.UserId, Latitude = locationMessage.Latitude, Longitude = locationMessage.Longitude, Name = locationMessage.Title, Address = locationMessage.Address, }; await contextState.StateStoreTable.ExecuteAsync(TableOperation.InsertOrReplace(locationLog)); await contextState.Client.ReplyMessageAsync(messageEvent.ReplyToken, LineMessages.GetConfirmMessage(LineMessages.AskCommentMessage)); SetNextCallMethod(nameof(AskingInputCommentAsync)); }