Skip to content

Commit

Permalink
Merge pull request #24 from Yakiyo/twitter-fix
Browse files Browse the repository at this point in the history
Twitter fix
  • Loading branch information
Yakiyo authored Jul 3, 2023
2 parents 302f269 + 2ccfc53 commit ed7517c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.16.1
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"rome.rome",
"prisma.prisma"
]
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ DEPLOY=<Set this to TRUE for registering slash commands on startup>
NODE_ENV=<production|dev>
YOUTUBE_API_KEY=<Youtube api key>
YOUTUBE_COOKIE=<Youtube cookie keys>
TWITTER_BEARER_TOKEN=<Twitter bearer token>
```
If you are deploying in production, do set the `NODE_ENV` to `production`. On dev it logs errors to console and other helpful stuff which are usually not needed in production. Once you are done with the env file, install packages and seed the database. Seeding is required as some of the code expect the bare minimum data to be there in the database.
```bash
Expand Down
18 changes: 5 additions & 13 deletions src/jobs/twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@ export const job: Job = {
name: 'Twitter',
interval: 15 * 60,
async run() {
const gimai_id = '1250594468262113280';
const res: string[] | null = await fetch(
`https://api.twitter.com/2/users/${gimai_id}/tweets?max_results=5`,
{
headers: {
Authorization: `Bearer ${process.env.TWITTER_BEARER_TOKEN}`,
},
},
const res = await fetch(
'https://rsshub.app/twitter/user/gimaiseikatsu.json?limit=5&sorted=true',
)
.then(async (v) => await v.json())
.then((v) => (v as Record<string, Record<string, string>[]>).data)
.then((v) =>
v.map((r: Record<string, string>) => `https://twitter.com/gimaiseikatsu/status/${r.id}`),
)
.then((v) => v.json())
.then((v) => (v as Record<string, any>).items as Record<string, string>[])
.then((v) => v.map((f) => f.url))
.catch(log);

if (!res?.length) return;
Expand Down

0 comments on commit ed7517c

Please sign in to comment.