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: news-plugin #1248

Merged
merged 11 commits into from
Jan 26, 2025
Merged
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ ETHSTORAGE_ADDRESS=0x64003adbdf3014f7E38FC6BE752EB047b95da89A
ETHSTORAGE_RPC_URL=https://rpc.beta.testnet.l2.quarkchain.io:8545



# Email Automation Plugin Configuration
RESEND_API_KEY= # Your Resend API key
DEFAULT_TO_EMAIL= # Default recipient
Expand Down Expand Up @@ -902,3 +901,6 @@ DCAP_MODE= # Options: OFF, PLUGIN-SGX, PLUGIN-TEE, MOCK

# QuickIntel Token Security API
QUICKINTEL_API_KEY= # Your QuickIntel API key for token security analysis

# News API Key
NEWS_API_KEY= # News API KEY from https://newsapi.org/
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@elizaos/plugin-mind-network": "workspace:*",
"@elizaos/plugin-movement": "workspace:*",
"@elizaos/plugin-massa": "workspace:*",
"@elizaos/plugin-news": "workspace:*",
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-quick-intel": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import { lensPlugin } from "@elizaos/plugin-lensNetwork"
import { mindNetworkPlugin } from "@elizaos/plugin-mind-network";
import { multiversxPlugin } from "@elizaos/plugin-multiversx"
import { nearPlugin } from "@elizaos/plugin-near"
import { newsPlugin } from "@elizaos/plugin-news";
import createNFTCollectionsPlugin from "@elizaos/plugin-nft-collections"
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation"
import { createNodePlugin } from "@elizaos/plugin-node"
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-news/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

!dist/**
!package.json
!readme.md
!tsup.config.ts
171 changes: 171 additions & 0 deletions packages/plugin-news/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# @elizaos/plugin-news

A plugin for fetching and handling real-time news data through NewsAPI integration.

## Overview

This plugin provides functionality to:
- Fetch latest news articles from NewsAPI
- Search news by specific topics or keywords
- Get article summaries including titles, descriptions, and URLs
- Limit results to most recent and relevant content

## Installation

```bash
npm install @elizaos/plugin-news
```

## Configuration

The plugin requires the following environment variable:

```env
NEWS_API_KEY=your_newsapi_key # Required for accessing NewsAPI
```

## Usage

Import and register the plugin in your Eliza configuration:

```typescript
import { newsPlugin } from "@elizaos/plugin-news";

export default {
plugins: [newsPlugin],
// ... other configuration
};
```

## Features

### Current News Action

The plugin provides a `CURRENT_NEWS` action that responds to various news-related queries:

```typescript
// Example queries the action responds to:
"what's the latest news about <searchTerm>?"
"can you show me the latest news about <searchTerm>?"
"what's in the <searchTerm> news today?"
"show me current events about <searchTerm>?"
"what's going on in the world of <searchTerm>?"
"give me the latest headlines about <searchTerm>?"
"show me news updates about <searchTerm>?"
"what are today's top stories about <searchTerm>?"
```

The action returns up to 5 recent articles, including:
- Article title
- Description
- URL
- Content preview (up to 1000 characters)

## Development

### Building

```bash
npm run build
```

### Development Mode

```bash
npm run dev
```

### Linting

```bash
npm run lint
```

### Project Structure

```
plugin-news/
├── src/
│ ├── actions/ # Action implementations
│ │ ├── news.ts # Current news action
│ │ └── index.ts # Action exports
│ └── index.ts # Main plugin export
├── package.json
└── tsconfig.json
```

## Dependencies

- `@ai16z/eliza`: Core Eliza framework
- `tsup`: Build tool for TypeScript packages
- Other standard dependencies listed in package.json

## API Reference

### Actions

- `CURRENT_NEWS`: Main action for fetching news
- Aliases: `["NEWS", "GET_NEWS", "GET_CURRENT_NEWS"]`
- Automatically extracts search terms from user messages
- Returns formatted news articles with titles, descriptions, and URLs

### Response Format

```typescript
interface NewsResponse {
title: string;
description: string;
url: string;
content: string; // Limited to 1000 characters
}
```

## Future Enhancements

1. **Additional News Sources**
- Integration with multiple news APIs
- RSS feed support
- Social media news aggregation

2. **Content Analysis**
- Sentiment analysis of news articles
- Topic categorization
- Trend detection
- Fact-checking integration

3. **Customization Options**
- User preferences for news sources
- Custom filtering rules
- Personalized news feeds
- Language preferences

4. **Advanced Search**
- Date range filtering
- Source filtering
- Category-based search
- Advanced query syntax

5. **Performance Improvements**
- Caching layer
- Rate limiting optimization
- Response compression
- Batch processing

We welcome community feedback and contributions to help prioritize these enhancements.

## Contributing

Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.


## License

This plugin is part of the Eliza project. See the main project repository for license information.

## Credits

This plugin integrates with and builds upon several key technologies:

- [NewsAPI](https://newsapi.org/): News data provider

Plugin generated from Eliza coding tutorial [Agent Dev School Part 2](https://www.youtube.com/watch?v=XenGeAcPAQo)
3 changes: 3 additions & 0 deletions packages/plugin-news/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];
19 changes: 19 additions & 0 deletions packages/plugin-news/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@elizaos/plugin-news",
"version": "0.1.5-alpha.5",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@elizaos/core": "workspace:*",
"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"
}
}
2 changes: 2 additions & 0 deletions packages/plugin-news/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./news.ts";

Loading
Loading