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

25
LINES

< > BotCompany Repo | #1002468 // Last Dialogs Bot

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (818L/6K/19K).

1  
!752
2  
3  
static int maxQuestionLength = 150;
4  
static int maxAnswerLength = 450;
5  
6  
answer {
7  
  if "last dialogs" s = "5 last dialogs";
8  
  if "last dialog" s = "1 last dialogs";
9  
  if "* last dialogs" {
10  
    int n = parseInt(m.unq(0));
11  
    
12  
    L history = cast get(getMainBot(), "history");
13  
    new StringBuffer buf;
14  
    
15  
    int x = max(l(history)-n, 0);
16  
    for (int i = l(history)-1; i >= x; i--) {
17  
      O dialog = history.get(i);
18  
      S q = shorten(getString(dialog, "question"), maxQuestionLength);
19  
      S a = shorten(getString(dialog, "answer"), maxAnswerLength);
20  
      buf.append("User: " + q + "\n");
21  
      buf.append("Eleutheria: " + a + "\n");
22  
    }
23  
    ret slackSnippet(buf);
24  
  }
25  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002468
Snippet name: Last Dialogs Bot
Eternal ID of this version: #1002468/1
Text MD5: f5b3f9fdcc973d6605487f04910fa960
Transpilation MD5: c98ee9f2bb8bc2ce1e253bbfc5cca263
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-25 01:32:30
Source code size: 709 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 797 / 1253
Referenced in: [show references]