mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 回退部分修改;增加验证码提示词
This commit is contained in:
parent
ef57259e8a
commit
b1570d6126
3 changed files with 123 additions and 94 deletions
|
|
@ -18,19 +18,6 @@ if (!globalThis.fetch) {
|
|||
globalThis.Request = Request
|
||||
globalThis.Response = Response
|
||||
}
|
||||
try {
|
||||
await import('ws')
|
||||
} catch (error) {
|
||||
logger.warn('【ChatGPT-Plugin】依赖ws未安装,可能影响Sydney模式下Bing对话,建议使用pnpm install ws安装')
|
||||
}
|
||||
let proxy
|
||||
if (Config.proxy) {
|
||||
try {
|
||||
proxy = (await import('https-proxy-agent')).default
|
||||
} catch (e) {
|
||||
console.warn('未安装https-proxy-agent,请在插件目录下执行pnpm add https-proxy-agent')
|
||||
}
|
||||
}
|
||||
|
||||
// async function getWebSocket () {
|
||||
// let WebSocket
|
||||
|
|
@ -111,7 +98,7 @@ export default class SydneyAIClient {
|
|||
fetchOptions.headers.cookie = this.opts.cookies || `_U=${this.opts.userToken}`
|
||||
}
|
||||
if (this.opts.proxy) {
|
||||
fetchOptions.agent = proxy(Config.proxy)
|
||||
fetchOptions.agent = HttpsProxyAgent(Config.proxy)
|
||||
}
|
||||
let accessible = !(await isCN()) || this.opts.proxy
|
||||
if (accessible && !Config.sydneyForceUseReverse) {
|
||||
|
|
@ -243,7 +230,7 @@ export default class SydneyAIClient {
|
|||
onProgress = () => { }
|
||||
}
|
||||
let master = (await getMasterQQ())[0]
|
||||
if (parentMessageId || !conversationSignature || !conversationId || !clientId) {
|
||||
if (!conversationSignature || !conversationId || !clientId) {
|
||||
const createNewConversationResponse = await this.createNewConversation()
|
||||
if (this.debug) {
|
||||
console.debug(createNewConversationResponse)
|
||||
|
|
@ -292,7 +279,7 @@ export default class SydneyAIClient {
|
|||
}
|
||||
})
|
||||
pm = pm.reverse()
|
||||
let previousMessages
|
||||
let previousMessages = []
|
||||
let whoAmI = ''
|
||||
if (Config.enforceMaster && master && qq) {
|
||||
// 加强主人人知
|
||||
|
|
@ -328,7 +315,7 @@ export default class SydneyAIClient {
|
|||
},
|
||||
...pm
|
||||
]
|
||||
: undefined
|
||||
: []
|
||||
} else {
|
||||
previousMessages = invocationId === 0
|
||||
? [
|
||||
|
|
@ -342,7 +329,7 @@ export default class SydneyAIClient {
|
|||
},
|
||||
...pm
|
||||
]
|
||||
: undefined
|
||||
: []
|
||||
}
|
||||
|
||||
const userMessage = {
|
||||
|
|
@ -363,9 +350,9 @@ export default class SydneyAIClient {
|
|||
'responsible_ai_policy_235',
|
||||
'enablemm',
|
||||
toneOption,
|
||||
'dagslnv1',
|
||||
'sportsansgnd',
|
||||
'dl_edge_desc',
|
||||
// 'dagslnv1',
|
||||
// 'sportsansgnd',
|
||||
// 'dl_edge_desc',
|
||||
'noknowimg',
|
||||
// 'dtappid',
|
||||
// 'cricinfo',
|
||||
|
|
@ -380,7 +367,7 @@ export default class SydneyAIClient {
|
|||
}
|
||||
const currentDate = moment().format('YYYY-MM-DDTHH:mm:ssZ')
|
||||
const imageDate = await this.kblobImage(opts.imageUrl)
|
||||
console.log(imageDate)
|
||||
// console.log(imageDate)
|
||||
const obj = {
|
||||
arguments: [
|
||||
{
|
||||
|
|
@ -389,30 +376,30 @@ export default class SydneyAIClient {
|
|||
allowedMessageTypes: ['ActionRequest', 'Chat', 'Context',
|
||||
// 'InternalSearchQuery', 'InternalSearchResult', 'Disengaged', 'InternalLoaderMessage', 'Progress', 'RenderCardRequest', 'AdsQuery',
|
||||
'SemanticSerp', 'GenerateContentQuery', 'SearchQuery'],
|
||||
sliceIds: [],
|
||||
sliceIds: [
|
||||
|
||||
],
|
||||
traceId: genRanHex(32),
|
||||
scenario: 'Underside',
|
||||
verbosity: 'verbose',
|
||||
isStartOfSession: invocationId === 0,
|
||||
message: {
|
||||
locale: 'zh-CN',
|
||||
market: 'zh-CN',
|
||||
region: 'HK',
|
||||
region: 'WW',
|
||||
location: 'lat:47.639557;long:-122.128159;re=1000m;',
|
||||
locationHints: [
|
||||
{
|
||||
country: 'Macedonia',
|
||||
state: 'Centar',
|
||||
city: 'Skopje',
|
||||
zipcode: '1004',
|
||||
timezoneoffset: 1,
|
||||
countryConfidence: 8,
|
||||
cityConfidence: 5,
|
||||
Center: {
|
||||
Latitude: 39.971031896331,
|
||||
Longitude: 116.33522679576237
|
||||
},
|
||||
RegionType: 2,
|
||||
SourceType: 11
|
||||
},
|
||||
{
|
||||
country: 'Hong Kong',
|
||||
timezoneoffset: 8,
|
||||
countryConfidence: 9,
|
||||
Center: {
|
||||
Latitude: 22.15,
|
||||
Longitude: 114.1
|
||||
Latitude: 41.9961,
|
||||
Longitude: 21.4317
|
||||
},
|
||||
RegionType: 2,
|
||||
SourceType: 1
|
||||
|
|
@ -499,10 +486,15 @@ export default class SydneyAIClient {
|
|||
messageType: 'Context',
|
||||
messageId: 'discover-web--page-ping-mriduna-----'
|
||||
})
|
||||
} else {
|
||||
obj.arguments[0].previousMessages.push({
|
||||
author: 'user',
|
||||
description: '<EMPTY>',
|
||||
contextType: 'WebPage',
|
||||
messageType: 'Context'
|
||||
})
|
||||
}
|
||||
if (obj.arguments[0].previousMessages.length === 0) {
|
||||
delete obj.arguments[0].previousMessages
|
||||
}
|
||||
|
||||
let apology = false
|
||||
const messagePromise = new Promise((resolve, reject) => {
|
||||
let replySoFar = ['']
|
||||
|
|
@ -671,7 +663,9 @@ export default class SydneyAIClient {
|
|||
logger.warn('该账户的SERP请求已被限流')
|
||||
logger.warn(JSON.stringify(event.item?.result))
|
||||
} else {
|
||||
reject(`${event.item?.result.value}\n${event.item?.result.error}\n${event.item?.result.exception}`)
|
||||
reject({
|
||||
message: `${event.item?.result.value}\n${event.item?.result.error}\n${event.item?.result.exception}`
|
||||
})
|
||||
}
|
||||
} else {
|
||||
reject('Unexpected message author.')
|
||||
|
|
@ -803,7 +797,7 @@ export default class SydneyAIClient {
|
|||
body: formData
|
||||
}
|
||||
if (this.opts.proxy) {
|
||||
fetchOptions.agent = proxy(Config.proxy)
|
||||
fetchOptions.agent = HttpsProxyAgent(Config.proxy)
|
||||
}
|
||||
let accessible = !(await isCN()) || this.opts.proxy
|
||||
let response = await fetch(`${accessible ? 'https://www.bing.com' : this.opts.host}/images/kblob`, fetchOptions)
|
||||
|
|
@ -843,7 +837,7 @@ async function generateRandomIP () {
|
|||
if (ip) {
|
||||
return ip
|
||||
}
|
||||
const baseIP = '104.28.215.'
|
||||
const baseIP = '62.77.140.'
|
||||
const subnetSize = 254 // 2^8 - 2
|
||||
const randomIPSuffix = Math.floor(Math.random() * subnetSize) + 1
|
||||
ip = baseIP + randomIPSuffix
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import fetch from 'node-fetch'
|
||||
|
||||
// this file is deprecated
|
||||
|
||||
import { Config } from './config.js'
|
||||
import HttpsProxyAgent from 'https-proxy-agent'
|
||||
const newFetch = (url, options = {}) => {
|
||||
|
|
@ -21,23 +24,27 @@ export async function createCaptcha (e, tokenU) {
|
|||
Cookie: `_U=${tokenU};`,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82',
|
||||
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
Referer: 'https://edgeservices.bing.com/edgesvc/chat?udsframed=1&form=SHORUN&clientscopes=chat,noheader,channelstable,&shellsig=ddb7b7dc7a56d0c5350f37b3653696bbeb77496e&setlang=zh-CN&lightschemeovr=1'
|
||||
}
|
||||
})
|
||||
const blob = await imageResponse.blob()
|
||||
let id = imageResponse.headers.get('id')
|
||||
let regionId = imageResponse.headers.get('Regionid')
|
||||
const arrayBuffer = await blob.arrayBuffer()
|
||||
const buffer = Buffer.from(arrayBuffer)
|
||||
const base64String = buffer.toString('base64')
|
||||
// await e.reply(segment.image(base64String))
|
||||
return { id, image: base64String }
|
||||
return { id, regionId, image: base64String }
|
||||
}
|
||||
|
||||
export async function solveCaptcha (id, text, token) {
|
||||
export async function solveCaptcha (id, regionId, text, token) {
|
||||
let baseUrl = Config.sydneyReverseProxy
|
||||
let url = `${baseUrl}/edgesvc/turing/captcha/verify?type=visual&id=${id}®ionId=0&value=${text}`
|
||||
let url = `${baseUrl}/edgesvc/turing/captcha/verify?type=visual&id=${id}®ionId=${regionId}&value=${text}`
|
||||
let res = await newFetch(url, {
|
||||
headers: {
|
||||
Cookie: '_U=' + token
|
||||
Cookie: '_U=' + token,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82',
|
||||
Referer: 'https://edgeservices.bing.com/edgesvc/chat?udsframed=1&form=SHORUN&clientscopes=chat,noheader,channelstable,&shellsig=ddb7b7dc7a56d0c5350f37b3653696bbeb77496e&setlang=zh-CN&lightschemeovr=1'
|
||||
}
|
||||
})
|
||||
res = await res.json()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue