@@ -10,24 +10,34 @@ 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:' )
20
+ elizaLogger . warn ( '1. violates consent of random users' )
21
+ elizaLogger . warn ( '2. burns your rate limit' )
22
+ elizaLogger . warn ( '3. can get your account banned' )
23
+ elizaLogger . warn ( 'use at your own risk' )
24
+ this . search = new TwitterSearchClient ( this . client , runtime ) ; // don't start the search client by default
25
+ }
20
26
this . interaction = new TwitterInteractionClient ( this . client , runtime ) ;
21
27
}
22
28
}
23
29
24
30
export const TwitterClientInterface : Client = {
31
+
25
32
async start ( runtime : IAgentRuntime ) {
26
33
await validateTwitterConfig ( runtime ) ;
27
34
28
35
elizaLogger . log ( "Twitter client started" ) ;
29
36
30
- const manager = new TwitterManager ( runtime ) ;
37
+ // enableSearch is just set previous to this call
38
+ // so enableSearch can change over time
39
+ // and changing it won't stop the SearchClient in the existing instance
40
+ const manager = new TwitterManager ( runtime , this . enableSearch ) ;
31
41
32
42
await manager . client . init ( ) ;
33
43
0 commit comments