リマインド機能の改善 (#93)

* [reminder]renote対象が消されていた場合にリマインダー解除を行う機能の追加

* [reminder]visibilityがfollowersのときにtodoを受け付けないようにした

* #70(他人のリマインダーを操作できる)対応

* セリフのベタ書きではなく、serifsに追加するような形にした。

* Fix[Reminder]RN対象の削除がなされていた場合へ入る条件分岐の修正
This commit is contained in:
na2na 2022-05-01 23:36:00 +09:00 committed by GitHub
parent bc2c7f0581
commit 5cd9e171da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View File

@ -34,6 +34,10 @@ export default class Message {
return this.messageOrNote.renoteId;
}
public get visibility(): string {
return this.messageOrNote.visibility;
}
/**
*
*/

View File

@ -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;
}
}

View File

@ -339,6 +339,8 @@ export default {
reminder: {
invalid: 'うーん...',
doneFromInvalidUser: 'イタズラはめっですよ!',
reminds: 'やること一覧です!',
notify: (name) => name ? `${name}、これやりましたか?` : `これやりましたか?`,