diff --git a/src/message.ts b/src/message.ts index 05c7f86..1c81439 100644 --- a/src/message.ts +++ b/src/message.ts @@ -34,6 +34,10 @@ export default class Message { return this.messageOrNote.renoteId; } + public get visibility(): string { + return this.messageOrNote.visibility; + } + /** * メンション部分を除いたテキスト本文 */ diff --git a/src/modules/reminder/index.ts b/src/modules/reminder/index.ts index 434e943..efdf674 100644 --- a/src/modules/reminder/index.ts +++ b/src/modules/reminder/index.ts @@ -59,9 +59,12 @@ export default class extends Module { const separatorIndex = text.indexOf(' ') > -1 ? text.indexOf(' ') : text.indexOf('\n'); const thing = text.substr(separatorIndex + 1).trim(); - if (thing === '' && msg.quoteId == null) { + if (thing === '' && msg.quoteId == null || msg.visibility === 'followers') { msg.reply(serifs.reminder.invalid); - return true; + return { + reaction: '🆖', + immediate: true, + }; } const remind = this.reminds.insertOne({ @@ -112,12 +115,16 @@ export default class extends Module { const done = msg.includes(['done', 'やった', 'やりました', 'はい']); const cancel = msg.includes(['やめる', 'やめた', 'キャンセル']); + const isOneself = msg.userId === remind.userId; - if (done || cancel) { + if ((done || cancel) && isOneself) { this.unsubscribeReply(key); this.reminds.remove(remind); msg.reply(done ? getSerif(serifs.reminder.done(msg.friend.name)) : serifs.reminder.cancel); return; + } else if (isOneself === false) { + msg.reply(serifs.reminder.doneFromInvalidUser); + return; } else { if (msg.isDm) this.unsubscribeReply(key); return false; @@ -149,7 +156,12 @@ export default class extends Module { text: acct(friend.doc.user) + ' ' + serifs.reminder.notify(friend.name) }); } catch (err) { - // TODO: renote対象が消されていたらリマインダー解除 + // renote対象が消されていたらリマインダー解除 + if (err.statusCode === 400) { + this.unsubscribeReply(remind.thing == null && remind.quoteId ? remind.quoteId : remind.id); + this.reminds.remove(remind); + return; + } return; } } diff --git a/src/serifs.ts b/src/serifs.ts index 7d61ba3..15ae16e 100644 --- a/src/serifs.ts +++ b/src/serifs.ts @@ -339,6 +339,8 @@ export default { reminder: { invalid: 'うーん...?', + doneFromInvalidUser: 'イタズラはめっですよ!', + reminds: 'やること一覧です!', notify: (name) => name ? `${name}、これやりましたか?` : `これやりましたか?`,