feat(cmd): add 10grans ez-tip && fix(cmd): media attachment && style(cmd): default format: markdown
This commit is contained in:
parent
831179b337
commit
56ce1ccd5e
9 changed files with 44 additions and 11 deletions
|
@ -16,8 +16,11 @@ exports.runQuery = function (matrixClient, room, registrar) {
|
|||
'',
|
||||
`<b><a href="${registrar.config.fediverse}/notice/${events.data[0].id}">${events.data[0].account.acct}</a>
|
||||
<blockquote><i>${events.data[0].content}<br>
|
||||
${events.data[0].media_attachments.map(media =>
|
||||
`<a href="${media.remote_url}">`+`${media.description}`+'</a>'
|
||||
).join('<br>')}
|
||||
(id: ${events.data[0].id}</a>)
|
||||
</blockquote><br>`);
|
||||
</blockquote>`);
|
||||
} else {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
|
@ -26,8 +29,11 @@ exports.runQuery = function (matrixClient, room, registrar) {
|
|||
<font color="#7886D7">has <a href="${registrar.config.fediverse}/notice/${events.data[0].id}">repeated</a>:
|
||||
<blockquote><a href="${events.data[0].reblog.account.url}">${events.data[0].reblog.account.acct}</a></blockquote>
|
||||
<blockquote>${events.data[0].content}<br>
|
||||
(id: ${events.data[0].id})
|
||||
</blockquote><br>`);
|
||||
${events.data[0].media_attachments.map(media =>
|
||||
`<a href="${media.remote_url}">`+`Proxied image, no description available.`+'</a>'
|
||||
).join('<br>')}
|
||||
<br>(id: ${events.data[0].id})
|
||||
</blockquote>`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ exports.runQuery = function (matrixClient, room, registrar) {
|
|||
'',
|
||||
`<hr><b><a href="${registrar.config.fediverse}/${notifications.data[0].account.id}">
|
||||
${notifications.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">favorited</a>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">favorited</a>
|
||||
your post:</b></font>
|
||||
<br><i><b>${notifications.data[0].status.content}</i></b><hr>`);
|
||||
} else if (notifications.data[0].type === 'mention') {
|
||||
|
@ -32,16 +32,16 @@ exports.runQuery = function (matrixClient, room, registrar) {
|
|||
'',
|
||||
`<hr><b><a href="${registrar.config.fediverse}/${notifications.data[0].account.id}">
|
||||
${notifications.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">mentioned</a>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">mentioned</a>
|
||||
you:</b></font><br>
|
||||
<i><b>${notifications.data[0].status.content}</i></b>
|
||||
<br>[id: ${notifications.data[0].status.id}]</i></b><hr>`);
|
||||
<br>(id: ${notifications.data[0].status.id})</i></b><hr>`);
|
||||
} else if (notifications.data[0].type === 'reblog') {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<hr><b><a href="${registrar.config.fediverse}/${notifications.data[0].account.id}">
|
||||
${notifications.data[0].account.acct}</a></b>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">repeated</a>
|
||||
<font color="#03b381"><b>has <a href="${notifications.data[0].status.uri}">repeated</a>
|
||||
your post:</b></font><br>
|
||||
<i><b>${notifications.data[0].status.content}</i></b><hr>`);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ exports.runQuery = function (matrixClient, room, userInput, registrar) {
|
|||
method: 'POST',
|
||||
url: `${registrar.config.fediverse}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
|
||||
data: { status: userInput },
|
||||
data: { status: userInput, content_type: `text/markdown` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
|
|
|
@ -5,7 +5,7 @@ exports.runQuery = function (matrixClient, room, address, flaggedInput, registra
|
|||
method: 'POST',
|
||||
url: `${registrar.config.fediverse}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
|
||||
data: { status: flaggedInput, in_reply_to_id: address },
|
||||
data: { status: flaggedInput, in_reply_to_id: address, content_type: `text/markdown` },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
|
|
21
commands/tip.js
Normal file
21
commands/tip.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const axios = require('axios');
|
||||
|
||||
exports.runQuery = function (matrixClient, room, address, flaggedInput, registrar) {
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: `${registrar.config.fediverse}/api/v1/statuses`,
|
||||
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
|
||||
data: { status: `@10grans@fedi.cc tip `+ flaggedInput + ` to `+address },
|
||||
}).then((response) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'',
|
||||
`<b>
|
||||
<blockquote><i>Tipping ${response.data.content}<br>
|
||||
(id: ${response.data.id}</a>)
|
||||
</blockquote><br>`);
|
||||
})
|
||||
.catch((e) => {
|
||||
matrixClient.sendHtmlNotice(room.roomId,
|
||||
'', `${e}`);
|
||||
});
|
||||
};
|
7
main.js
7
main.js
|
@ -2,14 +2,13 @@ const sdk = require('matrix-js-sdk');
|
|||
const axios = require('axios');
|
||||
const registrar = require('./registrar.js');
|
||||
|
||||
const homeServer = 'https://civseed.com/_matrix/client/r0/login';
|
||||
const auth = {
|
||||
type: 'm.login.password',
|
||||
user: registrar.config.matrixUser,
|
||||
password: registrar.config.matrixPass,
|
||||
};
|
||||
|
||||
axios.post(homeServer, auth).then((response) => {
|
||||
axios.post(`${registrar.config.matrixServer}/_matrix/client/r0/login`, auth).then((response) => {
|
||||
CreateClient(response.data.access_token);
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
|
@ -88,6 +87,10 @@ let CreateClient = (token) => {
|
|||
registrar.reply.runQuery(matrixClient, room, address, flaggedInput, registrar);
|
||||
}
|
||||
|
||||
if (command === 'tip') {
|
||||
registrar.tip.runQuery(matrixClient, room, address, flaggedInput, registrar);
|
||||
}
|
||||
|
||||
if (command === 'unfren') {
|
||||
registrar.unfren.runQuery(matrixClient, room, userInput, registrar);
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
2020-05-16T15:16:56.000Z
|
|
@ -11,6 +11,7 @@ module.exports = {
|
|||
redact: require('./commands/redact.js'),
|
||||
notify: require('./commands/notify.js'),
|
||||
reply: require('./commands/reply.js'),
|
||||
tip: require('./commands/tip.js'),
|
||||
unfren: require('./commands/unfren.js'),
|
||||
unpin: require('./commands/unpin.js'),
|
||||
};
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
2020-05-16T16:28:32.000Z
|
Loading…
Reference in a new issue