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();
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;
}