Metadata-Version: 2.4
Name: nonebot-plugin-heweather
Version: 0.11.0
Summary: Get Heweather information and convert to pictures
Project-URL: Homepage, https://github.com/kexue-z/nonebot-plugin-heweather
Project-URL: Bug Tracker, https://github.com/kexue-z/nonebot-plugin-heweather/issues
Author-email: kexue-z <x@kexue-cloud.cn>
License: MIT License
        
        Copyright (c) 2021 kexue
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: httpx>=0.28.1
Requires-Dist: nonebot-plugin-alconna>=0.57.0
Requires-Dist: nonebot-plugin-apscheduler>=0.5.0
Requires-Dist: nonebot-plugin-htmlrender>=0.6.0
Requires-Dist: nonebot-plugin-localstore>=0.7.0
Requires-Dist: nonebot2>=2.4.0
Requires-Dist: pyjwt[crypto]>=2.10.1
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://v2.nonebot.dev/store"><img src="https://user-images.githubusercontent.com/44545625/209862575-acdc9feb-3c76-471d-ad89-cc78927e5875.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
</p>

<div align="center">

# nonebot-plugin-heweather

_✨ 获取和风天气信息并转换为图片，支持每日定时推送 ✨_

</div>

<p align="center">
  <a href="https://raw.githubusercontent.com/kexue-z/nonebot-plugin-heweather/master/LICENSE">
    <img src="https://img.shields.io/github/license/kexue-z/nonebot-plugin-heweather.svg" alt="license">
  </a>
  <a href="https://pypi.org/project/nonebot-plugin-heweather/">
    <img src="https://img.shields.io/pypi/v/nonebot-plugin-heweather" alt="pypi">
  </a>
  <img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="python">
</p>

<div align="center">

# 使用 html+playwright 来渲染好看的！

<img src="docs/weather.png"  width="50%">
</div>

## 功能特性

- 天气查询：输入城市名称获取实时天气信息
- 每日推送：订阅每日定时天气预报，支持群聊和私聊
- 跨平台兼容：基于 nonebot-plugin-alconna，支持多种聊天适配器

## 依赖

- [nonebot-plugin-htmlrender](https://github.com/nonebot/plugin-htmlrender) - HTML 渲染
- [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) - 跨适配器命令处理
- [nonebot-plugin-apscheduler](https://github.com/nonebot/plugin-apscheduler) - 定时任务
- [nonebot-plugin-localstore](https://github.com/nonebot/plugin-localstore) - 数据持久化

**需要先保证 playwright 可以正常运行并在系统（或容器中）存在中文字体**

# 安装

直接使用 `pip install nonebot-plugin-heweather` 进行安装

在 `bot.py` 中 写入 `nonebot.load_plugin("nonebot_plugin_heweather")`

# 指令

## 天气查询

`天气+地区` 或 `地区+天气`  
例如：`上海天气` 或 `天气广州`

## 每日推送

| 指令 | 说明 | 示例 |
|------|------|------|
| `天气订阅 城市 HH:MM` | 订阅每日天气推送 | `天气订阅 上海 08:30` |
| `天气取消订阅` | 取消当前订阅 | `天气取消订阅` |
| `天气订阅状态` | 查看当前订阅配置 | `天气订阅状态` |

**说明：**
- 推送时间使用 24 小时制，格式为 `HH:MM`
- 每个群聊/用户可订阅多个城市
- 群聊中需要管理员权限才能管理订阅
- 订阅数据保存在 NoneBot 数据目录中

# 配置

## JWT 认证配置

参考文档 [身份认证](https://dev.qweather.com/docs/configuration/authentication/) 生成 Ed25519 密钥，并且上传公钥

```env
# JWT sub，即控制台中的项目管理的项目ID
QWEATHER_JWT_SUB=

# JWT Key ID，在控制台上传公钥后获取，凭据 ID
QWEATHER_JWT_KID=

# JWT 私钥文本，需要自行生成，需要单行填写，例如
# qweather_jwt_private_key="-----BEGIN PRIVATE KEY-----\n123abc\n-----END PRIVATE KEY-----"
QWEATHER_JWT_PRIVATE_KEY=
```

## API 主机配置

参考文档 [API 配置](https://dev.qweather.com/docs/configuration/api-config/) 在 [控制台-设置](https://console.qweather.com/setting) 获取地址。务必添加 scheme `https://`

```env
# API 主机地址，默认为 https://api.qweather.com
QWEATHER_APIHOST=https://api.qweather.com
```

## 天气预报配置

```env
# 每日预报天数，默认 3 天 根据订阅类型可选最多 30 天
QWEATHER_FORECASE_DAYS=3

# 逐小时预报类型
# 1 = 未来12小时 (默认值)
# 2 = 未来24小时
QWEATHER_HOURLYTYPE=1
```

## 调试配置

```env
# 是否开启调试模式，默认为 false
DEBUG=false
```

## 配置获取方式

1. 进入[控制台](https://console.qweather.com/)
2. 项目管理 -> 创建项目
3. 创建凭据
4. 选择 JWT 类型，并按照文档创建公钥和私钥
5. 上传公钥并保存提交
6. 设置 -> 开发者信息 -> API Host 获取地址
7. 填写 .env 文件

## 参考文档

[和风天气文档-订阅](https://dev.qweather.com/docs/finance/subscription/)
