Skip to content

Commit

Permalink
add logs, track variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Yinnii committed Oct 20, 2023
1 parent de52112 commit 0267905
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3286,8 +3286,9 @@ private void performTrigger(BotConfiguration botConfig, ServiceFunction sf, BotA
} else {
response = target.request()
.post(javax.ws.rs.client.Entity.entity(mp, mp.getMediaType()));
System.out.println(response.getStatus());
System.out.println(response.getEntity());
System.out.println("Response Code:" + response.getStatus());
System.out.println("Response Entitiy:" + response.getEntity());
System.out.println("Response Text:" + response.readEntity(String.class));
}

String test = response.readEntity(String.class);
Expand All @@ -3307,6 +3308,7 @@ private void performTrigger(BotConfiguration botConfig, ServiceFunction sf, BotA
JSONObject jsonResponse = (JSONObject) parser.parse(test);
for (String key : jsonResponse.keySet()) {
bot.getMessenger(messengerID).addVariable(channel, key, jsonResponse.getAsString(key));
System.out.println(key);
}
bot.getMessenger(messengerID).setContextToBasic(channel,
userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public Boolean sendMessageToChannel(String channel, String text, String type ) {
* replies to it later on.
*/
public Boolean sendMessageToChannel(String channel, String text, HashMap<String, IncomingMessage> hashMap, String type, IncomingMessage currentMessage) {
System.out.println("SEND MESSAGE TO CHANNEL");
System.out.println("SEND MESSAGE TO CHANNEL:" + text);

return sendMessageToChannel(channel, text, hashMap, type, currentMessage, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,19 @@ public void addVariable(String channel, String key, String value) {
HashMap<String, String> variables = this.getUserVariables().get(channel);
variables.put(key, value);
this.userVariables.put(channel, variables);
System.out.println("Variable set." + key + ":" + value);
}

public String replaceVariables(String channel, String text) {
HashMap<String, String> variables = this.getUserVariables().get(channel);
if (variables != null) {
for (String key : variables.keySet()) {
System.out.println("Replace Variable Key:" + key);
String composed = "[" + key + "]";
text = text.replace(composed, variables.get(key));
}
} else {
System.out.println("Replace Variables are null.");
}
String split[] = text.split("\\[");
for (int i = 1; i < split.length; i++) {
Expand Down

0 comments on commit 0267905

Please sign in to comment.