feat(fedi): add status query
This commit is contained in:
parent
38ca35bdd4
commit
6fe3c992e7
3 changed files with 28 additions and 3 deletions
19
commands/status.js
Normal file
19
commands/status.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const axios = require('axios');
|
||||||
|
|
||||||
|
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||||
|
axios({
|
||||||
|
method: 'GET',
|
||||||
|
url: `${registrar.config.fediverse.domain}/api/v1/statuses/${userInput}`,
|
||||||
|
headers: { Authorization: `Bearer ${registrar.config.fediverse.token}` },
|
||||||
|
}).then((response) => {
|
||||||
|
matrixClient.sendHtmlNotice(room.roomId,
|
||||||
|
'',
|
||||||
|
`<b><a href="${registrar.config.fediverse.domain}/notice/${response.data.id}">${response.data.account.acct}</a>
|
||||||
|
<blockquote><i>${response.data.content}<br>
|
||||||
|
${response.data.media_attachments.map(media =>
|
||||||
|
`<a href="${media.remote_url}"><b>${media.description}</b></a>`)
|
||||||
|
.join('<br>')}
|
||||||
|
(id: ${response.data.id}</a>)
|
||||||
|
</blockquote>`);
|
||||||
|
});
|
||||||
|
};
|
5
main.js
5
main.js
|
@ -131,6 +131,11 @@ let CreateClient = (token, user_id) => {
|
||||||
if (command === 'media') {
|
if (command === 'media') {
|
||||||
registrar.media.runQuery(matrixClient, room, userInput, registrar);
|
registrar.media.runQuery(matrixClient, room, userInput, registrar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command === 'status') {
|
||||||
|
registar.status.runQuery(matrixClient, room, userInput, registrar);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ module.exports = {
|
||||||
copy: require('./commands/copy.js'),
|
copy: require('./commands/copy.js'),
|
||||||
flood: require('./commands/flood.js'),
|
flood: require('./commands/flood.js'),
|
||||||
fren: require('./commands/fren.js'),
|
fren: require('./commands/fren.js'),
|
||||||
help: require('./commands/help.js'),
|
help: require('./commands/help.js'),
|
||||||
pin: require('./commands/pin.js'),
|
pin: require('./commands/pin.js'),
|
||||||
plemara: require('./commands/plemara.js'),
|
plemara: require('./commands/plemara.js'),
|
||||||
redact: require('./commands/redact.js'),
|
redact: require('./commands/redact.js'),
|
||||||
notify: require('./commands/notify.js'),
|
notify: require('./commands/notify.js'),
|
||||||
|
@ -19,5 +19,6 @@ module.exports = {
|
||||||
archive: require('./commands/archive.js'),
|
archive: require('./commands/archive.js'),
|
||||||
nitter: require('./commands/nitter.js'),
|
nitter: require('./commands/nitter.js'),
|
||||||
invidious: require('./commands/invidious.js'),
|
invidious: require('./commands/invidious.js'),
|
||||||
media: require('./commands/media.js')
|
media: require('./commands/media.js'),
|
||||||
|
status: require('./commands/status.js')
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue