Multi-account support: credentials keyed by account name
- prompts.json now has account field per prompt - bot.js looks up env vars by account prefix (e.g. THEJUNIPERSKY_USER) - .env restructured with account-prefixed credentials - Adding a new Twitter account = new env vars + new prompt blocks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
13
bot.js
13
bot.js
@@ -105,11 +105,12 @@ async function readPage(kernel, sessionId) {
|
||||
return result.result;
|
||||
}
|
||||
|
||||
async function login(kernel, sessionId) {
|
||||
const xAcct = JSON.stringify(process.env.X_ACCT);
|
||||
const xPw = JSON.stringify(process.env.X_PW);
|
||||
const xEmail = JSON.stringify(process.env.X_EMAIL);
|
||||
const xPhone = JSON.stringify(process.env.X_PHONE);
|
||||
async function login(kernel, sessionId, account) {
|
||||
const prefix = account.toUpperCase();
|
||||
const xAcct = JSON.stringify(process.env[`${prefix}_USER`]);
|
||||
const xPw = JSON.stringify(process.env[`${prefix}_PW`]);
|
||||
const xEmail = JSON.stringify(process.env[`${prefix}_EMAIL`]);
|
||||
const xPhone = JSON.stringify(process.env[`${prefix}_PHONE`]);
|
||||
|
||||
await exec(kernel, sessionId, `
|
||||
await page.goto('https://x.com/login', { waitUntil: 'networkidle' });
|
||||
@@ -232,7 +233,7 @@ async function main() {
|
||||
console.log(`[${promptName}] Session: ${sessionId}`);
|
||||
|
||||
try {
|
||||
const url = await login(kernel, sessionId);
|
||||
const url = await login(kernel, sessionId, promptConfig.account);
|
||||
if (!url.includes("x.com/home")) {
|
||||
throw new Error("Login didn't reach home page: " + url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user