Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9da8521

Browse files
author
Devin AI
committedNov 13, 2024
fix: Update TwitterPostClient with proper WebApprovalInterface integration
1 parent ac350bb commit 9da8521

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed
 

‎packages/client-twitter/src/post.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { IAgentRuntime, ModelClass } from "@ai16z/eliza/src/types.ts";
77
import { stringToUuid } from "@ai16z/eliza/src/uuid.ts";
88
import { ClientBase } from "./base.ts";
99
import { ApprovalQueue } from './approval-queue.js';
10+
import { WebApprovalInterface } from './web/approval-interface.js';
1011

1112
const twitterPostTemplate = `{{timeline}}
1213
@@ -27,35 +28,38 @@ Your response should not contain any questions. Brief, concise statements only.
2728

2829
export class TwitterPostClient extends ClientBase {
2930
private approvalQueue: ApprovalQueue;
30-
private approvalInterface: any; // Will be WebApprovalInterface
31+
private approvalInterface: WebApprovalInterface | null = null;
3132

3233
onReady() {
3334
const generateNewTweetLoop = () => {
3435
this.generateNewTweet();
3536
setTimeout(
3637
generateNewTweetLoop,
3738
(Math.floor(Math.random() * (20 - 2 + 1)) + 2) * 60 * 1000
38-
); // Random interval between 4-8 hours
39+
);
3940
};
4041
generateNewTweetLoop();
4142
}
4243

4344
constructor(runtime: IAgentRuntime) {
44-
// Initialize the client and pass an optional callback to be called when the client is ready
4545
super({
4646
runtime,
4747
});
4848
this.approvalQueue = new ApprovalQueue(undefined, this.config.approvalTimeout);
4949

5050
// Initialize and start the approval interface if required
5151
if (this.config.approvalRequired) {
52-
import('./web/approval-interface.js').then(async ({ WebApprovalInterface }) => {
53-
this.approvalInterface = await WebApprovalInterface.create(undefined, 3000);
54-
await this.approvalInterface.start();
55-
console.log('Twitter approval interface initialized and started');
56-
}).catch(error => {
57-
console.error('Error initializing approval interface:', error);
58-
});
52+
this.initializeApprovalInterface();
53+
}
54+
}
55+
56+
private async initializeApprovalInterface() {
57+
try {
58+
this.approvalInterface = new WebApprovalInterface(this.approvalQueue, 3000);
59+
await this.approvalInterface.start();
60+
console.log('Twitter approval interface initialized and started at http://localhost:3000/twitter-approval');
61+
} catch (error) {
62+
console.error('Error initializing approval interface:', error);
5963
}
6064
}
6165

0 commit comments

Comments
 (0)
Please sign in to comment.