Skip to content

Commit

Permalink
Merge pull request #756 from ai16z/tcm-twitter-recent-post
Browse files Browse the repository at this point in the history
fix: recentPosts always empty
  • Loading branch information
lalalune authored Dec 1, 2024
2 parents 85f2197 + 07aabf1 commit 0ef8f2a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/client-twitter/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,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,
Expand All @@ -135,7 +138,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,
Expand Down Expand Up @@ -198,6 +201,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,
Expand All @@ -222,10 +228,6 @@ export class TwitterPostClient {

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,
Expand All @@ -243,7 +245,7 @@ export class TwitterPostClient {
},
roomId,
embedding: getEmbeddingZeroVector(),
createdAt: tweet.timestamp * 1000,
createdAt: tweet.timestamp,
});
} catch (error) {
elizaLogger.error("Error sending tweet:", error);
Expand Down

0 comments on commit 0ef8f2a

Please sign in to comment.