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
import { correctPostAboutTwitter } from "https://esm.town/v/andreterron/correctPostAboutTwitter";
import { sortedPosts } from "https://esm.town/v/andreterron/sortedPosts";
import { searchPostsForTheActuallyBot } from "https://esm.town/v/andreterron/searchPostsForTheActuallyBot";
import { refreshActuallyBotToken } from "https://esm.town/v/andreterron/refreshActuallyBotToken";
export async function emojiSearchBot
() {
const token = await refreshActuallyBotToken();
//
// Search
const posts = await searchPostsForTheActuallyBot(
token.access_token,
);
const detailed = await sortedPosts({
posts,
accessToken: token.access_token,
});
//
const post = detailed[0];
if (!post) {
if (posts.length) {
throw new Error("Failed to get post users");
}
console.log("No valid posts returned");
return;
}
const reply = await correctPostAboutTwitter({
id: post.id,
accessToken: token.access_token,
});
//
return reply;
}