File tree 2 files changed +26
-8
lines changed
2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ X_SERVER_URL=
29
29
XAI_API_KEY =
30
30
XAI_MODEL =
31
31
32
+ # POST INTERVAL RANDOM MIN-MAX.
33
+ POST_INTERVAL_MIN = 30 # 5 # Default
34
+ POST_INTERVAL_MAX = 90 # 10 # Default
35
+
36
+
32
37
# USE IMAGE GEN
33
38
IMAGE_GEN = #TRUE
34
39
Original file line number Diff line number Diff line change @@ -28,19 +28,32 @@ Write a single sentence post that is {{adjective}} about {{topic}} (without ment
28
28
Your response should not contain any questions. Brief, concise statements only. No emojis. Use \\n\\n (double spaces) between statements.` ;
29
29
30
30
export class TwitterPostClient extends ClientBase {
31
- onReady ( ) {
31
+
32
+
33
+ onReady ( postImmediately : boolean = true ) {
32
34
const generateNewTweetLoop = ( ) => {
33
- this . generateNewTweet ( ) ;
35
+ const minMinutes = parseInt ( this . runtime . getSetting ( "POST_INTERVAL_MIN" ) ) || 5 ;
36
+ const maxMinutes = parseInt ( this . runtime . getSetting ( "POST_INTERVAL_MAX" ) ) || 15 ;
37
+ const randomMinutes = Math . floor ( Math . random ( ) * ( maxMinutes - minMinutes + 1 ) ) + minMinutes ;
38
+ const delay = randomMinutes * 60 * 1000 ;
39
+
34
40
setTimeout (
35
- generateNewTweetLoop ,
36
- ( Math . floor ( Math . random ( ) * ( 180 - 90 + 1 ) ) + 90 ) * 60 * 1000
37
- ) ; // Random interval: min 90min/max 180min (1.5-3h), Results in min 8/max 16 posts per day
41
+ ( ) => {
42
+ this . generateNewTweet ( ) ;
43
+ generateNewTweetLoop ( ) ; // Set up next iteration
44
+ } ,
45
+ delay
46
+ ) ;
47
+
48
+ console . log ( `Next tweet scheduled in ${ randomMinutes } minutes` ) ;
38
49
} ;
39
- // setTimeout(() => {
50
+
51
+ if ( postImmediately ) {
52
+ this . generateNewTweet ( ) ;
53
+ }
40
54
generateNewTweetLoop ( ) ;
41
- // }, 5 * 60 * 1000); // Wait 5 minutes before starting the loop
42
55
}
43
-
56
+
44
57
constructor ( runtime : IAgentRuntime ) {
45
58
// Initialize the client and pass an optional callback to be called when the client is ready
46
59
super ( {
You can’t perform that action at this time.
0 commit comments