feat(cmd): add 10grans begging

This commit is contained in:
vulet 2020-05-17 01:31:10 +08:00
parent 867fb0daca
commit 77b0eb12e8
4 changed files with 27 additions and 0 deletions

21
commands/beg.js Normal file
View file

@ -0,0 +1,21 @@
const axios = require('axios');
exports.runQuery = function (matrixClient, room, registrar) {
axios({
method: 'POST',
url: `${registrar.config.fediverse}/api/v1/statuses`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
data: { status: `@10grans@fedi.cc beg` },
}).then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
`<b>
<blockquote><i>You have begged for 10grans.<br>
(id: ${response.data.id}</a>)
</blockquote><br>`);
})
.catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};

View file

@ -8,6 +8,7 @@ exports.runQuery = function (matrixClient, room) {
+ '+copy [post id] : repeat/repost/retweet<br>' + '+copy [post id] : repeat/repost/retweet<br>'
+ '+reply [post id] [content] : reply to post<br>' + '+reply [post id] [content] : reply to post<br>'
+ '+tip [@user@fedi.url] [amount] : tip 10grans' + '+tip [@user@fedi.url] [amount] : tip 10grans'
+ '+beg : beg for 10grans'
+ '+clap [post id] : favorite<br>' + '+clap [post id] : favorite<br>'
+ '+boo [post id] : unfavorite</blockquote>' + '+boo [post id] : unfavorite</blockquote>'
+ '<blockquote><b>channel commands<br>' + '<blockquote><b>channel commands<br>'

View file

@ -47,6 +47,10 @@ let CreateClient = (token) => {
registrar.boo.runQuery(matrixClient, room, userInput, registrar); registrar.boo.runQuery(matrixClient, room, userInput, registrar);
} }
if (command === 'beg') {
registrar.beg.runQuery(matrixClient, room, registrar);
}
if (command === 'clap') { if (command === 'clap') {
registrar.clap.runQuery(matrixClient, room, userInput, registrar); registrar.clap.runQuery(matrixClient, room, userInput, registrar);
} }

View file

@ -1,6 +1,7 @@
module.exports = { module.exports = {
config: require('./config.js'), config: require('./config.js'),
boo: require('./commands/boo.js'), boo: require('./commands/boo.js'),
beg: require('./commands/beg.js'),
clap: require('./commands/clap.js'), clap: require('./commands/clap.js'),
copy: require('./commands/copy.js'), copy: require('./commands/copy.js'),
flood: require('./commands/flood.js'), flood: require('./commands/flood.js'),