release 0.1.0

This commit is contained in:
vulet 2019-07-03 17:27:39 -04:00
parent 4b3ba6b516
commit 35b4509238
18 changed files with 399 additions and 1 deletions

18
commands/boo.js Normal file
View 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}/unfavourite`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
}).then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
`You have boo'd: <a href="${response.data.url}">${response.data.account.acct}</a>
<blockquote>${response.data.content}`);
})
.catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};

18
commands/clap.js Normal file
View 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}/favourite`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
}).then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
`You have clapped: <a href="${response.data.url}">${response.data.account.acct}</a>:
<blockquote>${response.data.content}`);
})
.catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};

18
commands/copy.js Normal file
View 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}/reblog`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
}).then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
`You have repeated:
<blockquote>${response.data.content}`);
})
.catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};

35
commands/flood.js Normal file
View file

@ -0,0 +1,35 @@
const axios = require('axios');
const fs = require('fs');
exports.runQuery = function (matrixClient, room, registrar) {
setInterval(() => {
axios({
method: 'GET',
url: `${registrar.config.fediverse}/api/v1/timelines/home`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
}).then((events) => {
const event = fs.readFileSync('timeline.json', 'utf8');
fs.writeFileSync('timeline.json', events.data[0].created_at, 'utf8');
if (event !== events.data[0].created_at) {
if (events.data[0].reblog === null) {
matrixClient.sendHtmlNotice(room.roomId,
'',
`<b><a href="${registrar.config.fediverse}/notice/${events.data[0].id}">${events.data[0].account.acct}</a>
<blockquote><i>${events.data[0].content}<br>
(id: ${events.data[0].id}</a>)
</blockquote><br>`);
} else {
matrixClient.sendHtmlNotice(room.roomId,
'',
`<b><a href="${registrar.config.fediverse}/${events.data[0].account.id}">
${events.data[0].account.acct}</a>
<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>`);
}
}
});
}, 8000);
};

20
commands/fren.js Normal file
View file

@ -0,0 +1,20 @@
const axios = require('axios');
exports.runQuery = function (matrixClient, room, userInput, registrar) {
axios.get(`${registrar.config.fediverse}/api/v1/accounts/${userInput}`).then((findUID) => {
axios({
method: 'POST',
url: `${registrar.config.fediverse}/api/v1/accounts/${findUID.data.id}/follow`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
})
.then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
`Subscribed:
<blockquote>${registrar.config.fediverse}}/${response.data.id}`);
});
}).catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};

15
commands/help.js Normal file
View file

@ -0,0 +1,15 @@
exports.runQuery = function (matrixClient, room) {
matrixClient.sendHtmlNotice(room.roomId,
'',
'<blockquote><b>+plemara [your message] : post<br>'
+ '+fren [user id] : follow<br>'
+ '+unfren [user id] : unfollow<br>'
+ '+copy [post id] : repeat/repost/retweet<br>'
+ '+reply [post id] : reply to post<br>'
+ '+clap [post id] : favorite<br>'
+ '+boo [post id] : unfavorite</blockquote>'
+ '<blockquote><b>channel commands<br>'
+ '+flood : turn on timeline<br>'
+ '+notify : show notifications</b></blockquote>'
+ '<blockquote><b>--- <i>docs by lint</i> ---</b></blockquote>');
};

51
commands/notify.js Normal file
View file

@ -0,0 +1,51 @@
const axios = require('axios');
const fs = require('fs');
exports.runQuery = function (matrixClient, room, registrar) {
setInterval(() => {
axios({
method: 'GET',
url: `${registrar.config.fediverse}/api/v1/notifications`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
}).then((notifications) => {
const event = fs.readFileSync('notification.json', 'utf8');
fs.writeFileSync('notification.json', notifications.data[0].created_at, 'utf8');
if (event !== notifications.data[0].created_at) {
if (notifications.data[0].type === 'follow') {
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 followed you.</b></font>
<br><i>${notifications.data[0].account.note}</i><hr>`);
} else if (notifications.data[0].type === 'favourite') {
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}">favorited</a>
your post:</b></font>
<br><i><b>${notifications.data[0].status.content}</i></b><hr>`);
} else if (notifications.data[0].type === 'mention') {
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}">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>`);
} 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>
your post:</b></font><br>
<i><b>${notifications.data[0].status.content}</i></b><hr>`);
}
}
});
}, 8000);
};

21
commands/plemara.js Normal file
View file

@ -0,0 +1,21 @@
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: userInput },
}).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}`);
});
};

17
commands/redact.js Normal file
View file

@ -0,0 +1,17 @@
const axios = require('axios');
exports.runQuery = function (matrixClient, room, userInput, registrar) {
axios({
method: 'DELETE',
url: `${registrar.config.fediverse}/api/v1/statuses/${userInput}`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
}).then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
'<blockquote>Redacted.</blockquote');
})
.catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};

18
commands/reply.js Normal file
View file

@ -0,0 +1,18 @@
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: flaggedInput, in_reply_to_id: address },
}).then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
`${response.data.content} ${response.data.url}`);
})
.catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};

20
commands/unfren.js Normal file
View file

@ -0,0 +1,20 @@
const axios = require('axios');
exports.runQuery = function (matrixClient, room, userInput, registrar) {
axios.get(`${registrar.config.fediverse}/api/v1/accounts/${userInput}`).then((findUID) => {
axios({
method: 'POST',
url: `${registrar.config.fediverse}/api/v1/accounts/${findUID.data.id}/unfollow`,
headers: { Authorization: `Bearer ${registrar.config.fediverseToken}` },
})
.then((response) => {
matrixClient.sendHtmlNotice(room.roomId,
'',
`Unsubscribed:
<blockquote>${registrar.config.fediverse}/${response.data.id}`);
});
}).catch((e) => {
matrixClient.sendHtmlNotice(room.roomId,
'', `${e}`);
});
};