做了个Opencode插件,用来显示中转站剩余额度

opencode-myquota

效果展示

安装

将插件文件下载到你的 OpenCode 插件目录:

Windows

curl -fsSL https://raw.githubusercontent.com/watermeko/opencode-myquota/main/plugins/myquota.ts -o $env:USERPROFILE/.config/opencode/plugins/myquota.ts

Linux

curl -fsSL https://raw.githubusercontent.com/watermeko/opencode-myquota/main/plugins/myquota.ts -o ~/.config/opencode/plugins/myquota.ts

示例配置

~/.config/opencode/下创建myquota.json

以下是适用于任何基于NewAPI的中转站的示例配置。authorization可在个人设置-安全设置-系统访问令牌获取。New-Api-User是用户ID。

{
  "url": "https://replace.me/api/user/self",
  "headers": {
    "authorization": "xxxx",
    "New-Api-User": 1234
  },
  "fields": {
    "quotaRemaining": "data.quota",
    "quotaUsed": "data.used_quota",
    "usagePercentage": ""
  },
  "cooldownMinutes": 0,
  "enableLog": true
}

以下是适用于某:fox:中转站的示例配置。Bearer xxxx可通过开发者控制台查看。

{
  "url": "https://replace.me/api/user/dashboard",
  "headers": {
    "authorization": "Bearer xxxx"
  },
  "fields": {
    "quotaRemaining": "data.quota.quotaRemaining",
    "quotaUsed": "",
    "usagePercentage": "data.quota.usagePercentage"
  },
  "cooldownMinutes": 0,
  "enableLog": false
}

碎碎念

其实我想在opencode侧边栏显示的,奈何opencode的plugin系统没有提供这样的API。

13 个赞

加油,未来的佬友

1 个赞

感谢大佬!

1 个赞

感谢佬友,我这就去试试 :grinning_face:

1 个赞

感谢佬友

1 个赞

佬友厉害啊,感觉很实用的

1 个赞