feat(cmd): add pin/unpin commands
This commit is contained in:
parent
ee32965255
commit
0aced7e54c
3 changed files with 44 additions and 0 deletions
18
commands/pin.js
Normal file
18
commands/pin.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse}/api/v1/statuses/${userInput}/pin`,
|
||||
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`Pinned:
|
||||
<blockquote>${registrar.config.fediverse}/${userInput}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'', `${e}`);
|
||||
});
|
||||
};
|
18
commands/unpin.js
Normal file
18
commands/unpin.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse}/api/v1/statuses/${userInput}/unpin`,
|
||||
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`Unpinned:
|
||||
<blockquote>${registrar.config.fediverse}/${userInput}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'', `${e}`);
|
||||
});
|
||||
};
|
8
main.js
8
main.js
|
@ -68,6 +68,10 @@ let CreateClient = (token) => {
|
|||
registrar.help.runQuery(matrixClient, room);
|
||||
}
|
||||
|
||||
if (command === 'pin') {
|
||||
registrar.pin.runQuery(matrixClient, room, userInput, registrar);
|
||||
}
|
||||
|
||||
if (command === 'plemara') {
|
||||
registrar.plemara.runQuery(matrixClient, room, userInput, registrar);
|
||||
}
|
||||
|
@ -87,6 +91,10 @@ let CreateClient = (token) => {
|
|||
if (command === 'unfren') {
|
||||
registrar.unfren.runQuery(matrixClient, room, userInput, registrar);
|
||||
}
|
||||
|
||||
if (command === 'unpin') {
|
||||
registrar.unpin.runQuery(matrixClient, room, userInput, registrar);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue