From 4087b396e1c20ece6d254325ddc7ff7e42ba3921 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Mar 2026 08:30:40 +0000 Subject: [PATCH 1/2] feat(twitter-plugin): add getFollowersFunction to retrieve follower list by user ID Adds a new `get_followers` GameFunction that retrieves up to 100 followers for a given Twitter user ID, including public metrics and description. The function is also added to the default worker functions list. https://claude.ai/code/session_01KUvwzoZhwrUhv6Z2vt8ors --- plugins/twitterPlugin/src/twitterPlugin.ts | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/plugins/twitterPlugin/src/twitterPlugin.ts b/plugins/twitterPlugin/src/twitterPlugin.ts index 5e8b4549..135e4bb8 100644 --- a/plugins/twitterPlugin/src/twitterPlugin.ts +++ b/plugins/twitterPlugin/src/twitterPlugin.ts @@ -43,6 +43,7 @@ class TwitterPlugin { this.postTweetFunction, this.likeTweetFunction, this.quoteTweetFunction, + this.getFollowersFunction, ], getEnvironment: data?.getEnvironment || this.getMetrics.bind(this), }); @@ -220,6 +221,59 @@ class TwitterPlugin { }); } + get getFollowersFunction() { + return new GameFunction({ + name: "get_followers", + description: + "Retrieve the list of followers for a given user ID. Use this to analyze a user's audience or find potential accounts to engage with.", + args: [ + { name: "user_id", description: "The Twitter user ID to get followers for" }, + ] as const, + executable: async (args, logger) => { + try { + if (!args.user_id) { + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Failed, + "User ID is required" + ); + } + + logger(`Getting followers for user id: ${args.user_id}`); + + const followers = await this.twitterClient.v2.followers(args.user_id, { + max_results: 100, + "user.fields": ["public_metrics", "description"], + }); + + const feedbackMessage = + "Followers found:\n" + + JSON.stringify( + followers.data.data.map((user) => ({ + userId: user.id, + username: user.username, + name: user.name, + description: user.description, + followers: user.public_metrics?.followers_count, + following: user.public_metrics?.following_count, + })) + ); + + logger(feedbackMessage); + + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Done, + feedbackMessage + ); + } catch (e) { + return new ExecutableGameFunctionResponse( + ExecutableGameFunctionStatus.Failed, + "Failed to get followers" + ); + } + }, + }); + } + get quoteTweetFunction() { return new GameFunction({ name: "quote_tweet", From 7afba86c6dc354b94458df24beff7bccf85db6d7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Mar 2026 08:38:06 +0000 Subject: [PATCH 2/2] fix(twitter-plugin): fix type errors in getFollowersFunction The followers API returns UserV2[] directly on .data, not nested under .data.data. Also added explicit `any` type annotation for the map callback. https://claude.ai/code/session_01KUvwzoZhwrUhv6Z2vt8ors --- plugins/twitterPlugin/src/twitterPlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/twitterPlugin/src/twitterPlugin.ts b/plugins/twitterPlugin/src/twitterPlugin.ts index 135e4bb8..1a014677 100644 --- a/plugins/twitterPlugin/src/twitterPlugin.ts +++ b/plugins/twitterPlugin/src/twitterPlugin.ts @@ -248,7 +248,7 @@ class TwitterPlugin { const feedbackMessage = "Followers found:\n" + JSON.stringify( - followers.data.data.map((user) => ({ + followers.data.map((user: any) => ({ userId: user.id, username: user.username, name: user.name,