Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(new-plugin): truth social #2537

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions packages/client-truth-social/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Truth Social Client

A TypeScript client for interacting with Truth Social's API, built on top of the @elizaos/core framework for AI-powered social media interactions.

## System Overview

This client provides automated interaction capabilities with Truth Social, including:

- Posting and responding to content
- Processing mentions and interactions
- Searching and engaging with relevant content
- Managing rate limits and API interactions

### Core Components

1. **API Layer** (`api.ts`)
- Handles direct communication with Truth Social's API
- Manages authentication and rate limiting
- Provides base methods for posts, likes, reposts, etc.

2. **Base Client** (`base.ts`)
- Provides foundational client functionality
- Manages state and caching
- Handles timeline and post fetching

3. **Post Management** (`post.ts`)
- Handles post creation and processing
- Manages periodic posting
- Processes post actions and interactions

4. **Interactions** (`interactions.ts`)
- Manages user interactions and responses
- Handles conversation threading
- Controls engagement limits and timeouts

5. **Search** (`search.ts`)
- Implements search functionality
- Manages topic-based engagement
- Controls post selection and relevance

6. **Environment** (`environment.ts`)
- Manages configuration and settings
- Validates environment variables
- Sets operational parameters

### Supporting Files

- **Types** (`types.ts`): TypeScript interfaces and types
- **Utils** (`utils.ts`): Shared utilities and helper functions
- **Index** (`index.ts`): Main entry point and client initialization

## Requirements

### Dependencies

- Node.js 23.3+
- TypeScript 4.5+
- @ai16z/eliza framework
- axios
- date-fns
- zod

### Environment Variables

- TRUTHSOCIAL_DRY_RUN: Boolean, if true, the client will not post or interact with Truth Social
- TRUTHSOCIAL_USERNAME: String, the username of the Truth Social account
- TRUTHSOCIAL_PASSWORD: String, the password of the Truth Social account
- MAX_TRUTH_LENGTH: Number, the maximum length of a post
- POST_INTERVAL_MIN: Number, the minimum interval between posts in seconds
- POST_INTERVAL_MAX: Number, the maximum interval between posts in seconds
- ACTION_INTERVAL: Number, the interval between actions in seconds

## Setup

1. Clone the repository
2. Install dependencies: `npm install`
3. Set environment variables
4. Run the client: `npm start`

## Architecture

The system follows a layered architecture:

1. **API Layer** (Bottom)
- Raw API communication
- Rate limiting
- Authentication

2. **Client Layer**
- Base functionality
- State management
- Caching

3. **Feature Layer**
- Post management
- Interactions
- Search
- Content generation

4. **Interface Layer** (Top)
- Client interface
- Runtime management
- Configuration

## File Dependencies

```
index.ts
├── environment.ts
├── base.ts
│ └── api.ts
├── post.ts
│ ├── base.ts
│ └── utils.ts
├── interactions.ts
│ ├── base.ts
│ └── utils.ts
└── search.ts
├── base.ts
└── utils.ts
```

- `api.ts` depends on `types.ts`
- `base.ts` depends on `types.ts`
- `post.ts` depends on `types.ts`
- `interactions.ts` depends on `types.ts`
- `search.ts` depends on `types.ts`
- `environment.ts` depends on `types.ts`
- `utils.ts` depends on `types.ts`
- `index.ts` depends on `types.ts`
- `environment.ts` depends on `types.ts`

## Safety Notes

1. Rate Limiting
- Built-in rate limit management
- Configurable intervals
- Automatic backoff

2. Content Safety
- Content filtering
- Engagement limits
- Conversation depth control

3. Error Handling
- Comprehensive error catching
- Logging
- Graceful degradation

## Usage Warning

This client includes search and interaction capabilities that should be used responsibly.Be aware of:

1. Rate limit implications
2. User privacy considerations
3. Platform terms of service
4. Potential account restrictions

Always test with `TRUTHSOCIAL_DRY_RUN=true` before live deployment.
3 changes: 3 additions & 0 deletions packages/client-truth-social/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
24 changes: 24 additions & 0 deletions packages/client-truth-social/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@elizaos/client-truth",
"version": "0.1.9-alpha.1",
"description": "Truth Social client integration for eliza agents",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@elizaos/core": "workspace:*",
"glob": "11.0.0",
"zod": "3.23.8"
},
"devDependencies": {
"tsup": "8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
}
}
Loading
Loading