-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from Angels-Ray/feature/linkai-login
linkai增加可登录选项,修复gobing部分bug
- Loading branch information
Showing
3 changed files
with
139 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,95 @@ | ||
const account = config.gobing.account | ||
const password = config.gobing.password | ||
const $http = require('axios'); | ||
let result = "【Gobing每日签到】\n" | ||
// Gobing每日签到 | ||
|
||
const $http = require("axios"); | ||
|
||
const account = config.gobing.account; | ||
const password = config.gobing.password; | ||
|
||
let result = ""; | ||
headers = { | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json, text/plain, */*', | ||
'Origin': 'https://www.gobing.cn', | ||
'Referer': 'https://www.gobing.cn/', | ||
'sec-ch-ua': '"Chromium";v="9", "Not?A_Brand";v="8"', | ||
'sec-ch-ua-mobile': '?0', | ||
'sec-ch-ua-platform': '"Windows"', | ||
'Sec-Fetch-Dest': 'empty', | ||
'Sec-Fetch-Mode': 'cors', | ||
'Sec-Fetch-Site': 'same-site', | ||
'Accept-Encoding': 'gzip, deflate, br', | ||
'Accept-Language': 'zh-CN,zh;q=0.9', | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.3.1311 SLBChan/105', | ||
token: "" | ||
"Content-Type": "application/json", | ||
Accept: "application/json, text/plain, */*", | ||
Origin: "https://www.gobing.cn", | ||
Referer: "https://www.gobing.cn/", | ||
"sec-ch-ua": '"Chromium";v="9", "Not?A_Brand";v="8"', | ||
"sec-ch-ua-mobile": "?0", | ||
"sec-ch-ua-platform": '"Windows"', | ||
"Sec-Fetch-Dest": "empty", | ||
"Sec-Fetch-Mode": "cors", | ||
"Sec-Fetch-Site": "same-site", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Accept-Language": "zh-CN,zh;q=0.9", | ||
"User-Agent": | ||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.3.1311 SLBChan/105", | ||
token: "", | ||
}; | ||
|
||
function _log(msg) { | ||
console.log(msg); | ||
result += `${msg}\n`; | ||
} | ||
|
||
function getToken(account, password) { | ||
const data = { | ||
"account": account, | ||
"password": password | ||
account: account, | ||
password: password, | ||
}; | ||
return new Promise(async (resolve) => { | ||
let token; | ||
try { | ||
const response = await $http.post('https://api.gobing.cn/v1/user/login', data); | ||
const token = response.data.data.token; | ||
result += "登陆成功!\n" | ||
console.log("token: " + token) | ||
const response = await $http.post( | ||
"https://api.gobing.cn/v1/user/login", | ||
data | ||
); | ||
token = response.data.data?.token; | ||
resolve(token); | ||
} catch (err) { | ||
console.log(err.response); | ||
token = null | ||
result += "登陆失败!\n" | ||
} | ||
resolve(); | ||
}); | ||
} | ||
|
||
|
||
function addsign(token) { | ||
return new Promise(async (resolve) => { | ||
try { | ||
const data = {}; | ||
headers["token"] = token | ||
let url = "https://api.gobing.cn/v1/signin/signin" | ||
headers["token"] = token; | ||
let url = "https://api.gobing.cn/v1/signin/signin"; | ||
let res = await $http.post(url, data, { | ||
headers | ||
}) | ||
const msg = res.data.msg; | ||
result += "签到成功: " + msg + "\n"; | ||
headers, | ||
}); | ||
_log(`签到成功: ${res.data?.msg}`); | ||
} catch (err) { | ||
if (err.response.status == 400 && err.response.data.msg.includes("成功签到")) { | ||
result += err.response.data.msg + "\n"; | ||
if ( | ||
err.response.status == 400 && | ||
err.response.data.msg.includes("成功签到") | ||
) { | ||
_log(err.response.data?.msg); | ||
} else { | ||
console.error('Error sending GET request:', err.response.data.msg); | ||
result += "签到失败" + err.response.status + "\n"; | ||
console.error( | ||
"Error sending GET request:", | ||
err.response.data.msg | ||
); | ||
_log(`签到失败 ${err.response.status}`); | ||
} | ||
} | ||
resolve(); | ||
}); | ||
} | ||
|
||
|
||
async function gobing() { | ||
console.log("任务开始") | ||
token = await getToken(account, password) | ||
_log("【Gobing每日签到】:"); | ||
token = await getToken(account, password); | ||
|
||
if (token) { | ||
await addsign(token) | ||
_log("获取token成功"); | ||
await addsign(token); | ||
} else { | ||
_log("获取token失败"); | ||
} | ||
|
||
console.log(result); | ||
return result | ||
|
||
return result; | ||
} | ||
|
||
// gobing() | ||
module.exports = gobing; | ||
module.exports = gobing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,82 @@ | ||
// https://chat.link-ai.tech/home?share=GBoWyH | ||
const axios = require("axios"); | ||
function linkai() { | ||
return new Promise(async (resolve) => { | ||
try { | ||
const url = 'https://chat.link-ai.tech/api/chat/web/app/user/sign/in'; | ||
const token = config.linkai.Authorization; // | ||
|
||
const response = await axios.get(url, { | ||
headers: { | ||
Authorization: token, | ||
}, | ||
// linkai | ||
|
||
const axios = require("axios"); | ||
|
||
let result = ""; | ||
const linkaiConfig = config.linkai; | ||
|
||
function _log(msg) { | ||
console.log(msg); | ||
result += `${msg}\n`; | ||
} | ||
|
||
function login(username, password) { | ||
return new Promise(async (resolve) => { | ||
let authorization = ""; | ||
try { | ||
const response = await axios.post( | ||
"https://link-ai.tech/api/login", | ||
`username=${username}&password=${password}`, | ||
{ | ||
headers: { | ||
"Content-Type": | ||
"application/x-www-form-urlencoded;charset=UTF-8", | ||
}, | ||
} | ||
); | ||
authorization = response.data.data.token; | ||
_log("登录成功!"); | ||
} catch (error) { | ||
_log("登录失败!"); | ||
} | ||
resolve(authorization); | ||
}); | ||
} | ||
|
||
if (response.data.success) { | ||
msg = `签到成功,获得 ${response.data.data.score} 积分`; | ||
} else { | ||
msg = `签到失败,原因:${response.data.message}`; | ||
function signIn(authorization) { | ||
return new Promise(async (resolve) => { | ||
try { | ||
const response = await axios.get( | ||
"https://link-ai.tech/api/chat/web/app/user/sign/in", | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${authorization}`, | ||
"User-Agent": | ||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36", | ||
}, | ||
} | ||
); | ||
if (response.data.success) { | ||
_log(`签到成功,获得 ${response.data.data.score} 积分`); | ||
} else if (response.data.message.includes("已签到")) { | ||
_log(`签到成功,${response.data.message}`); | ||
} else { | ||
_log(`签到失败,原因:${response.data.message}`); | ||
} | ||
} catch (error) { | ||
console.log(`${error.message}`); | ||
_log(`签到失败, 请求错误`); | ||
} | ||
resolve(); | ||
}); | ||
} | ||
|
||
async function linkai() { | ||
_log("【linkai】:"); | ||
|
||
let authorization = linkaiConfig.Authorization || null; | ||
if (!authorization) { | ||
authorization = await login( | ||
linkaiConfig.username, | ||
linkaiConfig.password | ||
); | ||
} | ||
console.log(msg) | ||
} catch (err) { | ||
msg =`签到失败,原因:${err.message}`; | ||
|
||
if (authorization) { | ||
await signIn(authorization); | ||
} | ||
resolve("【linkai】:" + msg); | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
module.exports = linkai; |