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

84
LINES

< > BotCompany Repo | #1017706 // Baked Bot (auto-generated, don't edit, see #1017703)

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

Download Jar. Libraryless. Click here for Pure Java version (19669L/153K).

!7

sS regexpActivator = "."; // always

!include once #1017764 // VirtualMechLists

sS mechLibID = #1400124;
static O onOutput; // VF1<S>
static bool authorized;
sS msgGlobalID;

static L<AbstractThinkBot> bots;

abstract sclass AbstractThinkBot {
  transient VF1<? super S> postMessage;
  transient new L<Map> recentHistory;

  abstract void thinkAbout(S input);
  
  void postMessage(S s) {
    callF(postMessage, s);
  }
  
  JComponent visualize() {
    ret jpanel();
  }
}

p {
  mech_useLibrary(mechLibID);
  L<Class<? extends AbstractThinkBot>> classes = botClasses();
  print("Have think classes: " + classNames(classes));
  makeBots();
  bot();
}

static L<Class<? extends AbstractThinkBot>> botClasses() {
  ret myNonAbstractClassesImplementing(AbstractThinkBot);
}

svoid makeBots() {
  bots = map nuWithoutArguments(botClasses());
}

sbool telegram_amIAuthorized() {
  ret authorized;
}

svoid setMsgGlobalID(S globalID) {
  msgGlobalID = globalID;
}

sS answer(S s) {
  temp tempSetThreadLocal(telegram_msg_tl(), litorderedmap(globalID := msgGlobalID));
  msgGlobalID = null;
  final new L<S> output;
  for (AbstractThinkBot bot : bots) pcall {
    bot.postMessage = voidfunc(S s) {
      print(">> " + s);
      pcallF(onOutput, s);
      output.add(s);
    };
    bot.thinkAbout(s);
  }
  ret rtrim(lines(output));
}

svoid setDebug(bool b) {
  for (O bot : unnull(bots))
    setOpt(bot, debug := b);
}



please include function dm_reloadMe.

sclass TelegramFactsBot > AbstractThinkBot {
  !include #1018038
  
  visualize {
    ret withCenteredButtons(super.visualize(),
      "Checking Log", r { showText("Checking Log", lines(checkingLog)) });
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017706
Snippet name: Baked Bot (auto-generated, don't edit, see #1017703)
Eternal ID of this version: #1017706/47
Text MD5: b3c8d24ac5d5bb800c1681024f8cebd4
Transpilation MD5: 957363edc155fba5568678114db557cc
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-09 18:43:53
Source code size: 1752 bytes / 84 lines
Pitched / IR pitched: No / No
Views / Downloads: 306 / 8289
Version history: 46 change(s)
Referenced in: [show references]