Skip to content

Commit

Permalink
Merge pull request #3219 from elizaOS/tcm-twitter-disable-post
Browse files Browse the repository at this point in the history
feat: Add configuration for enabling/disabling Twitter post generation
  • Loading branch information
shakkernerd authored Feb 4, 2025
2 parents 117d48a + 94d49b1 commit 0e16f97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ TWITTER_SEARCH_ENABLE=FALSE # Enable timeline search, WARNING this greatly incre
TWITTER_TARGET_USERS= # Comma separated list of Twitter user names to interact with
TWITTER_RETRY_LIMIT= # Maximum retry attempts for Twitter login
TWITTER_SPACES_ENABLE=false # Enable or disable Twitter Spaces logic
ENABLE_TWITTER_POST_GENERATION=true # Set to true to enable automatic tweet generation. If false, the bot will not generate or post tweets.
# Post Interval Settings (in minutes)
POST_INTERVAL_MIN= # Default: 90
POST_INTERVAL_MAX= # Default: 180
Expand Down
9 changes: 9 additions & 0 deletions packages/client-twitter/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const twitterEnvSchema = z.object({
.optional()
.default(''),
*/
ENABLE_TWITTER_POST_GENERATION: z.boolean(),
POST_INTERVAL_MIN: z.number().int(),
POST_INTERVAL_MAX: z.number().int(),
ENABLE_ACTION_PROCESSING: z.boolean(),
Expand Down Expand Up @@ -173,6 +174,14 @@ export async function validateTwitterConfig(
process.env.TWITTER_TARGET_USERS
),

// bool
ENABLE_TWITTER_POST_GENERATION:
parseBooleanFromText(
runtime.getSetting("ENABLE_TWITTER_POST_GENERATION") ||
process.env.ENABLE_TWITTER_POST_GENERATION
) ?? true,


// int in minutes
POST_INTERVAL_MIN: safeParseInt(
runtime.getSetting("POST_INTERVAL_MIN") ||
Expand Down
11 changes: 9 additions & 2 deletions packages/client-twitter/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export class TwitterPostClient {
elizaLogger.log(
`- Dry Run Mode: ${this.isDryRun ? "enabled" : "disabled"}`
);

elizaLogger.log(
`- Enable Post: ${this.client.twitterConfig.ENABLE_TWITTER_POST_GENERATION ? "enabled" : "disabled"}`
);

elizaLogger.log(
`- Post Interval: ${this.client.twitterConfig.POST_INTERVAL_MIN}-${this.client.twitterConfig.POST_INTERVAL_MAX} minutes`
);
Expand Down Expand Up @@ -287,8 +292,10 @@ export class TwitterPostClient {
await this.generateNewTweet();
}

generateNewTweetLoop();
elizaLogger.log("Tweet generation loop started");
if (this.client.twitterConfig.ENABLE_TWITTER_POST_GENERATION) {
generateNewTweetLoop();
elizaLogger.log("Tweet generation loop started");
}

if (this.client.twitterConfig.ENABLE_ACTION_PROCESSING) {
processActionsLoop().catch((error) => {
Expand Down

0 comments on commit 0e16f97

Please sign in to comment.