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

18
LINES

< > BotCompany Repo | #1008058 // botAutoHelp - make an effort to parse current source and extract commands

JavaX fragment (include)

1  
static S botAutoHelp() {
2  
  ret "Commands: " + join(" ", botAutoHelp_commands());
3  
}
4  
5  
// crude interception possibility if you override botAutoHelp_commands
6  
// until JavaX supports replacing functions
7  
static L<S> _botAutoHelp_commands() {
8  
  new L<S> cmds;
9  
  L<S> tok = javaTokMe();
10  
  for (S pat : toLinesFullTrim([[
11  
    startsWith(s, <quoted>
12  
    startsWithWord(s, <quoted>,
13  
    eq(s, <quoted>)
14  
  ]]))
15  
    for (int i : jfindAll(tok, pat))
16  
      cmds.add(trim(unquote(tok.get(i+8))));
17  
  ret cmds;
18  
}

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: #1008058
Snippet name: botAutoHelp - make an effort to parse current source and extract commands
Eternal ID of this version: #1008058/6
Text MD5: f270d8fe137196888e20f67e71423938
Author: stefan
Category: javax / slack bots
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-27 14:37:32
Source code size: 512 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 423 / 457
Version history: 5 change(s)
Referenced in: [show references]