@elizaos/plugin-twitter 1.2.13 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +70 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6460,6 +6460,15 @@ Response (YES/NO):`;
|
|
|
6460
6460
|
}
|
|
6461
6461
|
});
|
|
6462
6462
|
const roomId = createUniqueUuid2(this.runtime, conversationId);
|
|
6463
|
+
await this.runtime.ensureRoomExists({
|
|
6464
|
+
id: roomId,
|
|
6465
|
+
name: `Twitter conversation ${conversationId}`,
|
|
6466
|
+
source: "twitter",
|
|
6467
|
+
type: ChannelType.FEED,
|
|
6468
|
+
channelId: conversationId,
|
|
6469
|
+
serverId: userId,
|
|
6470
|
+
worldId
|
|
6471
|
+
});
|
|
6463
6472
|
const entityId = createUniqueUuid2(this.runtime, userId);
|
|
6464
6473
|
await this.runtime.ensureConnection({
|
|
6465
6474
|
entityId,
|
|
@@ -6617,6 +6626,15 @@ Response (YES/NO):`;
|
|
|
6617
6626
|
type: ChannelType.FEED,
|
|
6618
6627
|
worldId
|
|
6619
6628
|
});
|
|
6629
|
+
await this.runtime.ensureRoomExists({
|
|
6630
|
+
id: roomId,
|
|
6631
|
+
name: `Twitter conversation ${conversationId}`,
|
|
6632
|
+
source: "twitter",
|
|
6633
|
+
type: ChannelType.FEED,
|
|
6634
|
+
channelId: conversationId,
|
|
6635
|
+
serverId: userId,
|
|
6636
|
+
worldId
|
|
6637
|
+
});
|
|
6620
6638
|
const memory = {
|
|
6621
6639
|
id: tweetId,
|
|
6622
6640
|
entityId,
|
|
@@ -6894,6 +6912,7 @@ Response (YES/NO):`;
|
|
|
6894
6912
|
|
|
6895
6913
|
// src/post.ts
|
|
6896
6914
|
import {
|
|
6915
|
+
ChannelType as ChannelType2,
|
|
6897
6916
|
createUniqueUuid as createUniqueUuid3,
|
|
6898
6917
|
logger as logger4,
|
|
6899
6918
|
ModelType as ModelType2
|
|
@@ -7089,7 +7108,40 @@ Generate a single tweet that sounds like YOU would actually write it:`;
|
|
|
7089
7108
|
logger4.info(`Tweet posted successfully! ID: ${tweetId}`);
|
|
7090
7109
|
if (result) {
|
|
7091
7110
|
const postedTweetId = createUniqueUuid3(this.runtime, tweetId);
|
|
7092
|
-
|
|
7111
|
+
await this.runtime.ensureWorldExists({
|
|
7112
|
+
id: worldId,
|
|
7113
|
+
name: `${this.client.profile?.username}'s Twitter`,
|
|
7114
|
+
agentId: this.runtime.agentId,
|
|
7115
|
+
serverId: userId
|
|
7116
|
+
});
|
|
7117
|
+
await this.runtime.ensureRoomExists({
|
|
7118
|
+
id: roomId,
|
|
7119
|
+
name: `${this.client.profile?.username}'s Timeline`,
|
|
7120
|
+
source: "twitter",
|
|
7121
|
+
type: ChannelType2.FEED,
|
|
7122
|
+
channelId: `${userId}-home`,
|
|
7123
|
+
serverId: userId,
|
|
7124
|
+
worldId
|
|
7125
|
+
});
|
|
7126
|
+
const postedMemory = {
|
|
7127
|
+
id: postedTweetId,
|
|
7128
|
+
entityId: this.runtime.agentId,
|
|
7129
|
+
agentId: this.runtime.agentId,
|
|
7130
|
+
roomId,
|
|
7131
|
+
content: {
|
|
7132
|
+
text: tweetText,
|
|
7133
|
+
source: "twitter",
|
|
7134
|
+
channelType: ChannelType2.FEED,
|
|
7135
|
+
type: "post",
|
|
7136
|
+
metadata: {
|
|
7137
|
+
tweetId,
|
|
7138
|
+
postedAt: Date.now()
|
|
7139
|
+
}
|
|
7140
|
+
},
|
|
7141
|
+
createdAt: Date.now()
|
|
7142
|
+
};
|
|
7143
|
+
await this.runtime.createMemory(postedMemory, "messages");
|
|
7144
|
+
logger4.info("Tweet posted and saved to memory successfully");
|
|
7093
7145
|
}
|
|
7094
7146
|
} catch (error) {
|
|
7095
7147
|
logger4.error("Error generating tweet:", error);
|
|
@@ -7377,6 +7429,15 @@ ${actionSummary.join("\n")}`);
|
|
|
7377
7429
|
} of tweetDecisions) {
|
|
7378
7430
|
const tweetId = this.createTweetId(this.runtime, tweet);
|
|
7379
7431
|
const executedActions = [];
|
|
7432
|
+
await this.runtime.ensureRoomExists({
|
|
7433
|
+
id: roomId,
|
|
7434
|
+
name: `Twitter conversation ${tweet.conversationId}`,
|
|
7435
|
+
source: "twitter",
|
|
7436
|
+
type: ChannelType3.GROUP,
|
|
7437
|
+
channelId: tweet.conversationId,
|
|
7438
|
+
serverId: tweet.userId,
|
|
7439
|
+
worldId: createUniqueUuid4(this.runtime, tweet.userId)
|
|
7440
|
+
});
|
|
7380
7441
|
await this.runtime.createMemory(
|
|
7381
7442
|
{
|
|
7382
7443
|
id: tweetId,
|
|
@@ -8120,43 +8181,12 @@ Quote tweet:`;
|
|
|
8120
8181
|
return response.trim();
|
|
8121
8182
|
}
|
|
8122
8183
|
async saveEngagementMemory(tweet, engagementType) {
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
id: createUniqueUuid5(this.runtime, tweet.id),
|
|
8126
|
-
entityId: createUniqueUuid5(this.runtime, tweet.userId),
|
|
8127
|
-
content: {
|
|
8128
|
-
text: `${engagementType} tweet from @${tweet.username}: ${tweet.text}`,
|
|
8129
|
-
metadata: {
|
|
8130
|
-
tweetId: tweet.id,
|
|
8131
|
-
engagementType,
|
|
8132
|
-
source: "discovery",
|
|
8133
|
-
isDryRun: this.isDryRun
|
|
8134
|
-
}
|
|
8135
|
-
},
|
|
8136
|
-
roomId: createUniqueUuid5(this.runtime, tweet.conversationId)
|
|
8137
|
-
},
|
|
8138
|
-
"messages"
|
|
8139
|
-
);
|
|
8184
|
+
logger6.debug(`[Discovery] Would save engagement memory for ${engagementType} on tweet ${tweet.id}`);
|
|
8185
|
+
return;
|
|
8140
8186
|
}
|
|
8141
8187
|
async saveFollowMemory(user) {
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
entityId: createUniqueUuid5(this.runtime, user.id),
|
|
8145
|
-
content: {
|
|
8146
|
-
text: `followed twitter user ${user.id} @${user.username}`,
|
|
8147
|
-
metadata: {
|
|
8148
|
-
userId: user.id,
|
|
8149
|
-
username: user.username,
|
|
8150
|
-
name: user.name,
|
|
8151
|
-
followersCount: user.followersCount,
|
|
8152
|
-
source: "discovery",
|
|
8153
|
-
isDryRun: this.isDryRun
|
|
8154
|
-
}
|
|
8155
|
-
},
|
|
8156
|
-
roomId: createUniqueUuid5(this.runtime, `twitter-follows`)
|
|
8157
|
-
},
|
|
8158
|
-
"messages"
|
|
8159
|
-
);
|
|
8188
|
+
logger6.debug(`[Discovery] Would save follow memory for @${user.username}`);
|
|
8189
|
+
return;
|
|
8160
8190
|
}
|
|
8161
8191
|
delay(ms) {
|
|
8162
8192
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -8877,6 +8907,10 @@ var postTweetAction = {
|
|
|
8877
8907
|
roomId: message.roomId,
|
|
8878
8908
|
entityId: message.entityId
|
|
8879
8909
|
});
|
|
8910
|
+
if (message.content?.type === "post" && !message.content?.text) {
|
|
8911
|
+
logger9.debug("Skipping validation for provider context (empty post type)");
|
|
8912
|
+
return false;
|
|
8913
|
+
}
|
|
8880
8914
|
const text = message.content?.text?.trim();
|
|
8881
8915
|
if (!text || text.length === 0) {
|
|
8882
8916
|
logger9.error("No text content for tweet");
|