Skip to main content
NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-apod

✨ 每日天文一图 ✨

License PyPI Python
NoneBot Registry Supported Adapters

安装

使用nb-cli [推荐]

nb plugin install nonebot-plugin-apod

使用pip

pip install nonebot-plugin-apod

使用

命令需要加 NoneBot 命令前缀 (默认为/)
命令需要用户为 SuperUsers
使用命令APOD/apod触发插件
命令选项状态 查询定时任务状态
命令选项关闭 关闭定时任务
命令选项开启 开启定时任务

[以下命令无需用户为SuperUsers]
使用命令今日天文一图获取今日天文一图
使用命令随机天文一图随机获得天文一图
使用命令指定日期天文一图获取指定日期天文一图

效果图

点击展开

example

配置项

配置方式:直接在 NoneBot 全局配置文件中添加以下配置项即可

apod_api_key [直连时必填]

  • 类型:str
  • 默认值:None
  • 说明:用于获取每日天文一图的 NASA API Key。配置镜像地址和镜像密钥后可省略;镜像失败后的直连回退使用 DEMO_KEY。

apod_default_send_time [选填]

  • 类型:str
  • 默认值:13:00
  • 说明:每日天文一图的默认发送时间

apod_infopuzzle [选填]

  • 类型:bool
  • 默认值:True
  • 说明:是否将今日天文一图完整信息构造为信息拼图

apod_infopuzzle_dark_mode [选填]

  • 类型:bool
  • 默认值:False
  • 说明: 是否启用信息拼图的深色模式

apod_baidu_trans [选填]

  • 类型:bool
  • 默认值:False
  • 说明:是否使用百度翻译将天文一图描述翻译为中文

apod_baidu_trans_appid [选填]

  • 类型:int
  • 默认值:None
  • 说明:百度翻译 APP ID

apod_baidu_trans_api_key [选填]

  • 类型:str
  • 默认值:None
  • 说明:百度翻译 密钥

apod_deepl_trans [选填]

  • 类型:bool
  • 默认值:False
  • 说明:是否使用DeepL 翻译将天文一图描述翻译为中文

apod_deepl_trans_api_key [选填]

  • 类型:str
  • 默认值:None
  • 说明:DeepL 翻译 密钥

apod_openai_trans [选填]

  • 类型:bool
  • 默认值:False
  • 说明:是否使用兼容 OpenAI 接口规范的大模型(如 OpenAI / DeepSeek / Qwen / Ollama 等)将天文一图描述翻译为中文

apod_openai_model_name [选填]

  • 类型: str | None
  • 默认值: None
  • 说明: 使用的模型名称(如 gpt-4o-mini, deepseek-chat, qwen-plus 等)。若调用的接口无需传入模型参数(如部分自建代理),可保留 None

apod_openai_api_key [选填]

  • 类型: str | None
  • 默认值:None
  • 说明:OpenAI 兼容接口的 API Key / 密钥

apod_openai_api_url [选填]

  • 类型: str
  • 默认值:https://api.openai.com/v1
  • 说明:OpenAI 兼容接口的 Base API URL(如 DeepSeek 可填 https://api.deepseek.com,Qwen 可填 https://dashscope.aliyuncs.com/compatible-mode/v1)

注:为保持向后兼容,旧版本的 apod_qwen_trans、apod_qwen_mt_model_name、apod_qwen_mt_api_key 和 apod_qwen_mt_api_url 配置项依然生效。

NASA Science 主站迁移

直连使用 https://science.nasa.gov/wp-json/wp/v2/apod-basic。插件兼容对象和数组响应,严格匹配日期;集合接口未返回目标日期时,使用同端点下的 YYMMDD 日期路径。今日数据和缓存日期以 America/New_York 为准。

NASA 图片响应中的 url 可能指向文章页,因此插件将 hdurl 映射为内部图片 url,并将标题、说明和版权中的 HTML 转为纯文本。镜像响应的 url 保持不变,继续使用 apod-server 的图片缓存。视频仍提示为天文视频。

新端点的 count=1 实测返回最近多条记录,因此随机功能改为在 1995-06-16 至 NASA 当天之间随机选日期,再请求该日期;最多尝试三个日期。今日、指定日期和随机功能均支持镜像优先、NASA 直连回退。

镜像配置示例:

APOD_MIRROR_URL=https://your-apod-server.example/v1/apod
APOD_MIRROR_API_KEY=your_server_bearer_key

APOD_MIRROR_URL 是完整元数据接口地址,APOD_MIRROR_API_KEY 对应服务端 API_AUTH_KEY,不等同于 NASA API Key。启用高清原图时仍可能直接访问 NASA 图片 CDN。

htmlrender 版本兼容

当前拼图使用 md_to_pic 接口,依赖限制为 nonebot-plugin-htmlrender>=0.6.7,<0.7.0。htmlrender 新版更改了公开接口,0.8 已移除该旧接口,不能直接升级到新版。若安装环境出现 cannot import name 'md_to_pic',请在机器人项目中重新解析依赖并同步环境;使用 uv 的项目可执行:

uv add "nonebot-plugin-htmlrender>=0.6.7,<0.7.0"
uv sync

仅更新 APOD 源码不会自动调整已安装依赖。后续若迁移新版 htmlrender,需要同时适配渲染 API、返回值、Provider 和配置。

Release files for nonebot-plugin-apod 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-apod 1.3.3
File Size Uploaded
nonebot_plugin_apod-1.3.3.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-apod 1.3.3
File Interpreter ABI Platform
nonebot_plugin_apod-1.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.6 kB

Release files / nonebot_plugin_apod-1.3.3.tar.gz

Download URL nonebot_plugin_apod-1.3.3.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
835ca1e000aec134f8c1ac1b9560709a80e971f59e10332cb0919b56b8a74751
BLAKE2b-256 checksum
How to use checksums
9b40ada1f006e61012489f7ba9d313d1273857467b437fb2a64d3ddfde86e76f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nonebot_plugin_apod-1.3.3-py3-none-any.whl

Download URL nonebot_plugin_apod-1.3.3-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff184cb02adb52da1659b7824903336bacfd0aac0a5e0b99d206d4157d518de4
BLAKE2b-256 checksum
How to use checksums
d3d6e9ecd505c07a5bfda8a1065f2a9a7623fae244d07f796af71f9aa58e711f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.3.3 This release

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page