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

84
LINES

< > BotCompany Repo | #1018381 // Baked Bot, new version (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 (19755L/154K).

!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 #1018379
  
  visualize {
    ret withCenteredButtons(super.visualize(),
      "Checking Log", r { showText("Checking Log", lines(checkingLog)) });
  }
}

Author comment

Began life as a copy of #1017706

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018381
Snippet name: Baked Bot, new version (auto-generated, don't edit, see #1017703)
Eternal ID of this version: #1018381/3
Text MD5: a986685e806c4d358639d343aca9bfd8
Transpilation MD5: 35d4577b066895a4b0c957b228411300
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-23 17:08:00
Source code size: 1752 bytes / 84 lines
Pitched / IR pitched: No / No
Views / Downloads: 378 / 1404
Version history: 2 change(s)
Referenced in: [show references]