-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.mjs
56 lines (49 loc) · 1.4 KB
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { login } from "masto";
import config from "./config.json" assert { type: "json" };
import * as dotenv from "dotenv";
dotenv.config();
const main = async () => {
const masto = await login({
url: config.instanceUrl,
accessToken: process.env.TOKEN,
});
const lists = await masto.lists.fetchAll();
const list = lists.find((element) => element.title === config.listName);
if (!list) {
console.log("No list for retoot found!");
return;
}
const accounts = await masto.lists.fetchAccounts(list.id);
const accountIds = accounts.value.map((account) => account.id);
if (!accountIds) {
console.log("No Account Ids found");
return;
}
accountIds.forEach(async (accountId) => {
const toots = await masto.accounts
.iterateStatuses(accountId, {
excludeReplies: true,
limit: config.statusesLimit,
tagged: config.tag,
})
.next();
toots.value
.map((toot) => toot.id)
.forEach(async (id) => {
const retootedby = await masto.statuses.fetchRebloggedBy(id);
if (
!retootedby.find(
(element) =>
element.url === `${config.instanceUrl}/@${config.ownAccountName}`
)
) {
await masto.statuses.reblog(id);
console.log("Boost successfull!", id);
}
});
});
};
main().catch((error) => {
console.error(error);
process.exit(1);
});