Change auto mode interval from 30 minutes to 60 minutes

This commit is contained in:
2025-10-30 20:53:38 +09:00
parent 48497b3c73
commit 3076ba45df
2 changed files with 14 additions and 14 deletions

View File

@@ -8,7 +8,7 @@ An automated Twitter bot that generates and posts tweets using Google Gemini's f
- **Three operation modes:** - **Three operation modes:**
- Interactive mode with manual approval - Interactive mode with manual approval
- Auto-post mode for one-time tweets - Auto-post mode for one-time tweets
- Scheduled mode (posts every 30 minutes) - Scheduled mode (posts every 60 minutes)
- **Attach images to tweets** - Include a static image from local file system with every tweet - **Attach images to tweets** - Include a static image from local file system with every tweet
- Automatic tweet posting at regular intervals - Automatic tweet posting at regular intervals
- Customizable prompts for different content types - Customizable prompts for different content types
@@ -117,9 +117,9 @@ Or using Maven:
mvn exec:java -Dexec.mainClass="com.voidcode.tweetbot.TweetBot" mvn exec:java -Dexec.mainClass="com.voidcode.tweetbot.TweetBot"
``` ```
### 2. Scheduled Mode (Auto-post every 30 minutes) ### 2. Scheduled Mode (Auto-post every 60 minutes)
Run continuously and automatically post tweets every 30 minutes: Run continuously and automatically post tweets every 60 minutes:
```bash ```bash
java -jar target/tweetbot-1.0.0.jar --schedule java -jar target/tweetbot-1.0.0.jar --schedule
@@ -133,7 +133,7 @@ java -jar target/tweetbot-1.0.0.jar --schedule "Write daily tech tips"
The bot will: The bot will:
- Post immediately when started - Post immediately when started
- Post a new tweet every 30 minutes - Post a new tweet every 60 minutes
- Run continuously until stopped with Ctrl+C - Run continuously until stopped with Ctrl+C
- Automatically recover from errors and retry at the next interval - Automatically recover from errors and retry at the next interval
@@ -157,7 +157,7 @@ java -jar target/tweetbot-1.0.0.jar --auto "Write a motivational quote about per
| Option | Short | Description | | Option | Short | Description |
|--------|-------|-------------| |--------|-------|-------------|
| `--schedule` | `-s` | Run in scheduled mode (posts every 30 minutes) | | `--schedule` | `-s` | Run in scheduled mode (posts every 60 minutes) |
| `--auto` | `-a` | Auto-post without confirmation (one-time) | | `--auto` | `-a` | Auto-post without confirmation (one-time) |
| `--help` | `-h` | Show help message | | `--help` | `-h` | Show help message |
@@ -189,7 +189,7 @@ View at: https://twitter.com/user/status/1234567890123456789
========================================================== ==========================================================
TweetBot - SCHEDULED MODE TweetBot - SCHEDULED MODE
========================================================== ==========================================================
Tweet will be posted every 30 minutes Tweet will be posted every 60 minutes
Press Ctrl+C to stop Press Ctrl+C to stop
========================================================== ==========================================================
@@ -201,7 +201,7 @@ The future is collaborative intelligence.
========================================================== ==========================================================
Tweet ID: 1234567890123456789 Tweet ID: 1234567890123456789
View at: https://twitter.com/user/status/1234567890123456789 View at: https://twitter.com/user/status/1234567890123456789
Next tweet in 30 minutes Next tweet in 60 minutes
========================================================== ==========================================================
``` ```
@@ -390,7 +390,7 @@ This error means your Twitter API access level doesn't support v1.1 tweet postin
Twitter API has rate limits: Twitter API has rate limits:
- Tweet creation: 300 tweets per 3 hours (100 per hour average) - Tweet creation: 300 tweets per 3 hours (100 per hour average)
- The default 30-minute interval allows for 6 tweets per 3 hours, well within limits - The default 60-minute interval allows for 3 tweets per 3 hours, well within limits
- Monitor your usage to avoid hitting limits - Monitor your usage to avoid hitting limits
- If you modify the schedule interval, ensure you stay within rate limits - If you modify the schedule interval, ensure you stay within rate limits
@@ -407,10 +407,10 @@ Feel free to fork this project and customize it for your needs. Some ideas:
### Customizing the Schedule Interval ### Customizing the Schedule Interval
To change the posting frequency from 30 minutes to another interval, edit `TweetBot.java`: To change the posting frequency from 60 minutes to another interval, edit `TweetBot.java`:
```java ```java
private static final int SCHEDULE_INTERVAL_MINUTES = 30; // Change this value private static final int SCHEDULE_INTERVAL_MINUTES = 60; // Change this value
``` ```
### Other Enhancement Ideas ### Other Enhancement Ideas

View File

@@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit;
public class TweetBot { public class TweetBot {
private static final Logger logger = LoggerFactory.getLogger(TweetBot.class); private static final Logger logger = LoggerFactory.getLogger(TweetBot.class);
private static final int SCHEDULE_INTERVAL_MINUTES = 30; private static final int SCHEDULE_INTERVAL_MINUTES = 60;
private static GeminiService geminiService; private static GeminiService geminiService;
private static TwitterService twitterService; private static TwitterService twitterService;
private static String tweetPrompt; private static String tweetPrompt;
@@ -125,7 +125,7 @@ public class TweetBot {
// Post immediately on startup // Post immediately on startup
postTweetAutomatically(); postTweetAutomatically();
// Schedule to run every 30 minutes // Schedule to run every 60 minutes
scheduler.scheduleAtFixedRate(() -> { scheduler.scheduleAtFixedRate(() -> {
if (isRunning) { if (isRunning) {
postTweetAutomatically(); postTweetAutomatically();
@@ -237,7 +237,7 @@ public class TweetBot {
System.out.println("\nUsage:"); System.out.println("\nUsage:");
System.out.println(" java -jar tweetbot.jar [OPTIONS] [CUSTOM_PROMPT]"); System.out.println(" java -jar tweetbot.jar [OPTIONS] [CUSTOM_PROMPT]");
System.out.println("\nOptions:"); System.out.println("\nOptions:");
System.out.println(" -s, --schedule Run in scheduled mode (posts every 30 minutes)"); System.out.println(" -s, --schedule Run in scheduled mode (posts every 60 minutes)");
System.out.println(" -a, --auto Auto-post without confirmation (one-time mode)"); System.out.println(" -a, --auto Auto-post without confirmation (one-time mode)");
System.out.println(" -h, --help Show this help message"); System.out.println(" -h, --help Show this help message");
System.out.println("\nExamples:"); System.out.println("\nExamples:");
@@ -245,7 +245,7 @@ public class TweetBot {
System.out.println(" java -jar tweetbot.jar"); System.out.println(" java -jar tweetbot.jar");
System.out.println("\n # Auto-post once with custom prompt"); System.out.println("\n # Auto-post once with custom prompt");
System.out.println(" java -jar tweetbot.jar --auto \"Write a tweet about AI\""); System.out.println(" java -jar tweetbot.jar --auto \"Write a tweet about AI\"");
System.out.println("\n # Scheduled mode (posts every 30 minutes)"); System.out.println("\n # Scheduled mode (posts every 60 minutes)");
System.out.println(" java -jar tweetbot.jar --schedule"); System.out.println(" java -jar tweetbot.jar --schedule");
System.out.println("\n # Scheduled mode with custom prompt"); System.out.println("\n # Scheduled mode with custom prompt");
System.out.println(" java -jar tweetbot.jar --schedule \"Daily tech tips\""); System.out.println(" java -jar tweetbot.jar --schedule \"Daily tech tips\"");