Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1029983 // gazelle_mathBot1_handlePost

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4248L/28K).

1  
svoid gazelle_mathBot1_handlePost(S _user, S _botToken, Map post) {
2  
  Number postID = cast post.get("id");
3  
  S text = cast post.get("text");
4  
  LS groups = regexpGroupsIC("What is (\\d+)\\s*\\+\\s*(\\d+)", text);
5  
  if (empty(groups)) ret;
6  
  print("Processing post " + postID + ": " + quote(text));
7  
  BigInt result = plus(parseBigInt(first(groups)), parseBigInt(second(groups)));
8  
  print("Calculated result: " + result);
9  
  print(postJSONPage("https://gazelle.rocks/bot/createPost",
10  
    +_user, +_botToken, refs := postID, text := "The result is " + result, type := "Answer", botInfo := "Math bot"));
11  
}

Author comment

Began life as a copy of #1029982

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1029983
Snippet name: gazelle_mathBot1_handlePost
Eternal ID of this version: #1029983/1
Text MD5: 91889df0dbe09cf25105f5be268b1a4d
Transpilation MD5: 66dcb1dda7527f4e10d258e8a7c8543c
Author: stefan
Category: javax / gazelle.rocks
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-10-27 08:45:10
Source code size: 609 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 154 / 217
Referenced in: [show references]