Runs every 15 min
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
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
import { twitterSearch } from "https://esm.town/v/stevekrouse/twitterSearch";
// looks like maybe all negative keywords are broken? "-is:retweet" doesn't work either
// otherwise would like to also add:
// -glif.io -@glifio
const query = `"glif.app" OR "glifapp" OR "glif app" OR "@heyglif" -is:retweet`;
export async function twitterAlert({ lastRunAt }: Interval) {
const results = await twitterSearch({
query,
start_time: lastRunAt,
bearerToken: Deno.env.get("GLIF_TWITTER_BEARER_TOKEN"),
});
if (!results.length) {
console.debug(`no new tweets since ${lastRunAt}`);
return;
}
else {
console.log("found tweets", { results });
}
// manually remove retweets; twitter's "-is:retweet" doesn't work!
// then format results for posting to Discord
let content = results
.filter(result => !result.is_retweet)
.map(({ author_name, author_username, text, id }) => `https://fxtwitter.com/${author_username}/status/${id}`)
.join("\n");
// post to Discord
await discordWebhook({
url: Deno.env.get("GLIF_TWITTER_WEBHOOK"),
content,
});
}