Skip to content

Commit

Permalink
update ignored folders
Browse files Browse the repository at this point in the history
  • Loading branch information
timqian committed Jul 11, 2019
1 parent f65bbff commit 30302ca
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/db.sqlite
/secret.json
/scripts/sampleJsons/

# Logs
logs
Expand Down
4 changes: 2 additions & 2 deletions .upignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!.next
*.md
/bots
/scripts
/bots/
/scripts/
5 changes: 3 additions & 2 deletions bots/slack/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const { WebClient } = require('@slack/web-api');
const { t9tSlackToken } = require('../../secret.json');

// Read a token from the environment variables
const token = 'xoxp-369402001654-508067868801-670441994593-f5c918bc32fb2df2b3439a7c77099fa1';
// https://api.slack.com/apps/AKUAA9XUJ/install-on-team?
const token = t9tSlackToken;

// Initialize
const web = new WebClient(token);
Expand Down
18 changes: 9 additions & 9 deletions scripts/addGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ const Group = require('../db/Group');
// topicCount: 0,
// });

Group.put({
name: 't9tio',
description: 't9t.io slack group',
// logoUrl: 'https://raw.githubusercontent.com/timqian/images/master/20190704172031.jpeg',
type: 'slack',
userCount: 10,
msgCount: 0,
topicCount: 0,
});
// Group.put({
// name: 'Noah iii Ark',
// // description: 'TypeScript 中文群',
// // logoUrl: 'https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/typescript/typescript.png',
// type: 'wechat',
// userCount: 200,
// msgCount: 0,
// topicCount: 0,
// });
4 changes: 2 additions & 2 deletions scripts/batchAddSlackMsgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const chunk = require('lodash.chunk');

async function batchInsertSlackMsgs(msgs) {
// filter out channel_join msgs and thread replies
const validMsgs = msgs.filter(msg => msg.subtype !== 'channel_join' || (msg.thread_ts && !msg.replies));
const validMsgs = msgs.filter(msg => msg.subtype !== 'channel_join');

const msgsArr = chunk(validMsgs, 25);

for (let i = msgsArr.length - 1; i >= 0; i -= 1) {
console.log(msgsArr[i], 'msgs')
console.log(msgsArr[i], 'msgs');
await batchAddSlackMsgs({
groupName: 't9tio',
msgs: msgsArr[i],
Expand Down
24 changes: 24 additions & 0 deletions scripts/batchAddSlackTopics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const abc = require('./abc.json');
const { add } = require('../db/Topics');

async function batchInsertSlackMsgs(msgs) {
// filter out channel_join msgs and thread replies
const validMsgs = msgs.filter(msg => msg.thread_ts && msg.replies);


// reverse order
for (let i = validMsgs.length - 1; i >= 0; i -= 1) {
const msg = validMsgs[i];
console.log(msg, 'msg');
await add({
groupName: 't9tio',
title: msg.text,
type: 'slack',
ts: msg.ts,
from: msg.user,
date: Number(msg.ts.split('.')[0]) * 1000,
});
}
}

batchInsertSlackMsgs(abc.messages);

0 comments on commit 30302ca

Please sign in to comment.