Public
Versions
- Open: VersionChanges from v27 to v28+1-1⦚ 16 unchanged lines ⦚bearerToken: process.env.twitter,});
if (!result.data) return;let latestTweet = result.data.filter(d => d.attachments)[0];let attachment = result.includes.media.find(m => m.media_key === latestTweet.attachments.media_keys[0]);⦚ 27 unchanged lines ⦚⦚ 16 unchanged lines ⦚bearerToken: process.env.twitter,});if (!result.data || !result?.includes?.media) return;let latestTweet = result.data.filter(d => d.attachments)[0];let attachment = result.includes.media.find(m => m.media_key === latestTweet.attachments.media_keys[0]);⦚ 27 unchanged lines ⦚ - Open: VersionChanges from v26 to v27+2-2import { postTweet } from "https://esm.town/v/andreterron/postTweet";
import { msHour } from "https://esm.town/v/stevekrouse/msHour";import { refreshEmojiSearchToken } from "https://esm.town/v/stevekrouse/refreshEmojiSearchToken";import { twitterJSON } from "https://esm.town/v/stevekrouse/twitterJSON";⦚ 6 unchanged lines ⦚const token = await refreshEmojiSearchToken();let query = `?start_time=${new Date(lastRunAt.getTime()).toISOString()}&expansions=attachments.media_keys&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text`;const result = await twitterJSON({⦚ 33 unchanged lines ⦚import { postTweet } from "https://esm.town/v/andreterron/postTweet";import { msSecond } from "https://esm.town/v/stevekrouse/msSecond";import { refreshEmojiSearchToken } from "https://esm.town/v/stevekrouse/refreshEmojiSearchToken";import { twitterJSON } from "https://esm.town/v/stevekrouse/twitterJSON";⦚ 6 unchanged lines ⦚const token = await refreshEmojiSearchToken();let query = `?start_time=${new Date(lastRunAt.getTime() - 5 * msSecond).toISOString()}&expansions=attachments.media_keys&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text`;const result = await twitterJSON({⦚ 33 unchanged lines ⦚ - Open: VersionChanges from v25 to v26+1-0⦚ 16 unchanged lines ⦚bearerToken: process.env.twitter,});
let latestTweet = result.data.filter(d => d.attachments)[0];let attachment = result.includes.media.find(m => m.media_key === latestTweet.attachments.media_keys[0]);if (attachment.type !== "photo") return;⦚ 26 unchanged lines ⦚⦚ 16 unchanged lines ⦚bearerToken: process.env.twitter,});if (!result.data) return;let latestTweet = result.data.filter(d => d.attachments)[0];let attachment = result.includes.media.find(m => m.media_key === latestTweet.attachments.media_keys[0]);if (attachment.type !== "photo") return;⦚ 26 unchanged lines ⦚ - Open: VersionChanges from v24 to v25+1-1⦚ 10 unchanged lines ⦚const token = await refreshEmojiSearchToken();let query = `?start_time=${
new Date(lastRunAt.getTime() - msHour).toISOString()}&expansions=attachments.media_keys&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text`;const result = await twitterJSON({⦚ 32 unchanged lines ⦚⦚ 10 unchanged lines ⦚const token = await refreshEmojiSearchToken();let query = `?start_time=${new Date(lastRunAt.getTime()).toISOString()}&expansions=attachments.media_keys&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text`;const result = await twitterJSON({⦚ 32 unchanged lines ⦚ - Open: VersionChanges from v23 to v24+1-1⦚ 37 unchanged lines ⦚},],
max_tokens: 5,});return postTweet({⦚ 5 unchanged lines ⦚⦚ 37 unchanged lines ⦚},],max_tokens: 10,});return postTweet({⦚ 5 unchanged lines ⦚ - Open: VersionChanges from v22 to v23+1-3
import { correctPostAboutTwitter } from "https://esm.town/v/andreterron/correctPostAboutTwitter";import { postTweet } from "https://esm.town/v/andreterron/postTweet?v=1";import { sortedPosts } from "https://esm.town/v/andreterron/sortedPosts";import { msHour } from "https://esm.town/v/stevekrouse/msHour";import { refreshEmojiSearchToken } from "https://esm.town/v/stevekrouse/refreshEmojiSearchToken";⦚ 44 unchanged lines ⦚import { postTweet } from "https://esm.town/v/andreterron/postTweet";import { msHour } from "https://esm.town/v/stevekrouse/msHour";import { refreshEmojiSearchToken } from "https://esm.town/v/stevekrouse/refreshEmojiSearchToken";⦚ 44 unchanged lines ⦚ - Open: VersionChanges from v21 to v22+0-1⦚ 41 unchanged lines ⦚max_tokens: 5,});return postTweet({accessToken: token.access_token,⦚ 4 unchanged lines ⦚⦚ 41 unchanged lines ⦚max_tokens: 5,});return postTweet({accessToken: token.access_token,⦚ 4 unchanged lines ⦚
- Open: VersionChanges from v20 to v21+1-1⦚ 20 unchanged lines ⦚let latestTweet = result.data.filter(d => d.attachments)[0];let attachment = result.includes.media.find(m => m.media_key === latestTweet.attachments.media_keys[0]);
if (attachment.type === "photo") return attachment;const response = await openai.chat.completions.create({model: "gpt-4-vision-preview",⦚ 25 unchanged lines ⦚⦚ 20 unchanged lines ⦚let latestTweet = result.data.filter(d => d.attachments)[0];let attachment = result.includes.media.find(m => m.media_key === latestTweet.attachments.media_keys[0]);if (attachment.type !== "photo") return;const response = await openai.chat.completions.create({model: "gpt-4-vision-preview",⦚ 25 unchanged lines ⦚ - Open: Version+50-0import { correctPostAboutTwitter } from "https://esm.town/v/andreterron/correctPostAboutTwitter";import { postTweet } from "https://esm.town/v/andreterron/postTweet?v=1";import { sortedPosts } from "https://esm.town/v/andreterron/sortedPosts";import { msHour } from "https://esm.town/v/stevekrouse/msHour";import { refreshEmojiSearchToken } from "https://esm.town/v/stevekrouse/refreshEmojiSearchToken";import { twitterJSON } from "https://esm.town/v/stevekrouse/twitterJSON";import process from "node:process";import OpenAI from "npm:openai";const openai = new OpenAI({ apiKey: process.env.openai });export async function emojiSearchBot({ lastRunAt }: Interval) {const token = await refreshEmojiSearchToken();let query = `?start_time=${new Date(lastRunAt.getTime() - msHour).toISOString()}&expansions=attachments.media_keys&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text`;const result = await twitterJSON({url: `https://api.twitter.com/2/users/1721850098575908864/mentions` + query,bearerToken: process.env.twitter,});let latestTweet = result.data.filter(d => d.attachments)[0];let attachment = result.includes.media.find(m => m.media_key === latestTweet.attachments.media_keys[0]);if (attachment.type === "photo") return attachment;const response = await openai.chat.completions.create({model: "gpt-4-vision-preview",messages: [{role: "user",content: [{type: "text",text:"I am trying to find an emoji. I took a selfie that's trying to evoke this emoji. Give me a list of potential emojis this photo evokes. Reply ONLY with emoji. No other text explaining your choices.",},{type: "image_url",
Updated: November 7, 2023