mirror of
https://github.com/System-End/slack-end.git
synced 2026-04-19 18:35:19 +00:00
feat: the thing pcb??
This commit is contained in:
parent
008060a394
commit
fa7748471f
3 changed files with 80 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ app.dbs.anondm = new EncryptedJsonDb("data/anondm.json", {
|
|||
app.dbs.mykcd = new JSONdb("data/mykcd.json");
|
||||
app.dbs.tags = new JSONdb("data/tags.json");
|
||||
app.dbs.stickymessages = new JSONdb("data/stickymessages.json");
|
||||
app.dbs.thething = new JSONdb("data/the-thing-hc.json")
|
||||
console.debug(`Dbs loaded`);
|
||||
console.timeEnd(`Loading db's`);
|
||||
app.db = db;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import { cronJobForRPG } from "./rpgysws";
|
|||
import { onLoadForLockIn } from "./lockinysws";
|
||||
import { setupFlightlyCron } from "./flightly";
|
||||
import { cronJobForAvatar } from "./alaskasavatar";
|
||||
import { cronTS } from "./thething";
|
||||
// import { onLoad } from "./lockinysws";
|
||||
const cronWithCheckIn = Sentry.cron.instrumentNodeCron(cron);
|
||||
|
||||
|
|
@ -281,6 +282,7 @@ export function setupOverallCron(app: ModifiedApp) {
|
|||
onLoadForLockIn(app);
|
||||
setupFlightlyCron(app);
|
||||
cronJobForAvatar();
|
||||
cronTS(app)
|
||||
return {
|
||||
// checkAirtableBoba,
|
||||
cronWithCheckIn,
|
||||
|
|
|
|||
77
src/modules/thething.ts
Normal file
77
src/modules/thething.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import crypto from 'crypto';
|
||||
import { ModifiedApp } from "./slackapp";
|
||||
|
||||
|
||||
export interface RootInterface {
|
||||
'Slack ID': string;
|
||||
'GitHub username': string;
|
||||
'Schedule match': boolean;
|
||||
'Can stream'?: boolean;
|
||||
'Planning on adding...'?: string;
|
||||
'Display name': string;
|
||||
'Avatar URL': string;
|
||||
}
|
||||
|
||||
function sha256OfJson(obj: any): string {
|
||||
const json = JSON.stringify(obj, Object.keys(obj).sort()); // sort keys
|
||||
return crypto.createHash('sha256').update(json).digest('hex');
|
||||
}
|
||||
|
||||
export async function cronThingy(app: ModifiedApp) {
|
||||
const object = await fetch("https://thing.hackclub.com/queue").then(r => r.json()).then(d => d as RootInterface[])
|
||||
for (const obj of object) {
|
||||
const objHash = sha256OfJson(obj)
|
||||
if (app.dbs.thething.get(objHash)) continue;
|
||||
|
||||
app.client.chat.postMessage({
|
||||
"blocks": [
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": `:wave:\n*<https://github.com/${obj['GitHub username']}|${obj['Display name']}>*`
|
||||
},
|
||||
"accessory": {
|
||||
"type": "image",
|
||||
"image_url": obj['Avatar URL'],
|
||||
"alt_text": obj['Display name']
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "context",
|
||||
"elements": [
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": `:slack: *Slack ID:* \`${obj['Slack ID']}\``
|
||||
},
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": `:calendar: *Schedule match:* ${obj['Schedule match']}`
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "context",
|
||||
"elements": [
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": `:video_camera: *Can stream:* ${obj['Can stream']}`
|
||||
},
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": `:bulb: *Planning to add:* _${obj['Planning on adding...']}..._`
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
channel: `C08MFTG96BH`
|
||||
})
|
||||
app.dbs.thething.set(objHash, true)
|
||||
await new Promise(r=>setTimeout(r,250))
|
||||
}
|
||||
}
|
||||
export async function cronTS(app: ModifiedApp) {
|
||||
await cronThingy(app);
|
||||
await new Promise(r => setTimeout(r, 60 * 1000))
|
||||
await cronTS(app)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue