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).

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

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: 148 / 209
Referenced in: [show references]