@elizaos/plugin-twitter 1.2.5 → 1.2.6
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 +61 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6344,7 +6344,8 @@ var TwitterInteractionClient = class {
|
|
|
6344
6344
|
createdAt: Date.now()
|
|
6345
6345
|
};
|
|
6346
6346
|
const state = await this.runtime.composeState(shouldEngageMemory);
|
|
6347
|
-
const
|
|
6347
|
+
const characterName = this.runtime?.character?.name || "AI Assistant";
|
|
6348
|
+
const context = `You are ${characterName}. Should you reply to this tweet based on your interests and expertise?
|
|
6348
6349
|
|
|
6349
6350
|
Tweet by @${tweet.username}: "${tweet.text}"
|
|
6350
6351
|
|
|
@@ -7463,8 +7464,26 @@ var TwitterDiscoveryClient = class {
|
|
|
7463
7464
|
});
|
|
7464
7465
|
}
|
|
7465
7466
|
buildDiscoveryConfig() {
|
|
7466
|
-
const character = this.runtime
|
|
7467
|
-
const
|
|
7467
|
+
const character = this.runtime?.character;
|
|
7468
|
+
const defaultTopics = [
|
|
7469
|
+
"ai",
|
|
7470
|
+
"technology",
|
|
7471
|
+
"blockchain",
|
|
7472
|
+
"web3",
|
|
7473
|
+
"crypto",
|
|
7474
|
+
"programming",
|
|
7475
|
+
"innovation"
|
|
7476
|
+
];
|
|
7477
|
+
let topics = defaultTopics;
|
|
7478
|
+
if (character) {
|
|
7479
|
+
if (character.topics && Array.isArray(character.topics) && character.topics.length > 0) {
|
|
7480
|
+
topics = character.topics;
|
|
7481
|
+
} else if (character.bio) {
|
|
7482
|
+
topics = this.extractTopicsFromBio(character.bio);
|
|
7483
|
+
}
|
|
7484
|
+
} else {
|
|
7485
|
+
logger6.warn("Character not available in runtime, using default topics for discovery");
|
|
7486
|
+
}
|
|
7468
7487
|
return {
|
|
7469
7488
|
topics,
|
|
7470
7489
|
minFollowerCount: parseInt(
|
|
@@ -7482,6 +7501,9 @@ var TwitterDiscoveryClient = class {
|
|
|
7482
7501
|
};
|
|
7483
7502
|
}
|
|
7484
7503
|
extractTopicsFromBio(bio) {
|
|
7504
|
+
if (!bio) {
|
|
7505
|
+
return [];
|
|
7506
|
+
}
|
|
7485
7507
|
const bioText = Array.isArray(bio) ? bio.join(" ") : bio;
|
|
7486
7508
|
const words = bioText.toLowerCase().split(/\s+/).filter((word) => word.length > 4).filter((word) => !["about", "helping", "working", "people", "making", "building"].includes(word));
|
|
7487
7509
|
return [...new Set(words)].slice(0, 5);
|
|
@@ -7814,12 +7836,21 @@ var TwitterDiscoveryClient = class {
|
|
|
7814
7836
|
return followMemories.length > 0;
|
|
7815
7837
|
}
|
|
7816
7838
|
async generateReply(tweet) {
|
|
7817
|
-
const
|
|
7839
|
+
const characterName = this.runtime?.character?.name || "AI Assistant";
|
|
7840
|
+
let characterBio = "";
|
|
7841
|
+
if (this.runtime?.character?.bio) {
|
|
7842
|
+
if (Array.isArray(this.runtime.character.bio)) {
|
|
7843
|
+
characterBio = this.runtime.character.bio.join(" ");
|
|
7844
|
+
} else {
|
|
7845
|
+
characterBio = this.runtime.character.bio;
|
|
7846
|
+
}
|
|
7847
|
+
}
|
|
7848
|
+
const prompt = `You are ${characterName}. Generate a thoughtful reply to this tweet:
|
|
7818
7849
|
|
|
7819
7850
|
Tweet by @${tweet.username}: "${tweet.text}"
|
|
7820
7851
|
|
|
7821
7852
|
Your interests: ${this.config.topics.join(", ")}
|
|
7822
|
-
Character bio: ${
|
|
7853
|
+
Character bio: ${characterBio}
|
|
7823
7854
|
|
|
7824
7855
|
Keep the reply:
|
|
7825
7856
|
- Relevant and adding value to the conversation
|
|
@@ -7837,12 +7868,21 @@ Reply:`;
|
|
|
7837
7868
|
return response.trim();
|
|
7838
7869
|
}
|
|
7839
7870
|
async generateQuote(tweet) {
|
|
7840
|
-
const
|
|
7871
|
+
const characterName = this.runtime?.character?.name || "AI Assistant";
|
|
7872
|
+
let characterBio = "";
|
|
7873
|
+
if (this.runtime?.character?.bio) {
|
|
7874
|
+
if (Array.isArray(this.runtime.character.bio)) {
|
|
7875
|
+
characterBio = this.runtime.character.bio.join(" ");
|
|
7876
|
+
} else {
|
|
7877
|
+
characterBio = this.runtime.character.bio;
|
|
7878
|
+
}
|
|
7879
|
+
}
|
|
7880
|
+
const prompt = `You are ${characterName}. Add your perspective to this tweet with a quote tweet:
|
|
7841
7881
|
|
|
7842
7882
|
Original tweet by @${tweet.username}: "${tweet.text}"
|
|
7843
7883
|
|
|
7844
7884
|
Your interests: ${this.config.topics.join(", ")}
|
|
7845
|
-
Character bio: ${
|
|
7885
|
+
Character bio: ${characterBio}
|
|
7846
7886
|
|
|
7847
7887
|
Create a quote tweet that:
|
|
7848
7888
|
- Adds unique insight or perspective
|
|
@@ -8414,11 +8454,23 @@ var _ClientBase = class _ClientBase {
|
|
|
8414
8454
|
try {
|
|
8415
8455
|
const profile = await this.requestQueue.add(async () => {
|
|
8416
8456
|
const profile2 = await this.twitterClient.getProfile(username);
|
|
8457
|
+
const defaultName = "AI Assistant";
|
|
8458
|
+
const defaultBio = "";
|
|
8459
|
+
let characterName = defaultName;
|
|
8460
|
+
let characterBio = defaultBio;
|
|
8461
|
+
if (this.runtime?.character) {
|
|
8462
|
+
characterName = this.runtime.character.name || defaultName;
|
|
8463
|
+
if (typeof this.runtime.character.bio === "string") {
|
|
8464
|
+
characterBio = this.runtime.character.bio;
|
|
8465
|
+
} else if (Array.isArray(this.runtime.character.bio) && this.runtime.character.bio.length > 0) {
|
|
8466
|
+
characterBio = this.runtime.character.bio[0];
|
|
8467
|
+
}
|
|
8468
|
+
}
|
|
8417
8469
|
return {
|
|
8418
8470
|
id: profile2.userId,
|
|
8419
8471
|
username,
|
|
8420
|
-
screenName: profile2.name ||
|
|
8421
|
-
bio: profile2.biography ||
|
|
8472
|
+
screenName: profile2.name || characterName,
|
|
8473
|
+
bio: profile2.biography || characterBio,
|
|
8422
8474
|
nicknames: this.profile?.nicknames || []
|
|
8423
8475
|
};
|
|
8424
8476
|
});
|