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)

static S botAutoHelp() {
  ret "Commands: " + join(" ", botAutoHelp_commands());
}

// crude interception possibility if you override botAutoHelp_commands
// until JavaX supports replacing functions
static L<S> _botAutoHelp_commands() {
  new L<S> cmds;
  L<S> tok = javaTokMe();
  for (S pat : toLinesFullTrim([[
    startsWith(s, <quoted>
    startsWithWord(s, <quoted>,
    eq(s, <quoted>)
  ]]))
    for (int i : jfindAll(tok, pat))
      cmds.add(trim(unquote(tok.get(i+8))));
  ret cmds;
}

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: 420 / 454
Version history: 5 change(s)
Referenced in: [show references]