feat(cmd): Add Mordekai
This commit is contained in:
parent
173ecf9103
commit
e95cefafb9
4 changed files with 34 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
|||
# Patches
|
||||
*.patch
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
|
26
commands/mordy.js
Normal file
26
commands/mordy.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
|
||||
data: {
|
||||
status: `@mordekai ${userInput}`,
|
||||
content_type: `text/markdown`,
|
||||
visibility: 'unlisted',
|
||||
expires_in: '7200'
|
||||
},
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b>
|
||||
<blockquote><i>${response.data.content}<br>
|
||||
(id: ${response.data.id}</a>)
|
||||
</blockquote><br>`);
|
||||
})
|
||||
.catch((e) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'', `${e}`);
|
||||
});
|
||||
};
|
4
main.js
4
main.js
|
@ -102,6 +102,10 @@ let CreateClient = (token) => {
|
|||
if (command === 'unpin') {
|
||||
registrar.unpin.runQuery(matrixClient, room, userInput, registrar);
|
||||
}
|
||||
|
||||
if (command === 'mordy') {
|
||||
registrar.mordy.runQuery(matrixClient, room, userInput, registrar);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -15,4 +15,5 @@ module.exports = {
|
|||
tip: require('./commands/tip.js'),
|
||||
unfren: require('./commands/unfren.js'),
|
||||
unpin: require('./commands/unpin.js'),
|
||||
mordy: require('./commands/mordy.js'),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue