8294634f by Administrator

Merge branch '30852_chatbot_chatgpt' into 'master'

30852_chatbot_chatgpt

See merge request !105
2 parents 810e6366 d82cedaa
...@@ -130,14 +130,14 @@ function App() { ...@@ -130,14 +130,14 @@ function App() {
130 130
131 if(data.status === 'invalid'){ 131 if(data.status === 'invalid'){
132 if(data.limited) { 132 if(data.limited) {
133 window.btutil_modalRegisterUpgrade(); 133 window.btutil_maxUsage();
134 return; 134 return;
135 } 135 }
136 if(data && data.status === 'max-tokens') { 136 if(data && data.status === 'max-tokens') {
137 window.btutil_maxUsage(); 137 window.btutil_maxUsage();
138 return; 138 return;
139 } 139 }
140 window.btutil_modalRegisterUpgrade(true); 140 window.btutil_maxUsage(true);
141 return; 141 return;
142 } 142 }
143 // "gpt-3.5-turbo" 143 // "gpt-3.5-turbo"
......
...@@ -346,7 +346,7 @@ async function runOpensource(req, res) { ...@@ -346,7 +346,7 @@ async function runOpensource(req, res) {
346 } 346 }
347 347
348 async function authenticate(params) { 348 async function authenticate(params) {
349 console.log("349", params) 349
350 let data = await fetch(`${hostapi}/e/authenticate/v2`, { 350 let data = await fetch(`${hostapi}/e/authenticate/v2`, {
351 method: "POST", 351 method: "POST",
352 headers: { 352 headers: {
...@@ -355,12 +355,12 @@ async function authenticate(params) { ...@@ -355,12 +355,12 @@ async function authenticate(params) {
355 body: JSON.stringify(params), 355 body: JSON.stringify(params),
356 referrer: "https://chatgpt.ai-pro.org" 356 referrer: "https://chatgpt.ai-pro.org"
357 }); 357 });
358 console.log("358", data); 358
359 return await data.json(); 359 return await data.json();
360 } 360 }
361 361
362 async function getLimitedUsage(params) { 362 async function getLimitedUsage(params) {
363 console.log("363", params) 363
364 let data = await fetch(`${hostapi}/e/get-usage`, { 364 let data = await fetch(`${hostapi}/e/get-usage`, {
365 method: "POST", 365 method: "POST",
366 headers: { 366 headers: {
...@@ -369,11 +369,11 @@ async function getLimitedUsage(params) { ...@@ -369,11 +369,11 @@ async function getLimitedUsage(params) {
369 body: JSON.stringify(params), 369 body: JSON.stringify(params),
370 referrer: "https://chatgpt.ai-pro.org" 370 referrer: "https://chatgpt.ai-pro.org"
371 }); 371 });
372 console.log("372", data); 372
373 return await data.json(); 373 return await data.json();
374 } 374 }
375 async function getUsage(params) { 375 async function getUsage(params) {
376 console.log("376", params) 376
377 let data = await fetch(`${hostapi}/e/get-chat-usage`, { 377 let data = await fetch(`${hostapi}/e/get-chat-usage`, {
378 method: "POST", 378 method: "POST",
379 headers: { 379 headers: {
...@@ -382,11 +382,11 @@ async function getUsage(params) { ...@@ -382,11 +382,11 @@ async function getUsage(params) {
382 body: JSON.stringify(params), 382 body: JSON.stringify(params),
383 referrer: "https://chatgpt.ai-pro.org" 383 referrer: "https://chatgpt.ai-pro.org"
384 }); 384 });
385 console.log("373", data); 385
386 return await data.json(); 386 return await data.json();
387 } 387 }
388 async function setUsage(params) { 388 async function setUsage(params) {
389 console.log("389", params) 389
390 fetch(`${hostapi}/e/set-usage`, { 390 fetch(`${hostapi}/e/set-usage`, {
391 method: "POST", 391 method: "POST",
392 headers: { 392 headers: {
...@@ -397,7 +397,7 @@ async function setUsage(params) { ...@@ -397,7 +397,7 @@ async function setUsage(params) {
397 }); 397 });
398 } 398 }
399 async function setChatUsage(params) { 399 async function setChatUsage(params) {
400 console.log("400", params) 400
401 fetch(`${hostapi}/e/set-chat-usage`, { 401 fetch(`${hostapi}/e/set-chat-usage`, {
402 method: "POST", 402 method: "POST",
403 headers: { 403 headers: {
...@@ -416,7 +416,7 @@ async function validation (aiwp_app_id, req, res) { ...@@ -416,7 +416,7 @@ async function validation (aiwp_app_id, req, res) {
416 416
417 if (aiwp_logged_in) { 417 if (aiwp_logged_in) {
418 let auth = await authenticate({ "aiwp_logged_in": aiwp_logged_in, "user_event_data": {}, "user_event": "endpoint" }); 418 let auth = await authenticate({ "aiwp_logged_in": aiwp_logged_in, "user_event_data": {}, "user_event": "endpoint" });
419 console.log(auth) 419
420 if (!auth.success) { 420 if (!auth.success) {
421 IS_FREE_USER = true; 421 IS_FREE_USER = true;
422 if (auth.is_restrict) { 422 if (auth.is_restrict) {
...@@ -429,7 +429,7 @@ async function validation (aiwp_app_id, req, res) { ...@@ -429,7 +429,7 @@ async function validation (aiwp_app_id, req, res) {
429 return false; 429 return false;
430 } 430 }
431 } 431 }
432 if (!auth.subscription_type || (auth.auth_version === 'v2' && auth.subscription_type.toLowerCase() === 'basic')) { 432 if (!auth.subscription_type || auth.auth_version === 'v2') {
433 res.json({ status: "invalid" }); 433 res.json({ status: "invalid" });
434 res.status(200); 434 res.status(200);
435 return false; 435 return false;
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!