Skip to main content

将代码统计嵌入 Bot 中

Project description

NoneBot-Plugin-Wakatime

✨ NoneBot Wakatime 查询插件 ✨

pypi python pdm-managed alc-resolved
NoneBot Registry Supported Adapters
📸 演示与预览   |   📦️ 下载插件   |   💬 加入交流群

📖 介绍

NoneBot Wakatime 查询插件。将你的代码统计嵌入 Bot 中

💿 安装

以下提到的方法任选 其一 即可

[推荐] 使用 nb-cli 安装 在 Bot 的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-wakatime
使用包管理器安装
pip install nonebot-plugin-wakatime
# or, use poetry
poetry add nonebot-plugin-wakatime
# or, use pdm
pdm add nonebot-plugin-wakatime

打开 NoneBot 项目根目录下的配置文件, 在 [plugin] 部分追加写入

plugins = ["nonebot_plugin_wakatime"]

⚙️ 配置

在项目的配置文件中添加下表中配置

[!note] client_idclient_secret 均从 WakaTime App 获取
redirect_uri 的配置参见 此处

配置项 必填 默认值
wakatime__client_id
wakatime__client_secret
wakatime__redirect_uri
wakatime__api_url https://wakatime.com/api/v1
wakatime__register_route /wakatime/register
wakatime__background_source default

redirect_uri

[!NOTE]

redirect_uri 指绑定后跳转的页面,可以使用 WakaTime 域名和个人域名

使用 WakaTime 域名

  • 在 WakaTime App 中的 Authorized Redirect URIs 添加:https://wakatime.com/oauth/test

  • 在项目配置文件中写入:

    wakatime__redirect_uri = https://wakatime.com/oauth/test
    

使用个人域名

[!TIP]

使用个人域名可以启用自动注册,即发送绑定指令后无需进行二次操作,用于简化绑定流程。

  • 使用 nb-cli 安装服务端类型驱动器并修改配置文件

  • 在 WakaTime App 中的 Authorized Redirect URIs 添加:https://<your-domain:PORT>/wakatime/register

  • 在项目配置文件中写入:

    wakatime__redirect_uri = https://<your-domain:PORT>/wakatime/register
    

background_source

wakatime__background_source 为背景图来源,可选值为字面量 default / LoliAPI / Lolicon 或者结构 CustomSourceLoliAPILolicon 均为随机背景图,CustomSource 用于自定义背景图。 默认为 default

以下是 CustomSource 用法

在配置文件中设置 wakatime__background_sourceCustomSource结构的字典

wakatime__background_source = '{"uri": "https://example.com/image.jpg"}'

其中

  • uri 可为网络图片 API,只要返回的是图片即可
  • uri 也可以为 base64 编码的图片,如 data:image/png;base64,xxxxxx (一般也没人这么干)
  • uri 也可以为本地图片路径,如 imgs/image.jpg/path/to/image.jpg
    • 如果本地图片路径是相对路径,会使用 nonebot-plugin-localstore 指定的 data 目录作为根目录
    • 如果本地图片路径是目录,会随机选择目录下的一张图片作为背景图

🎉 使用

[!note] 请检查你的 COMMAND_START 以及上述配置项。这里默认使用 /

绑定账号

首次绑定时向 Bot 发送 /wakatime bind,跟随链接指引进行绑定,成功后会跳转到 redirect_uri 处。

/wakatime bind [code]

解绑

/wakatime revoke

查询信息

/wakatime [@]

📸 效果图

默认背景图

rendering

💖 鸣谢

贡献者们

All Contributors

感谢这些大佬对本项目作出的贡献:

Komorebi
Komorebi

💻
Azide
Azide

💻
Jigsaw
Jigsaw

💻

本段符合 all-contributors 规范

📄 许可证

本项目使用 MIT 许可证开源

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.

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_wakatime-0.2.4.tar.gz (2.1 MB view hashes)

Uploaded Source

Built Distribution

nonebot_plugin_wakatime-0.2.4-py3-none-any.whl (1.2 MB view hashes)

Uploaded Python 3

Supported by

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