Commit
·
58ea57b
1
Parent(s):
8843020
🚀 Deploy on space
Browse files- Dockerfile +10 -0
- server.ts +12 -6
Dockerfile
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:18
|
2 |
+
|
3 |
+
COPY package.json package.json
|
4 |
+
COPY pnpm-lock.yaml pnpm-lock.yaml
|
5 |
+
|
6 |
+
RUN npm install
|
7 |
+
|
8 |
+
COPY . .
|
9 |
+
|
10 |
+
CMD ["npm", "start"]
|
server.ts
CHANGED
@@ -55,18 +55,22 @@ async function ff(url: string) {
|
|
55 |
let lastMention = "";
|
56 |
|
57 |
async function lookupTweets() {
|
58 |
-
const data: TweetMentions = await ff(
|
|
|
|
|
59 |
|
60 |
let lookups: TweetLookups = await ff(
|
61 |
-
`tweets?ids=${data.data
|
62 |
-
|
63 |
-
|
|
|
|
|
64 |
);
|
65 |
|
66 |
if (!lastMention) {
|
67 |
console.log("added mention", lookups.data[0].created_at);
|
68 |
lastMention = lookups.data[0].created_at;
|
69 |
-
return;
|
70 |
}
|
71 |
const tweets = lookups.data.filter((tweet) => tweet.attachments?.media_keys.length === 1);
|
72 |
console.log(lastMention);
|
@@ -111,7 +115,9 @@ async function lookupTweets() {
|
|
111 |
method: "post",
|
112 |
});
|
113 |
|
114 |
-
|
|
|
|
|
115 |
}
|
116 |
}
|
117 |
|
|
|
55 |
let lastMention = "";
|
56 |
|
57 |
async function lookupTweets() {
|
58 |
+
const data: TweetMentions = await ff(
|
59 |
+
`users/${BOT_ID}/mentions?${lastMention && `start_time=${new Date(new Date(lastMention).getTime() + 1).toJSON()}`}`
|
60 |
+
);
|
61 |
|
62 |
let lookups: TweetLookups = await ff(
|
63 |
+
`tweets?ids=${data.data
|
64 |
+
.map((t) => t.id)
|
65 |
+
.join(
|
66 |
+
","
|
67 |
+
)}&tweet.fields=created_at&expansions=attachments.media_keys&media.fields=duration_ms,height,media_key,preview_image_url,public_metrics,type,url,width,alt_text`
|
68 |
);
|
69 |
|
70 |
if (!lastMention) {
|
71 |
console.log("added mention", lookups.data[0].created_at);
|
72 |
lastMention = lookups.data[0].created_at;
|
73 |
+
return lookupTweets();
|
74 |
}
|
75 |
const tweets = lookups.data.filter((tweet) => tweet.attachments?.media_keys.length === 1);
|
76 |
console.log(lastMention);
|
|
|
115 |
method: "post",
|
116 |
});
|
117 |
|
118 |
+
try {
|
119 |
+
console.log("end", await r.json());
|
120 |
+
} catch {}
|
121 |
}
|
122 |
}
|
123 |
|