Download Jar. Uses 12378K of libraries. Click here for Pure Java version (9978L/71K).
!7 !include once #1017511 // Telegram Bots p { fS apiToken = telegramBotToken_mandatory(); botInit(); 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)); S response; try { response = makeResponse(text, msg); } catch e { printStackTrace(e); response = exceptionToStringShort(e); } response = rtrim(response); if (empty(response)) ret; Chat chat = msg.getChat(); logStructure(telegramLogFile(), litorderedmap( type := 'sent, date := localDateWithMilliseconds(), toChatID := msg.getChatId(), text := response)); new SendMessage sending; sending.setText(response); sending.setChatId(msg.getChatId()); sendMessage(sending); } } } }; new TelegramBotsApi api; api.registerBot(bot); } static S makeResponse(fS s, Message msg) { if (eqic(s, "whoami")) { User from = msg.getFrom(); if (from == null) ret "idk"; ret msg.getFrom().getId() + " / " + msg.getFrom().getUserName(); } if (eqic(s, "fullmsg")) ret str(msg); //ret "You typed " + n2(l(s), "character"); ret lines(map tok_dropAllCurlyBrackets(pnlEmits(r { ai_askForUnknownWordTypes(s) }))); } svoid botInit { dm_useLocallyCopiedMechLists(); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017505 |
Snippet name: | Telegram Bot asking for word types (older) |
Eternal ID of this version: | #1017505/14 |
Text MD5: | 30f24c989c9caa73dec9d656e1dc53f9 |
Transpilation MD5: | f47847e9f691877f9f56eb513237e415 |
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:58:54 |
Source code size: | 2130 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 496 / 1166 |
Version history: | 13 change(s) |
Referenced in: | #1017513 - Just-Logging Telegram Bot |