sei-agent-kit
Version:
A package for building AI agents on the SEI blockchain
44 lines • 1.78 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountDetails = getAccountDetails;
const twitter_api_v2_1 = require("twitter-api-v2");
const dotenv_1 = __importDefault(require("dotenv"));
dotenv_1.default.config();
async function getAccountDetails() {
const config = {
apiKey: process.env.TWITTER_API_KEY,
apiSecret: process.env.TWITTER_API_SECRET,
accessToken: process.env.TWITTER_ACCESS_TOKEN,
accessTokenSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
};
try {
if (!config.apiKey) {
throw new Error("TWITTER_API_KEY is not configured.");
}
if (!config.apiSecret) {
throw new Error("TWITTER_API_SECRET is not configured.");
}
if (!config.accessToken) {
throw new Error("TWITTER_ACCESS_TOKEN is not configured.");
}
if (!config.accessTokenSecret) {
throw new Error("TWITTER_ACCESS_TOKEN_SECRET is not configured.");
}
const Client = new twitter_api_v2_1.TwitterApi({
appKey: config.apiKey,
appSecret: config.apiSecret,
accessToken: config.accessToken,
accessSecret: config.accessTokenSecret,
});
const response = await Client.v2.me();
response.data.url = `https://x.com/${response.data.username}`;
return `Successfully retrieved authenticated user account details:\n${JSON.stringify(response)}`;
}
catch (error) {
return `Error retrieving authenticated user account details: ${error}`;
}
}
//# sourceMappingURL=getAccountDetails.js.map