Skip to content

Commit e7964c3

Browse files
committed
add enableSearch flag/property, display warning to console
1 parent af0b94d commit e7964c3

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

packages/client-twitter/src/index.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,32 @@ class TwitterManager {
1010
post: TwitterPostClient;
1111
search: TwitterSearchClient;
1212
interaction: TwitterInteractionClient;
13-
constructor(runtime: IAgentRuntime) {
13+
constructor(runtime: IAgentRuntime, enableSearch:boolean) {
1414
this.client = new ClientBase(runtime);
1515
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+
}
2024
this.interaction = new TwitterInteractionClient(this.client, runtime);
2125
}
2226
}
2327

2428
export const TwitterClientInterface: Client = {
29+
2530
async start(runtime: IAgentRuntime) {
2631
await validateTwitterConfig(runtime);
2732

2833
elizaLogger.log("Twitter client started");
2934

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);
3139

3240
await manager.client.init();
3341

0 commit comments

Comments
 (0)