Download Jar. Uses 3874K of libraries. Click here for Pure Java version (6616L/47K).
!7 lib 1400120 lib 1400115 // JTelegramBot lib 1400116 lib 1400117 lib 1400118 lib 1400119 // dependencies import io.fouad.jtb.core.*; import io.fouad.jtb.core.enums.*; import io.fouad.jtb.core.beans.*; import io.fouad.jtb.core.builders.*; p-exp { S apiToken = trim(loadTextFileMandatory(javaxSecretDir("telegram-bot-token.txt"))); UpdateHandler updateHandler = new SimpleUpdateHandler { public void onMessageReceived(TelegramBotApi api, int _id, Message message) { pcall { print("Got message!"); print("Text:"); printIndent("> ", message.getText()); User u = message.getFrom(); printStruct("From", ll(u.getId(), u.getFirstName(), u.getLastName(), u.getUsername())); print(); ChatIdentifier id = ChatIdentifier.byId(u.getId()); api.sendChatAction(id, ChatAction.TYPING); sleepSeconds(3); api.sendMessage( id, // ChatIdentifier targetChatIdentifier, "Hello " + u.getFirstName() + "!", null, // ParseMode parseMode, null, // Boolean disableLinkPreviews, null, // Boolean silentMessage, null, // Integer replyToMessageId, null); // ReplyMarkup replyMarkup } } }; JTelegramBot bot = new JTelegramBot("HelloComputer_bot", apiToken, updateHandler); bot.startAsync(); long chatID = -1001303287441L; print("Chat: " + ApiBuilder.api(bot).getChat() //.byChatUsername("Hello_Computer") .byChatId(chatID) .execute()); bot.sendMessage(ChatIdentifier.byId(chatID), "Hello channel", null, null, null, null, null); }
Began life as a copy of #1017464
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: | #1017465 |
Snippet name: | Telegram Bot Spike 4 (send msg to channel, OK) |
Eternal ID of this version: | #1017465/5 |
Text MD5: | e6bf21472154b26aa0ca1e74f929bb87 |
Transpilation MD5: | 91d3b5ea95239bfb344a480edcec5d40 |
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-23 14:48:44 |
Source code size: | 1681 bytes / 51 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 471 / 1007 |
Version history: | 4 change(s) |
Referenced in: | #1017466 - Telegram Bot Spike 5 (new library, OK) |