Skip to content

Commit

Permalink
Update PetStoreAssistantBot.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chtrembl committed Jan 3, 2024
1 parent 087bd58 commit 62d4c73
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {

//DEBUG ONLY
if (text.contains("context")) {
printTurnContext(turnContext);

return turnContext.sendActivity(
MessageFactory.text(getTurnContext(turnContext)))
.thenApply(sendResult -> null);
}

if (text.contains("variables")) {
Expand Down Expand Up @@ -261,22 +264,25 @@ private String getVariables() {
return debug;
}

public void printTurnContext(TurnContext turnContext) {
public String getTurnContext(TurnContext turnContext) {

StringBuilder debug = new StringBuilder();

try{
LOGGER.info("Turn Context Properties:");
turnContext.getActivity().getProperties().forEach((key, value) -> {
LOGGER.info(key + ": " + value.toString());
});
debug.append("Turn Context Properties:");
turnContext.getActivity().getProperties().forEach((key, value) -> {
debug.append(" "+ key + ": " + value.toString());
});
}
catch(Exception e)
{

}

try{
LOGGER.info("Turn Context Attachments:");
debug.append("Turn Context Attachments:");
turnContext.getActivity().getAttachments().forEach((attachment) -> {
LOGGER.info(attachment.getName());
debug.append(" " + attachment.getName());
});
}
catch(Exception e)
Expand All @@ -285,23 +291,25 @@ public void printTurnContext(TurnContext turnContext) {
}

try{
LOGGER.info("Turn Context Properties:");
debug.append("Turn Context Properties:");
turnContext.getActivity().getProperties().forEach((key, value) -> {
LOGGER.info(key + ": " + value.toString());
debug.append(" " + key + ": " + value.toString());
});
}
catch(Exception e)
{

}

try{
LOGGER.info("Turn Context Channel Data:");
LOGGER.info("channel data: "+turnContext.getActivity().getChannelData());
try{
debug.append("Turn Context Channel Data:");
debug.append(" channel data: "+turnContext.getActivity().getChannelData());
}
catch(Exception e)
{

}

return debug.toString();
}
}

0 comments on commit 62d4c73

Please sign in to comment.