Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
[chore] Upgrade dependencies (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-se authored Jul 30, 2021
1 parent 4dd35cd commit ed16d8b
Show file tree
Hide file tree
Showing 3 changed files with 1,214 additions and 945 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
"postinstall": "mkdir -p build && cp appsscript.json build/appsscript.json"
},
"dependencies": {
"@hi-se/web-api": "https://gitpkg.now.sh/hi-se/node-slack-sdk/packages/web-api?d6102cf8c48b6494d4afc4c01977e5235292c0eb",
"@slack/bolt": "^3.3.0",
"@hi-se/web-api": "https://gitpkg.now.sh/hi-se/node-slack-sdk/packages/web-api?ab078b145617d511327a8f74fe34f1d4695ff893",
"@slack/bolt": "^3.5.0",
"moment": "^2.29.1"
},
"devDependencies": {
"@google/clasp": "^2.3.2",
"@types/google-apps-script": "^1.0.29",
"gas-webpack-plugin": "^2.0.0",
"ts-loader": "^8.0.18",
"tslib": "^2.1.0",
"typescript": "^4.2.3",
"webpack": "5.25.0",
"webpack-cli": "4.5.0",
"@google/clasp": "^2.4.0",
"@types/google-apps-script": "^1.0.37",
"gas-webpack-plugin": "^2.1.0",
"ts-loader": "^9.2.4",
"tslib": "^2.3.0",
"typescript": "^4.3.5",
"webpack": "5.47.1",
"webpack-cli": "4.7.2",
"webpack-dev-server": "3.11.2"
}
}
20 changes: 9 additions & 11 deletions src/shujinosuke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ const sendReminderForJoin = async () => {
const client = getSlackClient();
const sessionChannelId = getSessionChannelId();
const channelState = getChannelState(sessionChannelId);
const channelMembers = (await client.conversations.members({
const channelMembers = client.conversations.members({
channel: sessionChannelId
})).members.filter(userId => !exceptions.includes(userId));
}).members.filter(userId => !exceptions.includes(userId));
const remindTargets = channelMembers.filter(userId => {
return (
!channelState.done.includes(userId) &&
!channelState.waiting.includes(userId)
)
});
remindTargets.forEach(async (remindTarget) => {
if ((await client.users.getPresence({ user: remindTarget })).presence === 'active') {
if (client.users.getPresence({ user: remindTarget }).presence === 'active') {
client.chat.postEphemeral({
channel: sessionChannelId,
user: remindTarget,
Expand Down Expand Up @@ -353,25 +353,23 @@ const getChannelStateMessage = (channelId: string) => {
const getListen = (client: SlackClient, event: SlackEvent) => {
switch (event.type) {
case 'app_mention':
return (regExp: RegExp, callback: (client: SlackClient, event: GenericMessageEvent) => void) => {
return (regExp: RegExp, callback: (client: SlackClient, event: AppMentionEvent) => void) => {
const messageContent = event.text.replace(/^<@\w+>\s*/, '');
if (messageContent.match(regExp)) {
callback(client, event as unknown as GenericMessageEvent);
callback(client, event as AppMentionEvent);
}
}
}
}
const getThreadTs = (event: GenericMessageEvent | AppMentionEvent) => {
const getThreadTs = (event: AppMentionEvent) => {
return event.thread_ts ? event.thread_ts : event.ts;
}


const handleSlackEvent = (client: SlackClient, event: SlackEvent) => {
switch (event.type) {
case 'app_mention':
// 公式が提供しているAppMentionEvent型では足りないプロパティがあるためGenericMessageEvent型を利用している
// see https://github.com/siiibo/shujinosuke/pull/16#discussion_r642349045
handleAppMention(client, event as unknown as GenericMessageEvent);
handleAppMention(client, event as AppMentionEvent);
break;
case 'message':
handleMessageEvent(client, event as GenericMessageEvent);
Expand All @@ -395,7 +393,7 @@ const handleMessageEvent = (client: SlackClient, event: GenericMessageEvent) =>
}


const handleAppMention = (slackClient: SlackClient, appMentionEvent: GenericMessageEvent) => {
const handleAppMention = (slackClient: SlackClient, appMentionEvent: AppMentionEvent) => {
const listen = getListen(slackClient, appMentionEvent);

listen(/^開始$/, (client, event) => {
Expand Down Expand Up @@ -551,7 +549,7 @@ const handleEmojiChange = (client: SlackClient, event: EmojiChangedEvent) => {
}
}

const handleChannelCreated = (client: SlackClient, event: ChannelCreatedEvent)=>{
const handleChannelCreated = (client: SlackClient, event: ChannelCreatedEvent) => {
client.chat.postMessage({
channel: CHANNEL_EVENT_POST_CHANNEL,
text: `<#${event.channel.id}>が追加されました!`
Expand Down
Loading

0 comments on commit ed16d8b

Please sign in to comment.