mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
OpenAI Plus剩余额度查询 (#161)
This commit is contained in:
parent
dd805136e0
commit
37f75a64fa
2 changed files with 52 additions and 22 deletions
25
apps/chat.js
25
apps/chat.js
|
|
@ -90,6 +90,11 @@ export class chatgpt extends plugin {
|
||||||
reg: '#移出(chat)?队列首位',
|
reg: '#移出(chat)?队列首位',
|
||||||
fnc: 'removeQueueFirst',
|
fnc: 'removeQueueFirst',
|
||||||
permission: 'master'
|
permission: 'master'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
reg: '#OpenAI(剩余)?(余额|额度)',
|
||||||
|
fnc: 'totalAvailable',
|
||||||
|
permission: 'master'
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
@ -524,6 +529,26 @@ export class chatgpt extends plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async totalAvailable(e) {
|
||||||
|
// 查询OpenAI Plus剩余试用额度
|
||||||
|
fetch('https://api.openai.com/dashboard/billing/credit_grants', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer ' + Config.apiKey,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.error) {
|
||||||
|
console.log(data.error)
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
this.reply('总额度:$' + data.total_granted + '\n已使用额度:$' + data.total_used + '\n当前剩余额度:$' + data.total_available)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #chatgpt
|
* #chatgpt
|
||||||
* @param prompt 问题
|
* @param prompt 问题
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,11 @@ let helpData = [
|
||||||
title: '#chatgpt设置(必应)token',
|
title: '#chatgpt设置(必应)token',
|
||||||
desc: '设置ChatGPT或bing的Token'
|
desc: '设置ChatGPT或bing的Token'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: 'help',
|
||||||
|
title: '#OpenAI剩余额度',
|
||||||
|
desc: '查询OpenAI Plus剩余试用额度'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
icon: 'help',
|
icon: 'help',
|
||||||
title: '#chatgpt模式帮助',
|
title: '#chatgpt模式帮助',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue