Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

goodbye_chatworkから出力されるexportsのcsvフィールドが変わっているようなので修正 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ const ChatWorkToSlack = require('./chatwork-to-slack');
const cwUsers = require('./cw_users');
const cwUserNameMap = {};
const cwUserAccountMap = {};
const cwUserNameAccountMap = {};
cwUsers.forEach((user) => {
cwUserNameMap[ user.id ] = user.name;
cwUserAccountMap[ user.id ] = user.account.toLowerCase();
cwUserNameAccountMap[ user.name ] = user.account.toLowerCase();
});

const converter = new ChatWorkToSlack(cwUserNameMap, cwUserAccountMap);

const parseCSV = (data) => {
return pify(parse)(data, {
columns: [
'timestamp', 'name', 'account', 'id', 'message'
'timestamp', 'name', 'message'
]
});
};
Expand All @@ -39,7 +41,7 @@ glob('./exports/*.csv')
.map((chat) => {
chat.message = converter.convert(chat.message);
chat.timestamp = Number(new Date(chat.timestamp)) / 1000;
chat.account = cwUserAccountMap[chat.id] || `cw_${chat.id}`;
chat.account = cwUserNameAccountMap[chat.name] || `cw_${chat.name}`;
return chat;
})
.filter((chat) => chat.message);
Expand Down