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

31
LINES

< > BotCompany Repo | #1017513 // Just-Logging Telegram Bot

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

Download Jar. Uses 12378K of libraries. Click here for Pure Java version (2614L/18K).

1  
!7
2  
3  
!include once #1017511 // Telegram Bots
4  
5  
p {
6  
  fS apiToken = telegramBotToken_mandatory();
7  
8  
  ApiContextInitializer.init();
9  
  TelegramLongPollingBot bot = new TelegramLongPollingBot {
10  
    public S getBotUsername() { ret "HelloComputer_bot"; }
11  
    public S getBotToken() { ret apiToken; }
12  
    
13  
    public void onUpdateReceived(Update update) {
14  
      pcall {
15  
        print("Got update! " + update);
16  
        Message msg = update.getMessage(); //update.getChannelPost();
17  
        logQuotedWithDate(telegramFullUpdatesLogFile(), str(update));
18  
        if (msg != null && msg.hasText()) {
19  
          S text = msg.getText();
20  
          print("Incoming text: " + text);
21  
          logStructure(telegramLogFile(), litorderedmap(
22  
            type := 'heard,
23  
            date := localDateWithMilliseconds(),
24  
            +text));
25  
        }
26  
      }
27  
    }
28  
  };
29  
30  
  new TelegramBotsApi().registerBot(bot);
31  
}

Author comment

Began life as a copy of #1017505

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: #1017513
Snippet name: Just-Logging Telegram Bot
Eternal ID of this version: #1017513/3
Text MD5: 807f925ca0399a4b3c3cb2c4592678af
Transpilation MD5: 6c6cc830887ee382752309e6c14bb029
Author: stefan
Category: javax / networking
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-25 11:18:37
Source code size: 920 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 270 / 691
Version history: 2 change(s)
Referenced in: [show references]