Back

Version 0

8/31/2024
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
import { twitterSearch } from "https://esm.town/v/stevekrouse/twitterSearch";

const excludedUsernames = [
"valenzuelacity",
];

const baseQuery = "\"val.town\" OR \"val town\" -_ValTown_ -is:retweet";
const excludeUsersQuery = excludedUsernames.map(username => `-from:${username}`).join(" ");

const query = `${baseQuery} ${excludeUsersQuery}`.trim();

export async function twitterAlert({ lastRunAt }: Interval) {
const results = await twitterSearch({
query,
start_time: lastRunAt,
bearerToken: Deno.env.get("twitter"),
});
if (!results.length) return;

// format results
let content = results
.map(({ author_name, author_username, text, id }) => `https://fxtwitter.com/${author_username}/status/${id}`)
.join("\n");

// notify
await discordWebhook({
url: Deno.env.get("mentionsDiscord"),
content,
});
}
Updated: August 31, 2024