@elizaos/plugin-twitter 1.2.2 → 1.2.4
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 +57 -58
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6077,29 +6077,28 @@ function getTargetUsers(targetUsersConfig) {
|
|
|
6077
6077
|
const users = parseTargetUsers(targetUsersConfig);
|
|
6078
6078
|
return users.filter((u) => u !== "*");
|
|
6079
6079
|
}
|
|
6080
|
+
function getSetting(runtime, key, defaultValue) {
|
|
6081
|
+
return runtime.getSetting(key) ?? process.env[key] ?? defaultValue;
|
|
6082
|
+
}
|
|
6080
6083
|
async function validateTwitterConfig(runtime, config = {}) {
|
|
6081
6084
|
try {
|
|
6082
|
-
const getConfig = (key) => {
|
|
6083
|
-
return config[key] || runtime.getSetting(key) || process.env[key] || void 0;
|
|
6084
|
-
};
|
|
6085
6085
|
const validatedConfig = {
|
|
6086
|
-
TWITTER_API_KEY:
|
|
6087
|
-
TWITTER_API_SECRET_KEY:
|
|
6088
|
-
TWITTER_ACCESS_TOKEN:
|
|
6089
|
-
TWITTER_ACCESS_TOKEN_SECRET:
|
|
6090
|
-
TWITTER_DRY_RUN: String(
|
|
6091
|
-
TWITTER_TARGET_USERS:
|
|
6092
|
-
TWITTER_ENABLE_POST: String(
|
|
6086
|
+
TWITTER_API_KEY: config.TWITTER_API_KEY ?? getSetting(runtime, "TWITTER_API_KEY") ?? "",
|
|
6087
|
+
TWITTER_API_SECRET_KEY: config.TWITTER_API_SECRET_KEY ?? getSetting(runtime, "TWITTER_API_SECRET_KEY") ?? "",
|
|
6088
|
+
TWITTER_ACCESS_TOKEN: config.TWITTER_ACCESS_TOKEN ?? getSetting(runtime, "TWITTER_ACCESS_TOKEN") ?? "",
|
|
6089
|
+
TWITTER_ACCESS_TOKEN_SECRET: config.TWITTER_ACCESS_TOKEN_SECRET ?? getSetting(runtime, "TWITTER_ACCESS_TOKEN_SECRET") ?? "",
|
|
6090
|
+
TWITTER_DRY_RUN: String((config.TWITTER_DRY_RUN ?? getSetting(runtime, "TWITTER_DRY_RUN") ?? "false").toLowerCase() === "true"),
|
|
6091
|
+
TWITTER_TARGET_USERS: config.TWITTER_TARGET_USERS ?? getSetting(runtime, "TWITTER_TARGET_USERS") ?? "",
|
|
6092
|
+
TWITTER_ENABLE_POST: String((config.TWITTER_ENABLE_POST ?? getSetting(runtime, "TWITTER_ENABLE_POST") ?? "false").toLowerCase() === "true"),
|
|
6093
6093
|
TWITTER_ENABLE_REPLIES: String(
|
|
6094
|
-
|
|
6095
|
-
// Default to true
|
|
6094
|
+
config.TWITTER_ENABLE_REPLIES !== void 0 ? config.TWITTER_ENABLE_REPLIES.toLowerCase() === "true" : (getSetting(runtime, "TWITTER_ENABLE_REPLIES") ?? "true").toLowerCase() === "true"
|
|
6096
6095
|
),
|
|
6097
|
-
TWITTER_ENABLE_ACTIONS: String(
|
|
6098
|
-
TWITTER_POST_INTERVAL: String(safeParseInt(
|
|
6099
|
-
TWITTER_ENGAGEMENT_INTERVAL: String(safeParseInt(
|
|
6100
|
-
TWITTER_MAX_ENGAGEMENTS_PER_RUN: String(safeParseInt(
|
|
6101
|
-
TWITTER_MAX_TWEET_LENGTH: String(safeParseInt(
|
|
6102
|
-
TWITTER_RETRY_LIMIT: String(safeParseInt(
|
|
6096
|
+
TWITTER_ENABLE_ACTIONS: String((config.TWITTER_ENABLE_ACTIONS ?? getSetting(runtime, "TWITTER_ENABLE_ACTIONS") ?? "false").toLowerCase() === "true"),
|
|
6097
|
+
TWITTER_POST_INTERVAL: String(safeParseInt(config.TWITTER_POST_INTERVAL ?? getSetting(runtime, "TWITTER_POST_INTERVAL"), 120)),
|
|
6098
|
+
TWITTER_ENGAGEMENT_INTERVAL: String(safeParseInt(config.TWITTER_ENGAGEMENT_INTERVAL ?? getSetting(runtime, "TWITTER_ENGAGEMENT_INTERVAL"), 30)),
|
|
6099
|
+
TWITTER_MAX_ENGAGEMENTS_PER_RUN: String(safeParseInt(config.TWITTER_MAX_ENGAGEMENTS_PER_RUN ?? getSetting(runtime, "TWITTER_MAX_ENGAGEMENTS_PER_RUN"), 10)),
|
|
6100
|
+
TWITTER_MAX_TWEET_LENGTH: String(safeParseInt(config.TWITTER_MAX_TWEET_LENGTH ?? getSetting(runtime, "TWITTER_MAX_TWEET_LENGTH"), 280)),
|
|
6101
|
+
TWITTER_RETRY_LIMIT: String(safeParseInt(config.TWITTER_RETRY_LIMIT ?? getSetting(runtime, "TWITTER_RETRY_LIMIT"), 5))
|
|
6103
6102
|
};
|
|
6104
6103
|
if (!validatedConfig.TWITTER_API_KEY || !validatedConfig.TWITTER_API_SECRET_KEY || !validatedConfig.TWITTER_ACCESS_TOKEN || !validatedConfig.TWITTER_ACCESS_TOKEN_SECRET) {
|
|
6105
6104
|
throw new Error(
|
|
@@ -6133,7 +6132,8 @@ var TwitterInteractionClient = class {
|
|
|
6133
6132
|
this.client = client;
|
|
6134
6133
|
this.runtime = runtime;
|
|
6135
6134
|
this.state = state;
|
|
6136
|
-
|
|
6135
|
+
const dryRunSetting = this.state?.TWITTER_DRY_RUN ?? this.runtime.getSetting("TWITTER_DRY_RUN") ?? process.env.TWITTER_DRY_RUN;
|
|
6136
|
+
this.isDryRun = dryRunSetting === true || dryRunSetting === "true" || typeof dryRunSetting === "string" && dryRunSetting.toLowerCase() === "true";
|
|
6137
6137
|
}
|
|
6138
6138
|
/**
|
|
6139
6139
|
* Asynchronously starts the process of handling Twitter interactions on a loop.
|
|
@@ -6147,7 +6147,7 @@ var TwitterInteractionClient = class {
|
|
|
6147
6147
|
return;
|
|
6148
6148
|
}
|
|
6149
6149
|
const engagementIntervalMinutes = parseInt(
|
|
6150
|
-
this.state?.TWITTER_ENGAGEMENT_INTERVAL || this.runtime.getSetting("TWITTER_ENGAGEMENT_INTERVAL") || "30"
|
|
6150
|
+
this.state?.TWITTER_ENGAGEMENT_INTERVAL || this.runtime.getSetting("TWITTER_ENGAGEMENT_INTERVAL") || process.env.TWITTER_ENGAGEMENT_INTERVAL || "30"
|
|
6151
6151
|
);
|
|
6152
6152
|
const interactionInterval = engagementIntervalMinutes * 60 * 1e3;
|
|
6153
6153
|
logger3.info(`Twitter interaction client will check every ${engagementIntervalMinutes} minutes`);
|
|
@@ -6172,11 +6172,11 @@ var TwitterInteractionClient = class {
|
|
|
6172
6172
|
logger3.log("Checking Twitter interactions");
|
|
6173
6173
|
const twitterUsername = this.client.profile?.username;
|
|
6174
6174
|
try {
|
|
6175
|
-
const repliesEnabled = this.runtime.getSetting("TWITTER_ENABLE_REPLIES") !== "false";
|
|
6175
|
+
const repliesEnabled = (this.runtime.getSetting("TWITTER_ENABLE_REPLIES") ?? process.env.TWITTER_ENABLE_REPLIES) !== "false";
|
|
6176
6176
|
if (repliesEnabled) {
|
|
6177
6177
|
await this.handleMentions(twitterUsername);
|
|
6178
6178
|
}
|
|
6179
|
-
const targetUsersConfig = this.runtime.getSetting("TWITTER_TARGET_USERS") || "";
|
|
6179
|
+
const targetUsersConfig = (this.runtime.getSetting("TWITTER_TARGET_USERS") ?? process.env.TWITTER_TARGET_USERS) || "";
|
|
6180
6180
|
if (targetUsersConfig?.trim()) {
|
|
6181
6181
|
await this.handleTargetUserPosts(targetUsersConfig);
|
|
6182
6182
|
}
|
|
@@ -6250,7 +6250,7 @@ var TwitterInteractionClient = class {
|
|
|
6250
6250
|
*/
|
|
6251
6251
|
async processTargetUserTweets(tweets, username) {
|
|
6252
6252
|
const maxEngagementsPerRun = parseInt(
|
|
6253
|
-
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || "10"
|
|
6253
|
+
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || process.env.TWITTER_MAX_ENGAGEMENTS_PER_RUN || "10"
|
|
6254
6254
|
);
|
|
6255
6255
|
let engagementCount = 0;
|
|
6256
6256
|
for (const tweet of tweets) {
|
|
@@ -6446,7 +6446,7 @@ Response (YES/NO):`;
|
|
|
6446
6446
|
);
|
|
6447
6447
|
let uniqueTweetCandidates = [...mentionCandidates];
|
|
6448
6448
|
uniqueTweetCandidates = uniqueTweetCandidates.sort((a, b) => a.id.localeCompare(b.id)).filter((tweet) => tweet.userId !== this.client.profile.id);
|
|
6449
|
-
const targetUsersConfig = this.runtime.getSetting("TWITTER_TARGET_USERS") || "";
|
|
6449
|
+
const targetUsersConfig = (this.runtime.getSetting("TWITTER_TARGET_USERS") ?? process.env.TWITTER_TARGET_USERS) || "";
|
|
6450
6450
|
if (targetUsersConfig?.trim()) {
|
|
6451
6451
|
uniqueTweetCandidates = uniqueTweetCandidates.filter((tweet) => {
|
|
6452
6452
|
const shouldTarget = shouldTargetUser(
|
|
@@ -6462,7 +6462,7 @@ Response (YES/NO):`;
|
|
|
6462
6462
|
});
|
|
6463
6463
|
}
|
|
6464
6464
|
const maxInteractionsPerRun = parseInt(
|
|
6465
|
-
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || "10"
|
|
6465
|
+
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || process.env.TWITTER_MAX_ENGAGEMENTS_PER_RUN || "10"
|
|
6466
6466
|
);
|
|
6467
6467
|
const tweetsToProcess = uniqueTweetCandidates.slice(0, maxInteractionsPerRun);
|
|
6468
6468
|
logger3.info(`Processing ${tweetsToProcess.length} of ${uniqueTweetCandidates.length} mention tweets (max: ${maxInteractionsPerRun})`);
|
|
@@ -6821,12 +6821,12 @@ var TwitterPostClient = class {
|
|
|
6821
6821
|
this.client = client;
|
|
6822
6822
|
this.state = state;
|
|
6823
6823
|
this.runtime = runtime;
|
|
6824
|
-
const dryRunSetting = this.state?.TWITTER_DRY_RUN ?? this.runtime.getSetting("TWITTER_DRY_RUN");
|
|
6824
|
+
const dryRunSetting = this.state?.TWITTER_DRY_RUN ?? this.runtime.getSetting("TWITTER_DRY_RUN") ?? process.env.TWITTER_DRY_RUN;
|
|
6825
6825
|
this.isDryRun = dryRunSetting === true || dryRunSetting === "true" || typeof dryRunSetting === "string" && dryRunSetting.toLowerCase() === "true";
|
|
6826
6826
|
logger4.log("Twitter Post Client Configuration:");
|
|
6827
6827
|
logger4.log(`- Dry Run Mode: ${this.isDryRun ? "Enabled" : "Disabled"}`);
|
|
6828
6828
|
const postInterval = parseInt(
|
|
6829
|
-
this.state?.TWITTER_POST_INTERVAL || this.runtime.getSetting("TWITTER_POST_INTERVAL") || "120"
|
|
6829
|
+
this.state?.TWITTER_POST_INTERVAL || this.runtime.getSetting("TWITTER_POST_INTERVAL") || process.env.TWITTER_POST_INTERVAL || "120"
|
|
6830
6830
|
);
|
|
6831
6831
|
logger4.log(`- Post Interval: ${postInterval} minutes`);
|
|
6832
6832
|
}
|
|
@@ -6848,25 +6848,25 @@ var TwitterPostClient = class {
|
|
|
6848
6848
|
logger4.log("Twitter post client stopped, exiting loop");
|
|
6849
6849
|
return;
|
|
6850
6850
|
}
|
|
6851
|
-
const
|
|
6852
|
-
this.state?.TWITTER_POST_INTERVAL || this.runtime.getSetting("TWITTER_POST_INTERVAL") || "120"
|
|
6851
|
+
const postIntervalMinutes = parseInt(
|
|
6852
|
+
this.state?.TWITTER_POST_INTERVAL || this.runtime.getSetting("TWITTER_POST_INTERVAL") || process.env.TWITTER_POST_INTERVAL || "120"
|
|
6853
6853
|
);
|
|
6854
|
-
const
|
|
6855
|
-
logger4.info(`Next tweet scheduled in ${
|
|
6854
|
+
const interval = postIntervalMinutes * 60 * 1e3;
|
|
6855
|
+
logger4.info(`Next tweet scheduled in ${postIntervalMinutes} minutes`);
|
|
6856
6856
|
await this.generateNewTweet();
|
|
6857
6857
|
if (this.isRunning) {
|
|
6858
|
-
setTimeout(generateNewTweetLoop,
|
|
6858
|
+
setTimeout(generateNewTweetLoop, interval);
|
|
6859
6859
|
}
|
|
6860
6860
|
};
|
|
6861
6861
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
)
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
setTimeout(generateNewTweetLoop, interval);
|
|
6862
|
+
const postImmediately = parseInt(
|
|
6863
|
+
this.state?.TWITTER_POST_INTERVAL || this.runtime.getSetting("TWITTER_POST_INTERVAL") || process.env.TWITTER_POST_INTERVAL || "120"
|
|
6864
|
+
) === 0;
|
|
6865
|
+
if (postImmediately) {
|
|
6866
|
+
logger4.info("TWITTER_POST_IMMEDIATELY is true, generating initial tweet now");
|
|
6867
|
+
await this.generateNewTweet();
|
|
6869
6868
|
}
|
|
6869
|
+
generateNewTweetLoop();
|
|
6870
6870
|
}
|
|
6871
6871
|
/**
|
|
6872
6872
|
* Handles the creation and posting of a tweet by emitting standardized events.
|
|
@@ -7076,10 +7076,9 @@ var TwitterTimelineClient = class {
|
|
|
7076
7076
|
this.twitterClient = client.twitterClient;
|
|
7077
7077
|
this.runtime = runtime;
|
|
7078
7078
|
this.state = state;
|
|
7079
|
-
const dryRunSetting = this.state?.TWITTER_DRY_RUN ?? this.runtime.getSetting("TWITTER_DRY_RUN");
|
|
7079
|
+
const dryRunSetting = this.state?.TWITTER_DRY_RUN ?? this.runtime.getSetting("TWITTER_DRY_RUN") ?? process.env.TWITTER_DRY_RUN;
|
|
7080
7080
|
this.isDryRun = dryRunSetting === true || dryRunSetting === "true" || typeof dryRunSetting === "string" && dryRunSetting.toLowerCase() === "true";
|
|
7081
|
-
|
|
7082
|
-
this.timelineType = timelineMode.toLowerCase() === "following" ? "following" /* Following */ : "foryou" /* ForYou */;
|
|
7081
|
+
this.timelineType = (this.runtime.getSetting("TWITTER_TIMELINE_MODE") ?? process.env.TWITTER_TIMELINE_MODE) || "foryou" /* ForYou */;
|
|
7083
7082
|
}
|
|
7084
7083
|
async start() {
|
|
7085
7084
|
logger5.info("Starting Twitter timeline client...");
|
|
@@ -7090,7 +7089,7 @@ var TwitterTimelineClient = class {
|
|
|
7090
7089
|
return;
|
|
7091
7090
|
}
|
|
7092
7091
|
const engagementIntervalMinutes = parseInt(
|
|
7093
|
-
this.state?.TWITTER_ENGAGEMENT_INTERVAL || this.runtime.getSetting("TWITTER_ENGAGEMENT_INTERVAL") || "30"
|
|
7092
|
+
this.state?.TWITTER_ENGAGEMENT_INTERVAL || this.runtime.getSetting("TWITTER_ENGAGEMENT_INTERVAL") || process.env.TWITTER_ENGAGEMENT_INTERVAL || "30"
|
|
7094
7093
|
);
|
|
7095
7094
|
const actionInterval = engagementIntervalMinutes * 60 * 1e3;
|
|
7096
7095
|
logger5.info(`Timeline client will check every ${engagementIntervalMinutes} minutes`);
|
|
@@ -7136,7 +7135,7 @@ var TwitterTimelineClient = class {
|
|
|
7136
7135
|
const tweets = await this.getTimeline(20);
|
|
7137
7136
|
logger5.info(`Fetched ${tweets.length} tweets from timeline`);
|
|
7138
7137
|
const maxActionsPerCycle = parseInt(
|
|
7139
|
-
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || "10"
|
|
7138
|
+
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || process.env.TWITTER_MAX_ENGAGEMENTS_PER_RUN || "10"
|
|
7140
7139
|
);
|
|
7141
7140
|
const tweetDecisions = [];
|
|
7142
7141
|
for (const tweet of tweets) {
|
|
@@ -7434,7 +7433,7 @@ var TwitterDiscoveryClient = class {
|
|
|
7434
7433
|
this.client = client;
|
|
7435
7434
|
this.twitterClient = client.twitterClient;
|
|
7436
7435
|
this.runtime = runtime;
|
|
7437
|
-
const dryRunSetting = state?.TWITTER_DRY_RUN ?? this.runtime.getSetting("TWITTER_DRY_RUN");
|
|
7436
|
+
const dryRunSetting = state?.TWITTER_DRY_RUN ?? this.runtime.getSetting("TWITTER_DRY_RUN") ?? process.env.TWITTER_DRY_RUN;
|
|
7438
7437
|
this.isDryRun = dryRunSetting === true || dryRunSetting === "true" || typeof dryRunSetting === "string" && dryRunSetting.toLowerCase() === "true";
|
|
7439
7438
|
this.config = this.buildDiscoveryConfig();
|
|
7440
7439
|
logger6.info("Twitter Discovery Config:", {
|
|
@@ -7451,13 +7450,13 @@ var TwitterDiscoveryClient = class {
|
|
|
7451
7450
|
return {
|
|
7452
7451
|
topics,
|
|
7453
7452
|
minFollowerCount: parseInt(
|
|
7454
|
-
this.runtime.getSetting("TWITTER_MIN_FOLLOWER_COUNT") || "100"
|
|
7453
|
+
this.runtime.getSetting("TWITTER_MIN_FOLLOWER_COUNT") || process.env.TWITTER_MIN_FOLLOWER_COUNT || "100"
|
|
7455
7454
|
),
|
|
7456
7455
|
maxFollowsPerCycle: parseInt(
|
|
7457
|
-
this.runtime.getSetting("TWITTER_MAX_FOLLOWS_PER_CYCLE") || "5"
|
|
7456
|
+
this.runtime.getSetting("TWITTER_MAX_FOLLOWS_PER_CYCLE") || process.env.TWITTER_MAX_FOLLOWS_PER_CYCLE || "5"
|
|
7458
7457
|
),
|
|
7459
7458
|
maxEngagementsPerCycle: parseInt(
|
|
7460
|
-
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || "10"
|
|
7459
|
+
this.runtime.getSetting("TWITTER_MAX_ENGAGEMENTS_PER_RUN") || process.env.TWITTER_MAX_ENGAGEMENTS_PER_RUN || "10"
|
|
7461
7460
|
),
|
|
7462
7461
|
likeThreshold: 0.6,
|
|
7463
7462
|
replyThreshold: 0.8,
|
|
@@ -7483,7 +7482,7 @@ var TwitterDiscoveryClient = class {
|
|
|
7483
7482
|
logger6.error("Discovery cycle error:", error);
|
|
7484
7483
|
}
|
|
7485
7484
|
const baseInterval = parseInt(
|
|
7486
|
-
this.runtime.getSetting("TWITTER_DISCOVERY_INTERVAL") || "30"
|
|
7485
|
+
this.runtime.getSetting("TWITTER_DISCOVERY_INTERVAL") || process.env.TWITTER_DISCOVERY_INTERVAL || "30"
|
|
7487
7486
|
);
|
|
7488
7487
|
const variance = Math.random() * 20 - 10;
|
|
7489
7488
|
const nextInterval = (baseInterval + variance) * 60 * 1e3;
|
|
@@ -7975,7 +7974,7 @@ var _ClientBase = class _ClientBase {
|
|
|
7975
7974
|
this.callback = null;
|
|
7976
7975
|
this.runtime = runtime;
|
|
7977
7976
|
this.state = state;
|
|
7978
|
-
const apiKey = state?.TWITTER_API_KEY ||
|
|
7977
|
+
const apiKey = state?.TWITTER_API_KEY || runtime.getSetting("TWITTER_API_KEY") || process.env.TWITTER_API_KEY;
|
|
7979
7978
|
if (apiKey && _ClientBase._twitterClients[apiKey]) {
|
|
7980
7979
|
this.twitterClient = _ClientBase._twitterClients[apiKey];
|
|
7981
7980
|
} else {
|
|
@@ -8039,10 +8038,10 @@ var _ClientBase = class _ClientBase {
|
|
|
8039
8038
|
throw new Error("Not implemented in base class, please call from subclass");
|
|
8040
8039
|
}
|
|
8041
8040
|
async init() {
|
|
8042
|
-
const apiKey = this.state?.TWITTER_API_KEY || this.runtime.getSetting("TWITTER_API_KEY");
|
|
8043
|
-
const apiSecretKey = this.state?.TWITTER_API_SECRET_KEY || this.runtime.getSetting("TWITTER_API_SECRET_KEY");
|
|
8044
|
-
const accessToken = this.state?.TWITTER_ACCESS_TOKEN || this.runtime.getSetting("TWITTER_ACCESS_TOKEN");
|
|
8045
|
-
const accessTokenSecret = this.state?.TWITTER_ACCESS_TOKEN_SECRET || this.runtime.getSetting("TWITTER_ACCESS_TOKEN_SECRET");
|
|
8041
|
+
const apiKey = this.state?.TWITTER_API_KEY || this.runtime.getSetting("TWITTER_API_KEY") || process.env.TWITTER_API_KEY;
|
|
8042
|
+
const apiSecretKey = this.state?.TWITTER_API_SECRET_KEY || this.runtime.getSetting("TWITTER_API_SECRET_KEY") || process.env.TWITTER_API_SECRET_KEY;
|
|
8043
|
+
const accessToken = this.state?.TWITTER_ACCESS_TOKEN || this.runtime.getSetting("TWITTER_ACCESS_TOKEN") || process.env.TWITTER_ACCESS_TOKEN;
|
|
8044
|
+
const accessTokenSecret = this.state?.TWITTER_ACCESS_TOKEN_SECRET || this.runtime.getSetting("TWITTER_ACCESS_TOKEN_SECRET") || process.env.TWITTER_ACCESS_TOKEN_SECRET;
|
|
8046
8045
|
if (!apiKey || !apiSecretKey || !accessToken || !accessTokenSecret) {
|
|
8047
8046
|
const missing = [];
|
|
8048
8047
|
if (!apiKey) missing.push("TWITTER_API_KEY");
|
|
@@ -8637,7 +8636,7 @@ View it here: ${tweetUrl}`,
|
|
|
8637
8636
|
var TwitterClientInstance = class {
|
|
8638
8637
|
constructor(runtime, state) {
|
|
8639
8638
|
this.client = new ClientBase(runtime, state);
|
|
8640
|
-
const postEnabledSetting = runtime.getSetting("TWITTER_ENABLE_POST");
|
|
8639
|
+
const postEnabledSetting = runtime.getSetting("TWITTER_ENABLE_POST") ?? process.env.TWITTER_ENABLE_POST;
|
|
8641
8640
|
logger9.debug(`TWITTER_ENABLE_POST setting value: ${JSON.stringify(postEnabledSetting)}, type: ${typeof postEnabledSetting}`);
|
|
8642
8641
|
const postEnabled = postEnabledSetting === "true" || postEnabledSetting === true;
|
|
8643
8642
|
if (postEnabled) {
|
|
@@ -8646,7 +8645,7 @@ var TwitterClientInstance = class {
|
|
|
8646
8645
|
} else {
|
|
8647
8646
|
logger9.info("Twitter posting is DISABLED - set TWITTER_ENABLE_POST=true to enable automatic posting");
|
|
8648
8647
|
}
|
|
8649
|
-
const repliesEnabled = runtime.getSetting("TWITTER_ENABLE_REPLIES") !== "false";
|
|
8648
|
+
const repliesEnabled = (runtime.getSetting("TWITTER_ENABLE_REPLIES") ?? process.env.TWITTER_ENABLE_REPLIES) !== "false";
|
|
8650
8649
|
if (repliesEnabled) {
|
|
8651
8650
|
logger9.info("Twitter replies/interactions are ENABLED");
|
|
8652
8651
|
this.interaction = new TwitterInteractionClient(
|
|
@@ -8657,14 +8656,14 @@ var TwitterClientInstance = class {
|
|
|
8657
8656
|
} else {
|
|
8658
8657
|
logger9.info("Twitter replies/interactions are DISABLED");
|
|
8659
8658
|
}
|
|
8660
|
-
const actionsEnabled = runtime.getSetting("TWITTER_ENABLE_ACTIONS") === "true";
|
|
8659
|
+
const actionsEnabled = (runtime.getSetting("TWITTER_ENABLE_ACTIONS") ?? process.env.TWITTER_ENABLE_ACTIONS) === "true";
|
|
8661
8660
|
if (actionsEnabled) {
|
|
8662
8661
|
logger9.info("Twitter timeline actions are ENABLED");
|
|
8663
8662
|
this.timeline = new TwitterTimelineClient(this.client, runtime, state);
|
|
8664
8663
|
} else {
|
|
8665
8664
|
logger9.info("Twitter timeline actions are DISABLED");
|
|
8666
8665
|
}
|
|
8667
|
-
const discoveryEnabled = runtime.getSetting("TWITTER_ENABLE_DISCOVERY") === "true" || actionsEnabled && runtime.getSetting("TWITTER_ENABLE_DISCOVERY") !== "false";
|
|
8666
|
+
const discoveryEnabled = (runtime.getSetting("TWITTER_ENABLE_DISCOVERY") ?? process.env.TWITTER_ENABLE_DISCOVERY) === "true" || actionsEnabled && (runtime.getSetting("TWITTER_ENABLE_DISCOVERY") ?? process.env.TWITTER_ENABLE_DISCOVERY) !== "false";
|
|
8668
8667
|
if (discoveryEnabled) {
|
|
8669
8668
|
logger9.info("Twitter discovery service is ENABLED");
|
|
8670
8669
|
this.discovery = new TwitterDiscoveryClient(this.client, runtime, state);
|