|
@@ -14,7 +14,7 @@ export default class Fortune {
|
|
|
this._mastodonRestClient = createRestAPIClient({ url: config.MASTODON_API_URL, accessToken });
|
|
|
}
|
|
|
|
|
|
- private async reply(inReplyToId: string | undefined, userName: string, iteration = 1, count = 1): Promise<void> {
|
|
|
+ private async reply(inReplyToId: string | undefined, userName: string, visibility, iteration = 1, count = 1): Promise<void> {
|
|
|
let status = "";
|
|
|
let spoilerText;
|
|
|
let stop = false;
|
|
@@ -23,7 +23,7 @@ export default class Fortune {
|
|
|
if (count == 1) {
|
|
|
status = `${Emojis.FAIRY}: ${userName} prepárate para un viaje mágico ${Emojis.SPARKLES}`;
|
|
|
console.log("Sending status\n", status);
|
|
|
- result = await this._mastodonRestClient.v1.statuses.create({ inReplyToId, status });
|
|
|
+ result = await this._mastodonRestClient.v1.statuses.create({ inReplyToId, status, visibility });
|
|
|
inReplyToId = result.id;
|
|
|
if (config.LOG_LEVEL === LogLevels.DEBUG) {
|
|
|
console.debug("Result", result);
|
|
@@ -62,14 +62,14 @@ export default class Fortune {
|
|
|
}
|
|
|
|
|
|
console.log("Sending status\n", status);
|
|
|
- result = await this._mastodonRestClient.v1.statuses.create({ inReplyToId, spoilerText, status });
|
|
|
+ result = await this._mastodonRestClient.v1.statuses.create({ inReplyToId, spoilerText, status, visibility });
|
|
|
|
|
|
if (config.LOG_LEVEL === LogLevels.DEBUG) {
|
|
|
console.log("Result", result);
|
|
|
}
|
|
|
|
|
|
if (!stop && count < 4) {
|
|
|
- setTimeout(async () => await this.reply(result.id, userName, iteration, count), 2000);
|
|
|
+ setTimeout(async () => await this.reply(result.id, userName, visibility, iteration, count), 3000);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -79,15 +79,15 @@ export default class Fortune {
|
|
|
switch(event.event) {
|
|
|
case "notification":
|
|
|
if (event.payload.type == "mention") {
|
|
|
- const {id, createdAt, url, content} = event.payload.status ?? {};
|
|
|
+ const {id, createdAt, visibility, url, content} = event.payload.status ?? {};
|
|
|
|
|
|
if (config.DEVELOP) {
|
|
|
console.log("Event received\n", event.payload);
|
|
|
} else {
|
|
|
- console.log("Event received\n", { id, createdAt, url, content });
|
|
|
+ console.log("Event received\n", { id, createdAt, visibility, url, content });
|
|
|
}
|
|
|
|
|
|
- await this.reply(event.payload.status?.id, event.payload.account.displayName, Math.floor(Math.random() * 10));
|
|
|
+ await this.reply(event.payload.status?.id, event.payload.account.displayName, visibility, Math.floor(Math.random() * 10));
|
|
|
}
|
|
|
break;
|
|
|
}
|