npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

koishi-plugin-ai-news

v1.0.0

Published

A Koishi plugin to get today's AI news with multiple sources support

Readme

koishi-plugin-ai-news

npm

🤖 获取今日 AI 人工智能新闻的 Koishi 插件

📦 安装

方式一:图形界面安装

在 Koishi 控制台的插件市场中搜索 ai-news 并安装。

方式二:命令行安装

npm install koishi-plugin-ai-news

方式三:本地开发

# 克隆到 Koishi 项目的 plugins 目录
cd your-koishi-bot/plugins
git clone https://github.com/yourusername/koishi-plugin-ai-news.git

# 安装依赖并编译
cd koishi-plugin-ai-news
npm install
npm run build

# 在 Koishi 配置文件中启用

✨ 功能特性

1. 多种新闻源 📰

  • NewsAPI:专业新闻 API(需要密钥)
  • RSS 订阅:免费 AI 新闻 RSS 源
  • 模拟数据:测试用模拟新闻

2. 智能缓存 🗄️

  • 自动缓存新闻,避免频繁请求
  • 可配置缓存时间
  • 支持强制刷新

3. 灵活配置 ⚙️

  • 自定义新闻数量
  • 选择新闻语言
  • 调整缓存时间

4. 友好输出 📝

  • 清晰的格式化输出
  • 包含标题、来源、链接
  • 可选的新闻摘要

📝 指令列表

主要指令

| 指令 | 说明 | 示例 | |------|------|------| | ai新闻 | 获取今日 AI 新闻 | ai新闻 | | 今日ai新闻 | 同上(别名) | 今日ai新闻 | | AI新闻 | 同上(别名) | AI新闻 |

选项参数

| 选项 | 说明 | 示例 | |------|------|------| | -n <count> | 指定新闻数量 | ai新闻 -n 5 | | -r | 强制刷新缓存 | ai新闻 -r |

管理指令

| 指令 | 说明 | |------|------| | ai新闻源 | 查看当前新闻源配置 |

🎮 使用示例

示例1:获取默认数量的新闻

用户:ai新闻

机器人:
🔍 正在获取最新 AI 新闻...

🤖 今日 AI 新闻 (10 条)
📅 2024年10月10日
══════════════════════════════

1. OpenAI 发布 GPT-5 模型,性能大幅提升
   📰 AI News | 🔗 https://example.com/news/1
   📝 OpenAI 今日宣布推出新一代大语言模型 GPT-5...

2. Google DeepMind 新突破:AI 解决数学难题
   📰 Tech News | 🔗 https://example.com/news/2
   📝 DeepMind 研究团队使用 AI 成功证明了一个数学猜想...

...(更多新闻)

──────────────────────────────
💡 使用 "ai新闻 -r" 强制刷新
💡 使用 "ai新闻 -n 5" 获取 5 条新闻

示例2:获取指定数量的新闻

用户:ai新闻 -n 3

机器人:
🤖 今日 AI 新闻 (3 条)
📅 2024年10月10日
══════════════════════════════

1. OpenAI 发布 GPT-5 模型
   📰 AI News | 🔗 https://...

2. Google DeepMind 新突破
   📰 Tech News | 🔗 https://...

3. 百度文心一言用户数突破 1 亿
   📰 科技日报 | 🔗 https://...

示例3:强制刷新

用户:ai新闻 -r

机器人:
🔍 正在获取最新 AI 新闻...

🤖 今日 AI 新闻 (10 条)
...(最新新闻)

示例4:查看配置

用户:ai新闻源

机器人:
📰 AI 新闻源配置
════════════════════
当前源:RSS 订阅
最大数量:10 条
缓存时间:30 分钟
语言:zh-cn

⚙️ 配置选项

在 Koishi 配置文件或控制台中配置:

基础配置

| 配置项 | 类型 | 默认值 | 说明 | |--------|------|--------|------| | newsApiKey | string | '' | NewsAPI 密钥 | | newsSource | enum | 'rss' | 新闻源类型 | | maxNews | number | 10 | 最大新闻数量 | | language | string | 'zh-cn' | 新闻语言 | | cacheTime | number | 30 | 缓存时间(分钟) |

配置示例

YAML 配置

plugins:
  ai-news:
    newsSource: rss
    maxNews: 10
    language: zh-cn
    cacheTime: 30

JSON 配置

{
  "plugins": {
    "ai-news": {
      "newsSource": "rss",
      "maxNews": 10,
      "language": "zh-cn",
      "cacheTime": 30
    }
  }
}

📚 新闻源说明

1. NewsAPI(推荐)

优点:

  • ✅ 专业的新闻 API
  • ✅ 数据质量高
  • ✅ 支持多种语言
  • ✅ 可过滤和搜索

缺点:

  • ❌ 需要注册获取 API Key
  • ❌ 免费版有请求限制

获取方式:

  1. 访问 https://newsapi.org
  2. 注册账号
  3. 获取 API Key
  4. 在配置中填入 newsApiKey

配置示例:

plugins:
  ai-news:
    newsSource: newsapi
    newsApiKey: your-api-key-here

2. RSS 订阅(默认)

优点:

  • ✅ 完全免费
  • ✅ 无需注册
  • ✅ 稳定可靠

缺点:

  • ❌ 可能有时效性延迟
  • ❌ 内容格式不统一

订阅源:

  • AI News (artificialintelligence-news.com)
  • VentureBeat AI
  • 更多源持续添加...

3. 模拟数据(测试)

用途:

  • 🧪 测试插件功能
  • 🧪 开发调试
  • 🧪 演示效果

配置:

plugins:
  ai-news:
    newsSource: mock

🔧 高级功能

自定义新闻源

你可以在代码中添加更多的 RSS 源或新闻网站:

// 在 src/index.ts 中修改
const rssSources = [
  'https://www.artificialintelligence-news.com/feed/',
  'https://feeds.feedburner.com/venturebeat/SZYF',
  // 添加你的 RSS 源
  'https://your-rss-feed.com/feed/',
]

修改输出格式

编辑 formatNews 函数来自定义输出格式:

function formatNews(news: NewsItem[], count: number): string {
  // 自定义你的格式
  let msg = `📰 AI 新闻速递\n`
  // ...
  return msg
}

🐛 故障排查

问题1:获取新闻失败

可能原因:

  • 网络连接问题
  • API Key 无效(NewsAPI)
  • RSS 源不可用

解决方法:

  1. 检查网络连接
  2. 验证 API Key 是否正确
  3. 尝试切换新闻源
  4. 查看 Koishi 日志获取详细错误

问题2:新闻内容为空

可能原因:

  • 所有新闻源都不可用
  • 过滤条件过于严格

解决方法:

  1. 使用 mock 模式测试
  2. 检查网络和防火墙
  3. 添加更多 RSS 源

问题3:缓存不更新

可能原因:

  • 缓存时间过长
  • 未使用 -r 强制刷新

解决方法:

  1. 使用 ai新闻 -r 强制刷新
  2. 调整配置中的 cacheTime
  3. 重启 Koishi

问题4:中文乱码

可能原因:

  • 编码问题
  • RSS 源编码不统一

解决方法:

  1. 确保 Koishi 使用 UTF-8 编码
  2. 更新插件到最新版本

📊 性能说明

资源占用

  • 内存:约 5-10 MB
  • 网络:每次请求约 100-500 KB
  • CPU:请求时短暂占用

请求频率

  • 默认缓存 30 分钟
  • 建议不要频繁刷新
  • NewsAPI 免费版限制:100 次/天

🔄 开发指南

本地开发

# 克隆项目
git clone https://github.com/yourusername/koishi-plugin-ai-news.git
cd koishi-plugin-ai-news

# 安装依赖
npm install

# 开发模式(自动编译)
npm run dev

# 构建
npm run build

目录结构

koishi-plugin-ai-news/
├── src/
│   └── index.ts        # 主文件
├── lib/                # 编译输出
├── package.json        # 包配置
├── tsconfig.json       # TS 配置
└── README.md           # 文档

添加新功能

  1. src/index.ts 中添加代码
  2. 运行 npm run build 编译
  3. 重启 Koishi 测试
  4. 提交 Pull Request

🎯 使用场景

场景1:技术社区

  • AI 技术交流群
  • 及时了解行业动态
  • 分享最新资讯

场景2:学习研究

  • 学生群体学习 AI
  • 追踪前沿技术
  • 研究参考资料

场景3:工作团队

  • 产品团队了解趋势
  • 技术团队跟进进展
  • 市场团队收集信息

📄 许可证

MIT License

🤝 贡献

欢迎提交 Issue 和 Pull Request!

贡献指南:

  1. Fork 本仓库
  2. 创建特性分支
  3. 提交更改
  4. 发起 Pull Request

📞 支持

🎉 更新日志

v1.0.0 (2024-10-10)

新增功能:

  • ✅ 支持 NewsAPI
  • ✅ 支持 RSS 订阅
  • ✅ 智能缓存机制
  • ✅ 多语言支持
  • ✅ 灵活的配置选项

开始使用 AI 新闻插件,每天了解 AI 行业动态! 🤖📰

示例命令ai新闻