Readme

glif.app/@heyglif-related tweets -> our Discord server

nice val steve

see original val for instructions :) https://www.val.town/v/stevekrouse/twitterAlert

requires a slightly updated version of twitterSearch

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,
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
2
stevekrouse avatar

Very cool how you handle the negative keywords being broken for RTs. I don't know if they've been broken for me recently or not. Twitter/X is a weird place these days...

jamiedubs avatar

yeah it was very annoying to notice RTs were showing up. excuse the tweet I just sent you now too, of course you get your val notifications :)

July 9, 2024