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

34
LINES

< > BotCompany Repo | #1001329 // sendToLocalBot

JavaX fragment (include)

static S sendToLocalBot(S bot, S text, O... args) {
  text = format3(text, args);
  
  temp DialogIO channel = findBot(bot);
  if (channel == null)
    fail(quote(bot) + " not found");
  try {
    channel.readLine();
    print(bot + "> " + shorten(text, 80));
    channel.sendLine(text);
    S s = channel.readLine();
    print(bot + "< " + shorten(s, 80));
    return s;
  } catch (Throwable e) {
    e.printStackTrace();
    return null;
  }
}

static S sendToLocalBot(int port, S text, O... args) {
  text = format3(text, args);
  temp DialogIO channel = talkTo(port);
  try {
    channel.readLine();
    print(port + "> " + shorten(text, 80));
    channel.sendLine(text);
    S s = channel.readLine();
    print(port + "< " + shorten(s, 80));
    return s;
  } catch (Throwable e) {
    e.printStackTrace();
    return null;
  }
}

Author comment

Began life as a copy of #1001322

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001329
Snippet name: sendToLocalBot
Eternal ID of this version: #1001329/2
Text MD5: 55434c7ddefca602d19bdf0751e5252d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-13 22:39:21
Source code size: 867 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 689 / 2686
Version history: 1 change(s)
Referenced in: #1001781 - sendToBotQuietly
#1002427 - Accellerating 629 (SPIKE)
#1003867 - sendToLocal - synonym of sendToLocalBot
#1004421 - sendToLocalBotQuietly
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)