Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
type Tweet,
} from "./client/index";
import { TwitterInteractionPayload } from "./types";
import { TIMELINE_TYPE } from "./timeline";

interface TwitterUser {
id_str: string;
Expand Down Expand Up @@ -675,7 +676,11 @@ export class ClientBase {
}
}

const timeline = await this.fetchHomeTimeline(cachedTimeline ? 10 : 50);
const following =
(this.state?.TWITTER_TIMELINE_MODE ||
this.runtime.getSetting("TWITTER_TIMELINE_MODE"))
=== TIMELINE_TYPE.Following;
const timeline = await this.fetchHomeTimeline(cachedTimeline ? 10 : following ? 20 : 50, following);
const username = this.runtime.getSetting("TWITTER_USERNAME");

// Get the most recent 20 mentions and interactions
Expand Down
7 changes: 7 additions & 0 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const twitterEnvSchema = z.object({
TWITTER_RETRY_LIMIT: z.number().int(),
TWITTER_POLL_INTERVAL: z.number().int(),
TWITTER_TARGET_USERS: z.string().default(""),
TWITTER_TIMELINE_MODE: z.string().refine(val => !val || val === 'following' || val === 'foryou', 'Timeline mode must be either "following", "foryou", or empty'),
TWITTER_ENABLE_POST_GENERATION: z.boolean(),
TWITTER_POST_INTERVAL_MIN: z.number().int(),
TWITTER_POST_INTERVAL_MAX: z.number().int(),
Expand Down Expand Up @@ -128,6 +129,12 @@ export async function validateTwitterConfig(
runtime.getSetting("TWITTER_TARGET_USERS") ||
process.env.TWITTER_TARGET_USERS ||
"",

//string - 'following' or 'foryou' (or empty => default to 'foryou')
TWITTER_TIMELINE_MODE:
runtime.getSetting("TWITTER_TIMELINE_MODE") ||
process.env.TWITTER_TIMELINE_MODE ||
"",

// bool
TWITTER_ENABLE_POST_GENERATION:
Expand Down
2 changes: 1 addition & 1 deletion src/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { sendTweet, parseActionResponseFromText } from "./utils";
import { ActionResponse } from "./types";

enum TIMELINE_TYPE {
export enum TIMELINE_TYPE {
ForYou = "foryou",
Following = "following",
}
Expand Down