Skip to main content

NoneBot2 plugin for forwarding tweets with optional translation support

Project description

nonebot-plugin-tweet

基于 RSSHub 的 Twitter/X 推文转发插件,支持自动翻译与多种输出模式。

功能亮点

  • 转发 twitter.com / x.com 链接中的推文文本、图片与视频
  • 支持 c / content 前缀仅发送多媒体内容
  • 支持 o / origin 前缀仅发送未翻译原文
  • 可选通过 OpenAI 兼容接口自动翻译推文文本

安装

nb-cli

nb plugin install nonebot-plugin-tweet

pip

pip install nonebot-plugin-tweet

安装完成后,将插件名加入 NoneBot 配置:

[tool.nonebot]
plugins = ["nonebot_plugin_tweet"]

或在代码中手动加载:

nonebot.load_plugin("nonebot_plugin_tweet")

配置

通过环境变量或 .env 文件配置插件参数:

变量名 默认值 说明
RSSHUB_BASE_URL https://rsshub.app/twitter/user/ RSSHub 推文路由基础地址,需包含末尾 /
RSSHUB_QUERY_PARAM 空字符串 追加到 RSSHub 请求的查询参数,示例:?format=raw
TRANSLATE_TARGET_LANGUAGE zh-Hans 翻译目标语言,留空代表禁用翻译
OPENAI_API_BASE 未设置 OpenAI 兼容接口地址,启用翻译时必填
OPENAI_API_KEY 未设置 OpenAI 兼容接口密钥,启用翻译时必填
OPENAI_MODEL gemini-2.5-flash-lite 用于翻译的模型名称,启用翻译时必填

如果仅需转发原始内容,可将 TRANSLATE_TARGET_LANGUAGE 置空或不配置,同时无需填写 OpenAI 相关参数。

使用说明

  • 直接发送推文链接即可触发转发。
  • 使用 c / content 前缀仅发送图片和视频。
  • 使用 o / origin 前缀仅发送未翻译的原始文本。
  • 视频会按顺序逐条下载并发送,发送间隔约为 1 秒。

本地调试

项目内置 bot.py,可在本地快速启动:

pip install -r requirements.txt
python bot.py

许可证

本项目基于 MIT 许可证开源。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_tweet-0.3.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_tweet-0.3.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_tweet-0.3.0.tar.gz.

File metadata

  • Download URL: nonebot_plugin_tweet-0.3.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nonebot_plugin_tweet-0.3.0.tar.gz
Algorithm Hash digest
SHA256 504331307748e9c7be5be508d8c8ca0244dced15a2d9f72cb62749d40e66921c
MD5 ad97b8bfa55e86ff573ecd508d3f031f
BLAKE2b-256 dfc1504d70a147d9b7ae393138309f98e24285a00bd1990ae87bde357967803f

See more details on using hashes here.

File details

Details for the file nonebot_plugin_tweet-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_tweet-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7eae17950ea7eae770582b01f00f218a08b0af4d09f9dd036c2b48a6e18524ac
MD5 f0526b2fad5af71116dde2626afd26e4
BLAKE2b-256 e0a1b21e059fbeaabe98c3d624192a9c62587a0de450f86c9586cac8e55d8da2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page