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

34
LINES

< > BotCompany Repo | #1001329 // sendToLocalBot

JavaX fragment (include)

1  
static S sendToLocalBot(S bot, S text, O... args) {
2  
  text = format3(text, args);
3  
  
4  
  temp DialogIO channel = findBot(bot);
5  
  if (channel == null)
6  
    fail(quote(bot) + " not found");
7  
  try {
8  
    channel.readLine();
9  
    print(bot + "> " + shorten(text, 80));
10  
    channel.sendLine(text);
11  
    S s = channel.readLine();
12  
    print(bot + "< " + shorten(s, 80));
13  
    return s;
14  
  } catch (Throwable e) {
15  
    e.printStackTrace();
16  
    return null;
17  
  }
18  
}
19  
20  
static S sendToLocalBot(int port, S text, O... args) {
21  
  text = format3(text, args);
22  
  temp DialogIO channel = talkTo(port);
23  
  try {
24  
    channel.readLine();
25  
    print(port + "> " + shorten(text, 80));
26  
    channel.sendLine(text);
27  
    S s = channel.readLine();
28  
    print(port + "< " + shorten(s, 80));
29  
    return s;
30  
  } catch (Throwable e) {
31  
    e.printStackTrace();
32  
    return null;
33  
  }
34  
}

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: 688 / 2685
Version history: 1 change(s)
Referenced in: [show references]