feat: Implement new follower of me trigger for twitter
This commit is contained in:
28
packages/backend/src/apps/twitter/triggers/my-followers.ts
Normal file
28
packages/backend/src/apps/twitter/triggers/my-followers.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import TwitterClient from '../client';
|
||||
|
||||
export default class MyFollowers {
|
||||
client: TwitterClient;
|
||||
|
||||
constructor(client: TwitterClient) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async run(lastInternalId: string) {
|
||||
return this.getFollowers(lastInternalId);
|
||||
}
|
||||
|
||||
async testRun() {
|
||||
return this.getFollowers();
|
||||
}
|
||||
|
||||
async getFollowers(lastInternalId?: string) {
|
||||
const { username } = await this.client.getCurrentUser.run();
|
||||
const user = await this.client.getUserByUsername.run(username as string);
|
||||
|
||||
const tweets = await this.client.getUserFollowers.run(
|
||||
user.id,
|
||||
lastInternalId
|
||||
);
|
||||
return tweets;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user