mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: 邮箱打码
This commit is contained in:
parent
c46c8fe458
commit
76caf5d040
2 changed files with 54 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import plugin from '../../../lib/plugins/plugin.js'
|
import plugin from '../../../lib/plugins/plugin.js'
|
||||||
import { SunoClient } from '../client/SunoClient.js'
|
import { SunoClient } from '../client/SunoClient.js'
|
||||||
import { Config } from '../utils/config.js'
|
import { Config } from '../utils/config.js'
|
||||||
import { downloadFile } from '../utils/common.js'
|
import { downloadFile, maskEmail } from '../utils/common.js'
|
||||||
import common from '../../../lib/common/common.js'
|
import common from '../../../lib/common/common.js'
|
||||||
|
|
||||||
export class Vocal extends plugin {
|
export class Vocal extends plugin {
|
||||||
|
|
@ -59,7 +59,9 @@ export class Vocal extends plugin {
|
||||||
let client = new SunoClient({ sessToken: sess, clientToken })
|
let client = new SunoClient({ sessToken: sess, clientToken })
|
||||||
let { credit, email } = await client.queryCredit()
|
let { credit, email } = await client.queryCredit()
|
||||||
logger.info({ credit, email })
|
logger.info({ credit, email })
|
||||||
msg += `用户${email}余额:${credit}\n`
|
msg += `用户: ${maskEmail(email)} 余额:${credit}\n`
|
||||||
|
msg += '-------------------\n'
|
||||||
|
msg += 'Notice:每首歌消耗5credit,每次生成2首歌'
|
||||||
}
|
}
|
||||||
await e.reply(msg)
|
await e.reply(msg)
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { translate } from './translate.js'
|
||||||
import uploadRecord from './uploadRecord.js'
|
import uploadRecord from './uploadRecord.js'
|
||||||
import Version from './version.js'
|
import Version from './version.js'
|
||||||
import fetch, { FormData, fileFromSync } from 'node-fetch'
|
import fetch, { FormData, fileFromSync } from 'node-fetch'
|
||||||
import https from "https";
|
import https from 'https'
|
||||||
let pdfjsLib
|
let pdfjsLib
|
||||||
try {
|
try {
|
||||||
pdfjsLib = (await import('pdfjs-dist')).default
|
pdfjsLib = (await import('pdfjs-dist')).default
|
||||||
|
|
@ -1261,3 +1261,52 @@ export async function extractContentFromFile (fileMsgElem, e) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generated by ai
|
||||||
|
* @param email
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
export function maskEmail (email) {
|
||||||
|
// 使用正则表达式匹配电子邮件地址的用户名和域名部分
|
||||||
|
const regex = /^([^@]+)@([^@]+)$/
|
||||||
|
const match = email.match(regex)
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
|
throw new Error('Invalid email format')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户名和域名
|
||||||
|
const username = match[1]
|
||||||
|
const domain = match[2]
|
||||||
|
|
||||||
|
// 对用户名部分进行部分打码
|
||||||
|
const maskedUsername = maskString(username)
|
||||||
|
|
||||||
|
// 对域名部分进行部分打码
|
||||||
|
const maskedDomain = maskString(domain)
|
||||||
|
|
||||||
|
// 构造新的电子邮件地址
|
||||||
|
const maskedEmail = maskedUsername + '@' + maskedDomain
|
||||||
|
|
||||||
|
return maskedEmail
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generated by ai
|
||||||
|
* @param str
|
||||||
|
* @returns {*|string}
|
||||||
|
*/
|
||||||
|
function maskString (str) {
|
||||||
|
// 如果字符串长度小于等于2,直接返回原字符串
|
||||||
|
if (str.length <= 2) {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取字符串的前三个字符和后三个字符,中间使用*代替
|
||||||
|
const firstThreeChars = str.substring(0, 3)
|
||||||
|
const lastThreeChars = str.substring(str.length - 3)
|
||||||
|
const maskedChars = '*'.repeat(str.length - 6)
|
||||||
|
|
||||||
|
return firstThreeChars + maskedChars + lastThreeChars
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue