Skip to content

Commit 857673f

Browse files
committed
add followinf option for timeline action
1 parent 2c227ba commit 857673f

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ POST_IMMEDIATELY=
8585
# Twitter action processing configuration
8686
ACTION_INTERVAL= # Interval in minutes between action processing runs (default: 5 minutes)
8787
ENABLE_ACTION_PROCESSING=false # Set to true to enable the action processing loop
88-
MAX_ACTIONS_PROCESSING= # Maximum number of actions (e.g., retweets, likes) to process in a single cycle. Helps prevent excessive or uncontrolled actions.
88+
MAX_ACTIONS_PROCESSING=1 # Maximum number of actions (e.g., retweets, likes) to process in a single cycle. Helps prevent excessive or uncontrolled actions.
89+
ACTION_TIMELINE_TYPE=foryou # Type of timeline to interact with. Options: "foryou" or "following". Default: "foryou"
8990

9091
# Feature Flags
9192
IMAGE_GEN= # Set to TRUE to enable image generation

packages/client-twitter/src/base.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getEmbeddingZeroVector,
99
elizaLogger,
1010
stringToUuid,
11+
ActionTimelineType,
1112
} from "@elizaos/core";
1213
import {
1314
QueryTweetsResponse,
@@ -321,7 +322,11 @@ export class ClientBase extends EventEmitter {
321322
elizaLogger.debug("fetching timeline for actions");
322323

323324
const agentUsername = this.twitterConfig.TWITTER_USERNAME;
324-
const homeTimeline = await this.twitterClient.fetchHomeTimeline(20, []);
325+
const homeTimeline =
326+
this.twitterConfig.ACTION_TIMELINE_TYPE ===
327+
ActionTimelineType.Following
328+
? await this.twitterClient.fetchFollowingTimeline(20, [])
329+
: await this.twitterClient.fetchHomeTimeline(20, []);
325330

326331
return homeTimeline
327332
.map((tweet) => ({

packages/client-twitter/src/environment.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { parseBooleanFromText, IAgentRuntime } from "@elizaos/core";
1+
import {
2+
parseBooleanFromText,
3+
IAgentRuntime,
4+
ActionTimelineType,
5+
} from "@elizaos/core";
26
import { z, ZodError } from "zod";
37

48
export const DEFAULT_MAX_TWEET_LENGTH = 280;
@@ -62,6 +66,9 @@ export const twitterEnvSchema = z.object({
6266
POST_IMMEDIATELY: z.boolean(),
6367
TWITTER_SPACES_ENABLE: z.boolean().default(false),
6468
MAX_ACTIONS_PROCESSING: z.number().int(),
69+
ACTION_TIMELINE_TYPE: z
70+
.nativeEnum(ActionTimelineType)
71+
.default(ActionTimelineType.ForYou),
6572
});
6673

6774
export type TwitterConfig = z.infer<typeof twitterEnvSchema>;
@@ -206,6 +213,10 @@ export async function validateTwitterConfig(
206213
process.env.MAX_ACTIONS_PROCESSING,
207214
1
208215
),
216+
217+
ACTION_TIMELINE_TYPE:
218+
runtime.getSetting("ACTION_TIMELINE_TYPE") ||
219+
process.env.ACTION_TIMELINE_TYPE,
209220
};
210221

211222
return twitterEnvSchema.parse(twitterConfig);

packages/core/src/types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1328,3 +1328,8 @@ export enum TranscriptionProvider {
13281328
Deepgram = "deepgram",
13291329
Local = "local",
13301330
}
1331+
1332+
export enum ActionTimelineType {
1333+
ForYou = "foryou",
1334+
Following = "following",
1335+
}

0 commit comments

Comments
 (0)