Created
February 26, 2020 10:59
-
-
Save kaz/7d31724e3819b1ba60a2e3c31afaed9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const {WebClient} = require("@slack/web-api"); | |
const fs = require("fs").promises; | |
const web = new WebClient("xoxp-XXXXXXXXXXXXXX"); | |
(async () => { | |
while(true){ | |
const cursor = JSON.parse(await fs.readFile("cursor.json").catch(() => "null")); | |
const data = JSON.parse(await fs.readFile("data.json").catch(() => "[]")); | |
console.log(data.length, cursor); | |
const res = await web.conversations.history({ | |
channel: "CXXXXXXXXXXXXX", | |
limit: 1000, | |
cursor, | |
}); | |
await fs.writeFile("cursor.json", JSON.stringify(res.response_metadata.next_cursor)); | |
await fs.writeFile("data.json", JSON.stringify(data.concat(res.messages))); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const result = {}; | |
require("./data.json").forEach(msg => { | |
if(!msg.user){ | |
return; | |
} | |
msg.text.replace(/github\.com\/([-\w]+\/[-\w]+)/, (_, key) => { | |
if(!(key in result)){ | |
result[key] = 0; | |
} | |
++result[key]; | |
}); | |
}); | |
Object.entries(result).sort(([, c1], [, c2]) => c2 - c1).forEach(([key, count]) => console.log(count, key)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment