feat(10grans): add make-it-rain

This commit is contained in:
vulet 2021-02-22 17:48:10 +08:00
parent fcadc5addc
commit 58ef31356a
7 changed files with 60 additions and 3 deletions

View file

@ -141,3 +141,25 @@ module.exports.unfollow = (roomId, account, event, original) => {
matrix.utils.sendError(event, roomId, e);
});
};
module.exports.getStatusMentions = (notice, event, original) => {
const posters = [];
const prefix = '@';
const users = axios({
method: 'GET',
url: `${config.fediverse.domain}/api/v1/statuses/${notice}`,
headers: { Authorization: `Bearer ${fediverse.auth.access_token}` },
}).then((notice) => {
const citizens = [];
citizens.push(notice.data.account.acct);
for (let i = 0; i < notice.data.mentions.length; i++) citizens.push(notice.data.mentions[i].acct);
const filtered = citizens.filter(users => !config.fediverse.username.includes(users))
for (let i = 0; i < filtered.length; i++) posters.push(prefix.concat(filtered[i]));
return posters;
})
.catch((e) => {
matrix.utils.addReact(event, '❌');
matrix.utils.sendError(event, roomId, e);
});
return users;
};