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).

!7

!include once #1017511 // Telegram Bots

p {
  fS apiToken = telegramBotToken_mandatory();

  ApiContextInitializer.init();
  TelegramLongPollingBot bot = new TelegramLongPollingBot {
    public S getBotUsername() { ret "HelloComputer_bot"; }
    public S getBotToken() { ret apiToken; }
    
    public void onUpdateReceived(Update update) {
      pcall {
        print("Got update! " + update);
        Message msg = update.getMessage(); //update.getChannelPost();
        logQuotedWithDate(telegramFullUpdatesLogFile(), str(update));
        if (msg != null && msg.hasText()) {
          S text = msg.getText();
          print("Incoming text: " + text);
          logStructure(telegramLogFile(), litorderedmap(
            type := 'heard,
            date := localDateWithMilliseconds(),
            +text));
        }
      }
    }
  };

  new TelegramBotsApi().registerBot(bot);
}

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: 259 / 679
Version history: 2 change(s)
Referenced in: [show references]