UNPKG

sei-agent-kit

Version:

A package for building AI agents on the SEI blockchain

45 lines 1.7 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.postTweetReply = postTweetReply; const twitter_api_v2_1 = require("twitter-api-v2"); const dotenv_1 = __importDefault(require("dotenv")); dotenv_1.default.config(); async function postTweetReply(args) { 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, }; 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."); } try { 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.tweet(args.tweetReply, { reply: { in_reply_to_tweet_id: args.tweetId }, }); return `Successfully posted reply to Twitter:\n${JSON.stringify(response)}`; } catch (error) { return `Error posting reply to Twitter: ${error}`; } } //# sourceMappingURL=postTweetReply.js.map