@@ -10,24 +10,32 @@ class TwitterManager {
10
10
post : TwitterPostClient ;
11
11
search : TwitterSearchClient ;
12
12
interaction : TwitterInteractionClient ;
13
- constructor ( runtime : IAgentRuntime ) {
13
+ constructor ( runtime : IAgentRuntime , enableSearch : boolean ) {
14
14
this . client = new ClientBase ( runtime ) ;
15
15
this . post = new TwitterPostClient ( this . client , runtime ) ;
16
- //this.search = new TwitterSearchClient(this.client, runtime); // don't start the search client by default
17
- // this searches topics from character file, but kind of violates consent of random users
18
- // burns your rate limit and can get your account banned
19
- // use at your own risk
16
+
17
+ if ( enableSearch ) {
18
+ // this searches topics from character file
19
+ elizaLogger . warn ( 'Twitter/X client running in a mode that violates consent of random users' )
20
+ elizaLogger . warn ( 'burns your rate limit and can get your account banned' )
21
+ elizaLogger . warn ( 'use at your own risk' )
22
+ this . search = new TwitterSearchClient ( this . client , runtime ) ; // don't start the search client by default
23
+ }
20
24
this . interaction = new TwitterInteractionClient ( this . client , runtime ) ;
21
25
}
22
26
}
23
27
24
28
export const TwitterClientInterface : Client = {
29
+
25
30
async start ( runtime : IAgentRuntime ) {
26
31
await validateTwitterConfig ( runtime ) ;
27
32
28
33
elizaLogger . log ( "Twitter client started" ) ;
29
34
30
- const manager = new TwitterManager ( runtime ) ;
35
+ // enableSearch is just set previous to this call
36
+ // so enableSearch can change over time
37
+ // and changing it won't stop the SearchClient in the existing instance
38
+ const manager = new TwitterManager ( runtime , this . enableSearch ) ;
31
39
32
40
await manager . client . init ( ) ;
33
41
0 commit comments