@polybiouslabs/polybious
Version:
Polybius is a next-generation intelligent agent framework built for adaptability across diverse domains. It merges contextual awareness, multi-agent collaboration, and predictive reasoning to deliver dynamic, self-optimizing performance.
43 lines (42 loc) • 1.41 kB
JavaScript
import { Scraper } from 'agent-twitter-client';
import { logger } from '../config/logger';
export class TwitterService {
scraper;
config;
constructor(config) {
this.scraper = new Scraper();
this.config = config;
}
async initialize() {
try {
logger.info('Initializing Twitter service...');
const { username, password, email } = this.config.credentials;
if (!username || !password || !email) {
throw new Error('Missing required Twitter credentials: username, password, email');
}
await this.scraper.login(username, password, email);
logger.info('Twitter login successful');
}
catch (error) {
logger.error('Failed to initialize Twitter service', {
error: error instanceof Error ? {
message: error.message,
stack: error.stack,
name: error.name
} : error,
});
throw error;
}
}
async sendTweet(content) {
try {
logger.info('Sending tweet', { content });
await this.scraper.sendTweet(content);
logger.info('Tweet sent successfully');
}
catch (error) {
logger.error('Failed to send tweet', { error, content });
throw error;
}
}
}