mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
Merge branch 'v2' into v2
This commit is contained in:
commit
64340e2cca
9 changed files with 998 additions and 1008 deletions
45
apps/chat.js
45
apps/chat.js
|
|
@ -1,8 +1,8 @@
|
|||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import common from '../../../lib/common/common.js'
|
||||
import _ from 'lodash'
|
||||
import { Config, defaultOpenAIAPI } from '../utils/config.js'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import delay from 'delay'
|
||||
import { ChatGPTAPI } from '../utils/openai/chatgpt-api.js'
|
||||
import SydneyAIClient from '../utils/SydneyAIClient.js'
|
||||
import { PoeClient } from '../utils/poe/index.js'
|
||||
|
|
@ -1041,7 +1041,7 @@ export class chatgpt extends plugin {
|
|||
logger.info(`问题超时已弹出,chatgpt队列前方还有${length}个问题。管理员可通过#清空队列来强制清除所有等待的问题。`)
|
||||
}
|
||||
}
|
||||
await delay(1500)
|
||||
await common.sleep(1500)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1514,12 +1514,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
const userData = await getUserData(e.user_id)
|
||||
const useCast = userData.cast || {}
|
||||
if (use === 'browser') {
|
||||
{
|
||||
return await this.chatgptBrowserBased(prompt, conversation)
|
||||
}
|
||||
} else if (use === 'bing') {
|
||||
{
|
||||
if (use === 'bing') {
|
||||
let throttledTokens = []
|
||||
let {
|
||||
bingToken,
|
||||
|
|
@ -1700,7 +1695,7 @@ export class chatgpt extends plugin {
|
|||
retry = 0
|
||||
}
|
||||
} else {
|
||||
// 未登录用户maxConv目前为5或10,出验证码没救
|
||||
// 未登录用户maxConv目前为5或10,出验证码是ip或MUID问题
|
||||
logger.warn(`token [${bingToken}] 出现必应验证码,请前往网页版或app手动解决`)
|
||||
errorMessage = message
|
||||
retry = 0
|
||||
|
|
@ -1749,12 +1744,11 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
} while (retry > 0)
|
||||
if (errorMessage) {
|
||||
response = response || {}
|
||||
if (errorMessage.includes('CaptchaChallenge')) {
|
||||
if (bingToken) {
|
||||
errorMessage = '出现验证码,请使用当前账户前往https://www.bing.com/chat或Edge侧边栏或移动端APP手动解除验证码'
|
||||
} else {
|
||||
errorMessage = '未配置必应账户,请绑定必应账户再使用必应模式'
|
||||
errorMessage = '未配置必应账户,建议绑定必应账户再使用必应模式'
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
|
@ -1779,9 +1773,7 @@ export class chatgpt extends plugin {
|
|||
noMsg: true
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (use === 'api3') {
|
||||
{
|
||||
// official without cloudflare
|
||||
let accessToken = await redis.get('CHATGPT:TOKEN')
|
||||
if (!accessToken) {
|
||||
|
|
@ -1804,9 +1796,7 @@ export class chatgpt extends plugin {
|
|||
await redis.set(`CHATGPT:CONVERSATION_CREATER_NICK_NAME:${sendMessageResult.conversationId}`, e.sender.card)
|
||||
}
|
||||
return sendMessageResult
|
||||
}
|
||||
} else if (use === 'chatglm') {
|
||||
{
|
||||
const cacheOptions = {
|
||||
namespace: 'chatglm_6b',
|
||||
store: new KeyvFile({ filename: 'cache.json' })
|
||||
|
|
@ -1817,9 +1807,7 @@ export class chatgpt extends plugin {
|
|||
})
|
||||
let sendMessageResult = await this.chatGPTApi.sendMessage(prompt, conversation)
|
||||
return sendMessageResult
|
||||
}
|
||||
} else if (use === 'poe') {
|
||||
{
|
||||
const cookie = await redis.get('CHATGPT:POE_TOKEN')
|
||||
if (!cookie) {
|
||||
throw new Error('未绑定Poe Cookie,请使用#chatgpt设置Poe token命令绑定cookie')
|
||||
|
|
@ -1836,9 +1824,7 @@ export class chatgpt extends plugin {
|
|||
return {
|
||||
text: response.data
|
||||
}
|
||||
}
|
||||
} else if (use === 'claude') {
|
||||
{
|
||||
let client = new SlackClaudeClient({
|
||||
slackUserToken: Config.slackUserToken,
|
||||
slackChannelId: Config.slackChannelId
|
||||
|
|
@ -1861,9 +1847,7 @@ export class chatgpt extends plugin {
|
|||
return {
|
||||
text
|
||||
}
|
||||
}
|
||||
} else if (use === 'claude2') {
|
||||
{
|
||||
let { conversationId } = conversation
|
||||
let client = new ClaudeAIClient({
|
||||
organizationId: Config.claudeAIOrganizationId,
|
||||
|
|
@ -1902,9 +1886,7 @@ export class chatgpt extends plugin {
|
|||
let conv = await client.createConversation()
|
||||
return await client.sendMessage(prompt, conv.uuid, attachments)
|
||||
}
|
||||
}
|
||||
} else if (use === 'xh') {
|
||||
{
|
||||
const cacheOptions = {
|
||||
namespace: 'xh',
|
||||
store: new KeyvFile({ filename: 'cache.json' })
|
||||
|
|
@ -1926,9 +1908,7 @@ export class chatgpt extends plugin {
|
|||
image: image ? image[0] : undefined
|
||||
})
|
||||
return response
|
||||
}
|
||||
} else if (use === 'azure') {
|
||||
{
|
||||
let azureModel
|
||||
try {
|
||||
azureModel = await import('@azure/openai')
|
||||
|
|
@ -1951,9 +1931,7 @@ export class chatgpt extends plugin {
|
|||
text: completion.content,
|
||||
message: completion
|
||||
}
|
||||
}
|
||||
} else if (use === 'qwen') {
|
||||
{
|
||||
let completionParams = {
|
||||
parameters: {
|
||||
top_p: Config.qwenTopP || 0.5,
|
||||
|
|
@ -1968,11 +1946,11 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
const currentDate = new Date().toISOString().split('T')[0]
|
||||
|
||||
async function um(message) {
|
||||
async function um (message) {
|
||||
return await upsertMessage(message, 'QWEN')
|
||||
}
|
||||
|
||||
async function gm(id) {
|
||||
async function gm (id) {
|
||||
return await getMessageById(id, 'QWEN')
|
||||
}
|
||||
|
||||
|
|
@ -2006,9 +1984,7 @@ export class chatgpt extends plugin {
|
|||
throw new Error(err)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
} else if (use === 'bard') {
|
||||
{
|
||||
// 处理cookie
|
||||
const matchesPSID = /__Secure-1PSID=([^;]+)/.exec(Config.bardPsid)
|
||||
const matchesPSIDTS = /__Secure-1PSIDTS=([^;]+)/.exec(Config.bardPsid)
|
||||
|
|
@ -2057,9 +2033,7 @@ export class chatgpt extends plugin {
|
|||
text: response.content,
|
||||
images: response.images
|
||||
}
|
||||
}
|
||||
} else if (use === 'gemini') {
|
||||
{
|
||||
let client = new CustomGoogleGeminiClient({
|
||||
e,
|
||||
userId: e.sender.user_id,
|
||||
|
|
@ -2174,9 +2148,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
option.system = system
|
||||
return await client.sendMessage(prompt, option)
|
||||
}
|
||||
} else {
|
||||
{
|
||||
// openai api
|
||||
let completionParams = {}
|
||||
if (Config.model) {
|
||||
|
|
@ -2421,7 +2393,7 @@ export class chatgpt extends plugin {
|
|||
option.parentMessageId = msg.id
|
||||
option.name = name
|
||||
// 不然普通用户可能会被openai限速
|
||||
await delay(300)
|
||||
await common.sleep(300)
|
||||
msg = await this.chatGPTApi.sendMessage(functionResult, option, 'function')
|
||||
logger.info(msg)
|
||||
}
|
||||
|
|
@ -2458,7 +2430,6 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async newClaudeConversation (e) {
|
||||
let presetName = e.msg.replace(/^#claude开启新对话/, '').trim()
|
||||
|
|
|
|||
|
|
@ -176,12 +176,13 @@ export class ChatgptManagement extends plugin {
|
|||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt(本群)?(群\\d+)?(启动|激活|张嘴|开口|说话|上班)$',
|
||||
|
||||
reg: '^#chatgpt(本群)?(群\\d+)?(张嘴|开口|说话|上班)$',
|
||||
fnc: 'openMouth',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt查看?(关闭|闭嘴|关机|休眠|下班|休眠)列表$',
|
||||
reg: '^#chatgpt查看?(闭嘴|关机|休眠|下班)列表$',
|
||||
fnc: 'listShutUp',
|
||||
permission: 'master'
|
||||
},
|
||||
|
|
@ -332,8 +333,8 @@ export class ChatgptManagement extends plugin {
|
|||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: '^#chatgpt修补Gemini$',
|
||||
fnc: 'patchGemini',
|
||||
reg: '^#chatgpt必应(禁用|禁止|关闭|启用|开启)搜索$',
|
||||
fnc: 'switchBingSearch',
|
||||
permission: 'master'
|
||||
}
|
||||
]
|
||||
|
|
@ -1684,6 +1685,16 @@ azure语音:Azure 语音是微软 Azure 平台提供的一项语音服务,
|
|||
return false
|
||||
}
|
||||
|
||||
async switchBingSearch (e) {
|
||||
if (e.msg.includes('启用') || e.msg.includes('开启')) {
|
||||
Config.sydneyEnableSearch = true
|
||||
await e.reply('已开启必应搜索')
|
||||
} else {
|
||||
Config.sydneyEnableSearch = false
|
||||
await e.reply('已禁用必应搜索')
|
||||
}
|
||||
}
|
||||
|
||||
async saveXinghuoModel (e) {
|
||||
if (!this.e.msg) return
|
||||
let token = this.e.msg
|
||||
|
|
|
|||
|
|
@ -380,6 +380,12 @@ export function supportGuoba () {
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'sydneyEnableSearch',
|
||||
label: '是否允许必应进行搜索',
|
||||
bottomHelpMessage: '关闭后必应将禁用搜索',
|
||||
component: 'Switch'
|
||||
},
|
||||
{
|
||||
field: 'enableSuggestedResponses',
|
||||
label: '是否开启建议回复',
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
"@google/generative-ai": "^0.1.1",
|
||||
"@slack/bolt": "^3.13.2",
|
||||
"asn1.js": "^5.0.0",
|
||||
"delay": "^6.0.0",
|
||||
"diff": "^5.1.0",
|
||||
"emoji-strip": "^1.0.1",
|
||||
"eventsource": "^2.0.2",
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@ import crypto from 'crypto'
|
|||
import WebSocket from 'ws'
|
||||
import { Config, pureSydneyInstruction } from './config.js'
|
||||
import { formatDate, getMasterQQ, isCN, getUserData, limitString } from './common.js'
|
||||
import delay from 'delay'
|
||||
import moment from 'moment'
|
||||
import { getProxy } from './proxy.js'
|
||||
import Version from './version.js'
|
||||
import common from '../../../lib/common/common.js'
|
||||
|
||||
if (!globalThis.fetch) {
|
||||
globalThis.fetch = fetch
|
||||
|
|
@ -87,9 +86,12 @@ export default class SydneyAIClient {
|
|||
// 'x-forwarded-for': '1.1.1.1'
|
||||
}
|
||||
}
|
||||
if (this.opts.cookies || this.opts.userToken) {
|
||||
let initCk = 'SRCHD=AF=NOFORM; PPLState=1; SRCHHPGUSR=HV=' + new Date().getTime() + ';'
|
||||
if (this.opts.userToken) {
|
||||
// 疑似无需token了
|
||||
fetchOptions.headers.cookie = this.opts.cookies || `_U=${this.opts.userToken}`
|
||||
fetchOptions.headers.cookie = `${initCk} _U=${this.opts.userToken}`
|
||||
} else {
|
||||
fetchOptions.headers.cookie = initCk
|
||||
}
|
||||
if (this.opts.proxy) {
|
||||
fetchOptions.agent = proxy(Config.proxy)
|
||||
|
|
@ -101,12 +103,12 @@ export default class SydneyAIClient {
|
|||
this.opts.host = 'https://edgeservices.bing.com/edgesvc'
|
||||
}
|
||||
logger.mark('使用host:' + this.opts.host)
|
||||
let response = await fetch(`${this.opts.host}/turing/conversation/create?bundleVersion=1.1366.5`, fetchOptions)
|
||||
let response = await fetch(`${this.opts.host}/turing/conversation/create?bundleVersion=1.1381.12`, fetchOptions)
|
||||
let text = await response.text()
|
||||
let retry = 10
|
||||
while (retry >= 0 && response.status === 200 && !text) {
|
||||
await delay(400)
|
||||
response = await fetch(`${this.opts.host}/turing/conversation/create?bundleVersion=1.1366.5`, fetchOptions)
|
||||
await common.sleep(400)
|
||||
response = await fetch(`${this.opts.host}/turing/conversation/create?bundleVersion=1.1381.12`, fetchOptions)
|
||||
text = await response.text()
|
||||
retry--
|
||||
}
|
||||
|
|
@ -308,8 +310,7 @@ export default class SydneyAIClient {
|
|||
const text = (pureSydney ? pureSydneyInstruction : (useCast?.bing || Config.sydney)).replaceAll(namePlaceholder, botName || defaultBotName) +
|
||||
((Config.enableGroupContext && groupId) ? groupContextTip : '') +
|
||||
((Config.enforceMaster && master) ? masterTip : '') +
|
||||
(Config.sydneyMood ? moodTip : '') +
|
||||
(Config.sydneySystemCode ? '' : '')
|
||||
(Config.sydneyMood ? moodTip : '')
|
||||
// logger.info(text)
|
||||
if (pureSydney) {
|
||||
previousMessages = invocationId === 0
|
||||
|
|
@ -362,7 +363,7 @@ export default class SydneyAIClient {
|
|||
// 'dagslnv1',
|
||||
// 'sportsansgnd',
|
||||
// 'dl_edge_desc',
|
||||
'noknowimg',
|
||||
// 'noknowimg',
|
||||
// 'dtappid',
|
||||
// 'cricinfo',
|
||||
// 'cricinfov2',
|
||||
|
|
@ -370,21 +371,21 @@ export default class SydneyAIClient {
|
|||
// 'gencontentv3',
|
||||
'iycapbing',
|
||||
'iyxapbing',
|
||||
'revimglnk',
|
||||
'revimgsrc1',
|
||||
'revimgur',
|
||||
// 'revimglnk',
|
||||
// 'revimgsrc1',
|
||||
// 'revimgur',
|
||||
'clgalileo',
|
||||
'eredirecturl'
|
||||
]
|
||||
if (Config.enableGenerateContents) {
|
||||
optionsSets.push(...['gencontentv3'])
|
||||
}
|
||||
if (!Config.sydneyEnableSearch || toSummaryFileContent?.content) {
|
||||
optionsSets.push(...['nosearchall'])
|
||||
}
|
||||
let maxConv = Config.maxNumUserMessagesInConversation
|
||||
const currentDate = moment().format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
const imageDate = await this.kblobImage(opts.imageUrl)
|
||||
if (toSummaryFileContent?.content) {
|
||||
// message = `请不要进行搜索,用户的问题是:"${message}"`
|
||||
messageType = 'Chat'
|
||||
}
|
||||
let argument0 = {
|
||||
source: 'cib',
|
||||
optionsSets,
|
||||
|
|
@ -392,17 +393,17 @@ export default class SydneyAIClient {
|
|||
// 'InternalSearchQuery', 'InternalSearchResult', 'Disengaged', 'InternalLoaderMessage', 'Progress', 'RenderCardRequest', 'AdsQuery',
|
||||
'InvokeAction', 'SemanticSerp', 'GenerateContentQuery', 'SearchQuery'],
|
||||
sliceIds: [
|
||||
'e2eperf',
|
||||
'gbacf',
|
||||
'srchqryfix',
|
||||
'caccnctacf',
|
||||
'translref',
|
||||
'fluxnosearchc',
|
||||
'fluxnosearch',
|
||||
'1115rai289s0',
|
||||
'1130deucs0',
|
||||
'1116pythons0',
|
||||
'cacmuidarb'
|
||||
// 'e2eperf',
|
||||
// 'gbacf',
|
||||
// 'srchqryfix',
|
||||
// 'caccnctacf',
|
||||
// 'translref',
|
||||
// 'fluxnosearchc',
|
||||
// 'fluxnosearch',
|
||||
// '1115rai289s0',
|
||||
// '1130deucs0',
|
||||
// '1116pythons0',
|
||||
// 'cacmuidarb'
|
||||
],
|
||||
requestId: crypto.randomUUID(),
|
||||
traceId: genRanHex(32),
|
||||
|
|
@ -476,9 +477,9 @@ export default class SydneyAIClient {
|
|||
conversationId,
|
||||
previousMessages,
|
||||
plugins: [
|
||||
{
|
||||
id: 'c310c353-b9f0-4d76-ab0d-1dd5e979cf68'
|
||||
}
|
||||
// {
|
||||
// id: 'c310c353-b9f0-4d76-ab0d-1dd5e979cf68'
|
||||
// }
|
||||
]
|
||||
}
|
||||
if (encryptedconversationsignature) {
|
||||
|
|
@ -799,6 +800,7 @@ export default class SydneyAIClient {
|
|||
message,
|
||||
conversationExpiryTime: event?.item?.conversationExpiryTime
|
||||
})
|
||||
break
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import lodash from 'lodash'
|
|||
import { Config } from '../utils/config.js'
|
||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||
import { getOpenAIAuth } from './openai-auth.js'
|
||||
import delay from 'delay'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import common from '../../../lib/common/common.js'
|
||||
const chatUrl = 'https://chat.openai.com/chat'
|
||||
let puppeteer = {}
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ export class ChatGPTPuppeteer extends Puppeteer {
|
|||
if (Config['2captchaToken']) {
|
||||
await this._page.solveRecaptchas()
|
||||
}
|
||||
await delay(300)
|
||||
await common.sleep(300)
|
||||
timeout = timeout - 300
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -243,7 +243,7 @@ export class ChatGPTPuppeteer extends Puppeteer {
|
|||
break
|
||||
}
|
||||
|
||||
await delay(300)
|
||||
await common.sleep(300)
|
||||
} while (true)
|
||||
|
||||
if (!await this.getIsAuthenticated()) {
|
||||
|
|
@ -405,7 +405,7 @@ export class ChatGPTPuppeteer extends Puppeteer {
|
|||
if (isAuthenticated) {
|
||||
while (!this._accessToken) {
|
||||
// wait for async response hook result
|
||||
await delay(300)
|
||||
await common.sleep(300)
|
||||
timeout = timeout - 300
|
||||
if (timeout < 0) {
|
||||
const error = new Error('Not signed in')
|
||||
|
|
@ -493,7 +493,7 @@ export class ChatGPTPuppeteer extends Puppeteer {
|
|||
// const responseP = new Promise<string>(async (resolve, reject) => {
|
||||
// try {
|
||||
// do {
|
||||
// await delay(1000)
|
||||
// await common.sleep(1000)
|
||||
|
||||
// // TODO: this logic needs some work because we can have repeat messages...
|
||||
// const newLastMessage = await this.getLastMessage()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ const defaultConfig = {
|
|||
sydneyImageRecognition: false,
|
||||
sydneyMoodTip: 'Your response should be divided into two parts, namely, the text and your mood. The mood available to you can only include: blandness, happy, shy, frustrated, disgusted, and frightened.All content should be replied in this format {"text": "", "mood": ""}.All content except mood should be placed in text, It is important to ensure that the content you reply to can be parsed by json.',
|
||||
enableSuggestedResponses: false,
|
||||
sydneyEnableSearch: false,
|
||||
api: defaultChatGPTAPI,
|
||||
apiBaseUrl: 'https://chat3.avocado.wiki/backend-api',
|
||||
apiForceUseReverse: false,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Config } from '../utils/config.js'
|
||||
import delay from 'delay'
|
||||
import random from 'random'
|
||||
import common from '../../../lib/common/common.js'
|
||||
|
||||
let hasRecaptchaPlugin = !!Config['2captchaToken']
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ export async function getOpenAIAuth (opt) {
|
|||
await waitForConditionOrAtCapacity(page, () =>
|
||||
page.waitForSelector('#__next .btn-primary', { timeout: timeoutMs / 3 })
|
||||
)
|
||||
await delay(500)
|
||||
await common.sleep(500)
|
||||
|
||||
// click login button and wait for navigation to finish
|
||||
do {
|
||||
|
|
@ -69,7 +69,7 @@ export async function getOpenAIAuth (opt) {
|
|||
}),
|
||||
page.click('#__next .btn-primary')
|
||||
])
|
||||
await delay(1000)
|
||||
await common.sleep(1000)
|
||||
} while (page.url().endsWith('/auth/login'))
|
||||
logger.mark('进入登录页面')
|
||||
await checkForChatGPTAtCapacity(page)
|
||||
|
|
@ -90,7 +90,7 @@ export async function getOpenAIAuth (opt) {
|
|||
} else {
|
||||
await page.waitForSelector('#username')
|
||||
await page.type('#username', email, { delay: 20 })
|
||||
await delay(100)
|
||||
await common.sleep(100)
|
||||
|
||||
if (hasRecaptchaPlugin) {
|
||||
// console.log('solveRecaptchas()')
|
||||
|
|
@ -114,7 +114,7 @@ export async function getOpenAIAuth (opt) {
|
|||
submitP()
|
||||
])
|
||||
} else {
|
||||
await delay(2000)
|
||||
await common.sleep(2000)
|
||||
await checkForChatGPTAtCapacity(page)
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ async function checkForChatGPTAtCapacity (page, opts = {}) {
|
|||
timeout: timeoutMs
|
||||
})
|
||||
|
||||
await delay(pollingIntervalMs)
|
||||
await common.sleep(pollingIntervalMs)
|
||||
}
|
||||
} catch (err) {
|
||||
// ignore errors likely due to navigation
|
||||
|
|
@ -251,29 +251,29 @@ async function solveSimpleCaptchas (page) {
|
|||
const verifyYouAreHuman = await page.$('text=Verify you are human')
|
||||
if (verifyYouAreHuman) {
|
||||
logger.mark('encounter cloudflare simple captcha "Verify you are human"')
|
||||
await delay(2000)
|
||||
await common.sleep(2000)
|
||||
await verifyYouAreHuman.click({
|
||||
delay: random.int(5, 25)
|
||||
})
|
||||
await delay(1000)
|
||||
await common.sleep(1000)
|
||||
}
|
||||
const verifyYouAreHumanCN = await page.$('text=确认您是真人')
|
||||
if (verifyYouAreHumanCN) {
|
||||
logger.mark('encounter cloudflare simple captcha "确认您是真人"')
|
||||
await delay(2000)
|
||||
await common.sleep(2000)
|
||||
await verifyYouAreHumanCN.click({
|
||||
delay: random.int(5, 25)
|
||||
})
|
||||
await delay(1000)
|
||||
await common.sleep(1000)
|
||||
}
|
||||
|
||||
const cloudflareButton = await page.$('.hcaptcha-box')
|
||||
if (cloudflareButton) {
|
||||
await delay(2000)
|
||||
await common.sleep(2000)
|
||||
await cloudflareButton.click({
|
||||
delay: random.int(5, 25)
|
||||
})
|
||||
await delay(1000)
|
||||
await common.sleep(1000)
|
||||
}
|
||||
} catch (err) {
|
||||
// ignore errors
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Config } from '../config.js'
|
||||
import slack from '@slack/bolt'
|
||||
import delay from 'delay'
|
||||
import { limitString } from '../common.js'
|
||||
import common from '../../../../lib/common/common.js'
|
||||
let proxy
|
||||
if (Config.proxy) {
|
||||
try {
|
||||
|
|
@ -24,7 +24,7 @@ export class SlackClaudeClient {
|
|||
if (Config.proxy) {
|
||||
option.agent = proxy(Config.proxy)
|
||||
}
|
||||
option.logLevel = Config.debug ? 'debug': 'info'
|
||||
option.logLevel = Config.debug ? 'debug' : 'info'
|
||||
this.app = new slack.App(option)
|
||||
} else {
|
||||
throw new Error('未配置Slack信息')
|
||||
|
|
@ -61,7 +61,7 @@ export class SlackClaudeClient {
|
|||
channel: channel.id,
|
||||
users: Config.slackClaudeUserId
|
||||
})
|
||||
await delay(1000)
|
||||
await common.sleep(1000)
|
||||
} else {
|
||||
channel = channel[0]
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ export class SlackClaudeClient {
|
|||
let response = '_Typing…_'
|
||||
let tryTimes = 0
|
||||
// 发完先等3喵
|
||||
await delay(3000)
|
||||
await common.sleep(3000)
|
||||
while (response.trim().endsWith('_Typing…_')) {
|
||||
let replies = await this.app.client.conversations.replies({
|
||||
token: this.config.slackUserToken,
|
||||
|
|
@ -106,7 +106,7 @@ export class SlackClaudeClient {
|
|||
}
|
||||
}
|
||||
}
|
||||
await delay(2000)
|
||||
await common.sleep(2000)
|
||||
tryTimes++
|
||||
if (tryTimes > 3 && response === '_Typing…_') {
|
||||
// 过了6秒还没任何回复,就重新发一下试试
|
||||
|
|
@ -127,7 +127,7 @@ export class SlackClaudeClient {
|
|||
let response = '_Typing…_'
|
||||
let tryTimes = 0
|
||||
// 发完先等3喵
|
||||
await delay(3000)
|
||||
await common.sleep(3000)
|
||||
while (response.trim().endsWith('_Typing…_')) {
|
||||
let replies = await this.app.client.conversations.replies({
|
||||
token: this.config.slackUserToken,
|
||||
|
|
@ -156,7 +156,7 @@ export class SlackClaudeClient {
|
|||
}
|
||||
}
|
||||
}
|
||||
await delay(2000)
|
||||
await common.sleep(2000)
|
||||
tryTimes++
|
||||
if (tryTimes > 3 && response === '_Typing…_') {
|
||||
// 过了6秒还没任何回复,就重新发一下试试
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue