Skip to content

Commit

Permalink
fix: switch to rsshub from twitter api
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakiyo authored Jul 3, 2023
1 parent 5d50566 commit 0ef95ab
Showing 1 changed file with 5 additions and 13 deletions.
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 0ef95ab

Please sign in to comment.