Skip to content

Commit

Permalink
fix: qmsg 酱 增加 bot 参数
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoMeiYouRen committed Oct 30, 2024
1 parent 447fe60 commit 95b5433
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/push/qmsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ajax } from '@/utils/ajax'
const Debugger = debug('push:qmsg')

/**
* 推送类型,见 [Qmsg](https://qmsg.zendee.cn/docs)。
* 推送类型,见 [Qmsg](https://qmsg.zendee.cn/docs/api)。
*/
export type QmsgPushType = 'send' | 'group'

Expand All @@ -21,15 +21,26 @@ export type QmsgPushType = 'send' | 'group'
export class Qmsg implements Send {

private QMSG_KEY: string
private QMSG_BOT?: string

constructor(QMSG_KEY: string) {
constructor(QMSG_KEY: string, QMSG_BOT?: string) {
this.QMSG_KEY = QMSG_KEY
Debugger('set QMSG_KEY: "%s"', QMSG_KEY)
this.QMSG_BOT = QMSG_BOT
Debugger('set QMSG_KEY: "%s", QMSG_BOT: "%s"', QMSG_KEY, QMSG_BOT)
if (!this.QMSG_KEY) {
throw new Error('QMSG_KEY 是必须的!')
}
}

/**
*
*
* @author CaoMeiYouRen
* @date 2024-10-30
* @param msg 要推送的消息内容
* @param [qq] 指定要接收消息的QQ号或者QQ群。多个以英文逗号分割,例如:12345,12346
* @param [type='send'] send 表示发送消息给指定的QQ号,group 表示发送消息给指定的QQ群。默认为 send
*/
async send(msg: string, qq?: string, type: QmsgPushType = 'send'): Promise<AxiosResponse<any>> {
Debugger('msg: "%s", qq: "%s", type: "%s"', msg, qq, type)
return ajax({
Expand All @@ -38,7 +49,7 @@ export class Qmsg implements Send {
'Content-Type': 'application/x-www-form-urlencoded',
},
method: 'POST',
data: { msg, qq },
data: { msg, qq, bot: this.QMSG_BOT },
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import crypto from 'crypto'
* @param suiteTicket
* @param suiteSecret
*/
export function generateSignature(timestamp: string | number, suiteTicket: string, suiteSecret: crypto.BinaryLike | crypto.KeyObject) {
export function generateSignature(timestamp: string | number, suiteTicket: string, suiteSecret: crypto.BinaryLike | crypto.KeyObject): string {
// 创建要签名的字符串
const stringToSign = `${timestamp}\n${suiteTicket}`

Expand Down

0 comments on commit 95b5433

Please sign in to comment.