Libraryless. Click here for Pure Java version (832L/7K/21K).
!752 static class Msg { // either user (internal user ID) is set or botName S type, user, text, ts; S botName; O reactions; } static S data; static new L<Msg> msgs; // Note: They're in reverse order! static S token; static S channelID = "C0FH9PY8J"; // #talkingbots //static S oldest = "1449245380.000382"; // timestamp of first msg to get static int limit = 10; // get n messages max p { token = loadSecretTextFileMandatory("#1001889", "relp-slack-botstuff-token").trim(); S url = "https://slack.com/api/channels.history"; S postData = "token=" + urlencode(token) + "&channel=" + urlencode(channelID) + /*"&oldest=" + urlencode(oldest) +*/ "&count=" + limit; data = doPost(postData, url); print(data); Map map = cast jsonDecode(data); assertTrue(map.get("ok")); List<Map> _msgs = cast map.get("messages"); msgs = new ArrayList<Msg>(); for (Map msg : _msgs) { new Msg m; m.type = (S) msg.get("type"); m.user = (S) msg.get("user"); m.botName = (S) msg.get("username"); m.text = (S) msg.get("text"); m.ts = (S) msg.get("ts"); m.reactions = msg.get("reactions"); msgs.add(m); print(structure(m)); } print(l(msgs) + " messages sucked from slack channel."); }
Began life as a copy of #1001888
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001904 |
Snippet name: | Try finding bot responses in Slack channel |
Eternal ID of this version: | #1001904/1 |
Text MD5: | e2c70bf059cf00a5f7310ef71775d7ac |
Transpilation MD5: | 69ad52010ad8ce4ab7658133fdcfe465 |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-06 18:45:56 |
Source code size: | 1267 bytes / 40 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 579 / 653 |
Referenced in: | #3000202 - Answer for stefanreich (>> T conversion bot) #3000238 - Answer for stefanreich (>> t power bot) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |