diff --git a/packages/client-twitter/src/post.ts b/packages/client-twitter/src/post.ts index b8355610f97..5176ebff7dc 100644 --- a/packages/client-twitter/src/post.ts +++ b/packages/client-twitter/src/post.ts @@ -125,6 +125,9 @@ export class TwitterPostClient { elizaLogger.log("Generating new tweet"); try { + const roomId = stringToUuid( + "twitter_generate_room-" + this.client.profile.username + ); await this.runtime.ensureUserExists( this.runtime.agentId, this.client.profile.username, @@ -157,7 +160,7 @@ export class TwitterPostClient { const state = await this.runtime.composeState( { userId: this.runtime.agentId, - roomId: stringToUuid("twitter_generate_room"), + roomId: roomId, agentId: this.runtime.agentId, content: { text: topics, @@ -221,6 +224,9 @@ export class TwitterPostClient { text: tweetResult.legacy.full_text, conversationId: tweetResult.legacy.conversation_id_str, createdAt: tweetResult.legacy.created_at, + timestamp: new Date( + tweetResult.legacy.created_at + ).getTime(), userId: this.client.profile.id, inReplyToStatusId: tweetResult.legacy.in_reply_to_status_id_str, @@ -247,10 +253,6 @@ export class TwitterPostClient { await this.client.cacheTimeline(homeTimeline); elizaLogger.log(`Tweet posted:\n ${tweet.permanentUrl}`); - const roomId = stringToUuid( - tweet.conversationId + "-" + this.runtime.agentId - ); - await this.runtime.ensureRoomExists(roomId); await this.runtime.ensureParticipantInRoom( this.runtime.agentId, @@ -268,7 +270,7 @@ export class TwitterPostClient { }, roomId, embedding: getEmbeddingZeroVector(), - createdAt: tweet.timestamp * 1000, + createdAt: tweet.timestamp, }); } catch (error) { elizaLogger.error("Error sending tweet:", error);