Skip to content

Commit 227baf7

Browse files
authored
Merge pull request #1248 from ileana-pr/news-plugin
feat: news-plugin
2 parents 1281911 + 2a967af commit 227baf7

12 files changed

+468
-1
lines changed

.env.example

+3-1
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,6 @@ ETHSTORAGE_ADDRESS=0x64003adbdf3014f7E38FC6BE752EB047b95da89A
873873
ETHSTORAGE_RPC_URL=https://rpc.beta.testnet.l2.quarkchain.io:8545
874874

875875

876-
877876
# Email Automation Plugin Configuration
878877
RESEND_API_KEY= # Your Resend API key
879878
DEFAULT_TO_EMAIL= # Default recipient
@@ -902,3 +901,6 @@ DCAP_MODE= # Options: OFF, PLUGIN-SGX, PLUGIN-TEE, MOCK
902901

903902
# QuickIntel Token Security API
904903
QUICKINTEL_API_KEY= # Your QuickIntel API key for token security analysis
904+
905+
# News API Key
906+
NEWS_API_KEY= # News API KEY from https://newsapi.org/

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@elizaos/plugin-mind-network": "workspace:*",
7171
"@elizaos/plugin-movement": "workspace:*",
7272
"@elizaos/plugin-massa": "workspace:*",
73+
"@elizaos/plugin-news": "workspace:*",
7374
"@elizaos/plugin-nft-generation": "workspace:*",
7475
"@elizaos/plugin-node": "workspace:*",
7576
"@elizaos/plugin-quick-intel": "workspace:*",

agent/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import { lensPlugin } from "@elizaos/plugin-lensNetwork"
8484
import { mindNetworkPlugin } from "@elizaos/plugin-mind-network";
8585
import { multiversxPlugin } from "@elizaos/plugin-multiversx"
8686
import { nearPlugin } from "@elizaos/plugin-near"
87+
import { newsPlugin } from "@elizaos/plugin-news";
8788
import createNFTCollectionsPlugin from "@elizaos/plugin-nft-collections"
8889
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation"
8990
import { createNodePlugin } from "@elizaos/plugin-node"

packages/plugin-news/.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!tsup.config.ts

packages/plugin-news/README.md

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# @elizaos/plugin-news
2+
3+
A plugin for fetching and handling real-time news data through NewsAPI integration.
4+
5+
## Overview
6+
7+
This plugin provides functionality to:
8+
- Fetch latest news articles from NewsAPI
9+
- Search news by specific topics or keywords
10+
- Get article summaries including titles, descriptions, and URLs
11+
- Limit results to most recent and relevant content
12+
13+
## Installation
14+
15+
```bash
16+
npm install @elizaos/plugin-news
17+
```
18+
19+
## Configuration
20+
21+
The plugin requires the following environment variable:
22+
23+
```env
24+
NEWS_API_KEY=your_newsapi_key # Required for accessing NewsAPI
25+
```
26+
27+
## Usage
28+
29+
Import and register the plugin in your Eliza configuration:
30+
31+
```typescript
32+
import { newsPlugin } from "@elizaos/plugin-news";
33+
34+
export default {
35+
plugins: [newsPlugin],
36+
// ... other configuration
37+
};
38+
```
39+
40+
## Features
41+
42+
### Current News Action
43+
44+
The plugin provides a `CURRENT_NEWS` action that responds to various news-related queries:
45+
46+
```typescript
47+
// Example queries the action responds to:
48+
"what's the latest news about <searchTerm>?"
49+
"can you show me the latest news about <searchTerm>?"
50+
"what's in the <searchTerm> news today?"
51+
"show me current events about <searchTerm>?"
52+
"what's going on in the world of <searchTerm>?"
53+
"give me the latest headlines about <searchTerm>?"
54+
"show me news updates about <searchTerm>?"
55+
"what are today's top stories about <searchTerm>?"
56+
```
57+
58+
The action returns up to 5 recent articles, including:
59+
- Article title
60+
- Description
61+
- URL
62+
- Content preview (up to 1000 characters)
63+
64+
## Development
65+
66+
### Building
67+
68+
```bash
69+
npm run build
70+
```
71+
72+
### Development Mode
73+
74+
```bash
75+
npm run dev
76+
```
77+
78+
### Linting
79+
80+
```bash
81+
npm run lint
82+
```
83+
84+
### Project Structure
85+
86+
```
87+
plugin-news/
88+
├── src/
89+
│ ├── actions/ # Action implementations
90+
│ │ ├── news.ts # Current news action
91+
│ │ └── index.ts # Action exports
92+
│ └── index.ts # Main plugin export
93+
├── package.json
94+
└── tsconfig.json
95+
```
96+
97+
## Dependencies
98+
99+
- `@ai16z/eliza`: Core Eliza framework
100+
- `tsup`: Build tool for TypeScript packages
101+
- Other standard dependencies listed in package.json
102+
103+
## API Reference
104+
105+
### Actions
106+
107+
- `CURRENT_NEWS`: Main action for fetching news
108+
- Aliases: `["NEWS", "GET_NEWS", "GET_CURRENT_NEWS"]`
109+
- Automatically extracts search terms from user messages
110+
- Returns formatted news articles with titles, descriptions, and URLs
111+
112+
### Response Format
113+
114+
```typescript
115+
interface NewsResponse {
116+
title: string;
117+
description: string;
118+
url: string;
119+
content: string; // Limited to 1000 characters
120+
}
121+
```
122+
123+
## Future Enhancements
124+
125+
1. **Additional News Sources**
126+
- Integration with multiple news APIs
127+
- RSS feed support
128+
- Social media news aggregation
129+
130+
2. **Content Analysis**
131+
- Sentiment analysis of news articles
132+
- Topic categorization
133+
- Trend detection
134+
- Fact-checking integration
135+
136+
3. **Customization Options**
137+
- User preferences for news sources
138+
- Custom filtering rules
139+
- Personalized news feeds
140+
- Language preferences
141+
142+
4. **Advanced Search**
143+
- Date range filtering
144+
- Source filtering
145+
- Category-based search
146+
- Advanced query syntax
147+
148+
5. **Performance Improvements**
149+
- Caching layer
150+
- Rate limiting optimization
151+
- Response compression
152+
- Batch processing
153+
154+
We welcome community feedback and contributions to help prioritize these enhancements.
155+
156+
## Contributing
157+
158+
Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.
159+
160+
161+
## License
162+
163+
This plugin is part of the Eliza project. See the main project repository for license information.
164+
165+
## Credits
166+
167+
This plugin integrates with and builds upon several key technologies:
168+
169+
- [NewsAPI](https://newsapi.org/): News data provider
170+
171+
Plugin generated from Eliza coding tutorial [Agent Dev School Part 2](https://www.youtube.com/watch?v=XenGeAcPAQo)
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.config.mjs";
2+
3+
export default [...eslintGlobalConfig];

packages/plugin-news/package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@elizaos/plugin-news",
3+
"version": "0.1.5-alpha.5",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@elizaos/core": "workspace:*",
9+
"tsup": "8.3.5"
10+
},
11+
"scripts": {
12+
"build": "tsup --format esm --dts",
13+
"dev": "tsup --format esm --dts --watch",
14+
"lint": "eslint . --fix"
15+
},
16+
"peerDependencies": {
17+
"whatwg-url": "7.1.0"
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./news.ts";
2+

0 commit comments

Comments
 (0)