Download Jar. Uses 3874K of libraries. Click here for Pure Java version (6599L/47K).
1 | !7 |
2 | |
3 | lib 1400120 lib 1400115 // JTelegramBot |
4 | lib 1400116 lib 1400117 lib 1400118 lib 1400119 // dependencies |
5 | |
6 | import io.fouad.jtb.core.*; |
7 | import io.fouad.jtb.core.beans.*; |
8 | |
9 | p-exp { |
10 | S apiToken = trim(loadTextFileMandatory(javaxSecretDir("telegram-bot-token.txt"))); |
11 | |
12 | UpdateHandler updateHandler = new SimpleUpdateHandler { |
13 | public void onMessageReceived(TelegramBotApi api, int id, Message message) { |
14 | pcall { |
15 | print("Got message!"); |
16 | print("Text:"); |
17 | printIndent("> ", message.getText()); |
18 | User u = message.getFrom(); |
19 | printStruct("From", ll(u.getId(), u.getFirstName(), u.getLastName(), u.getUsername())); |
20 | print(); |
21 | |
22 | api.sendMessage( |
23 | ChatIdentifier.byId(u.getId()), // ChatIdentifier targetChatIdentifier, |
24 | "Hello " + u.getFirstName() + "!", |
25 | null, // ParseMode parseMode, |
26 | null, // Boolean disableLinkPreviews, |
27 | null, // Boolean silentMessage, |
28 | null, // Integer replyToMessageId, |
29 | null); // ReplyMarkup replyMarkup |
30 | } |
31 | } |
32 | }; |
33 | |
34 | JTelegramBot bot = new JTelegramBot("HelloComputer_bot", apiToken, updateHandler); |
35 | bot.startAsync(); |
36 | } |
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: | #1017462 |
Snippet name: | Telegram Bot Spike 1 (answers any direct message with "Hello <name>!", OK with token) |
Eternal ID of this version: | #1017462/17 |
Text MD5: | f5502dcf250cdfc353e32107ca26c618 |
Transpilation MD5: | cefc6837e1589ba77f557661978da3ef |
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:03:59 |
Source code size: | 1209 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 567 / 1220 |
Version history: | 16 change(s) |
Referenced in: | [show references] |