1 Star 1 Fork 2

chinjiaqing/juejin-helper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sign.js 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
chinjiaqing 提交于 2022-07-14 16:45 . fix:登录失败处理
const JuejinHttp = require('./juejin/api')
const config = require("./config/index")
const { getCookie } = require('./juejin/cookie')
const { sendEmail } = require(`./utils/email`)
const signIn = async () => {
try {
const cookie = await getCookie()
if (!cookie) {
throw new Error(`获取cookie失败`)
}
const API = new JuejinHttp(cookie)
const isCheckIn = await API.queryTodayStatus()
let lotteryName = ''
if (isCheckIn) {
console.log(`今日已签到`)
return
} else {
await API.handleCheckIn()
console.log(`签到成功`)
}
const userInfo = await API.queryUserProfile()
const { free_count } = await API.queryLotteryConfig()
if (!free_count) {
console.log(`今日已免费抽奖`)
} else {
const { lotteries } = await API.queryLuckyList()
const luckyId = lotteries && lotteries[0] ? lotteries[0]['history_id'] : 0
const { has_dip, dip_action, total_value } = await API.handleDipLucky(luckyId)
if (has_dip) {
console.log(`今日已沾过喜气`)
}
if (dip_action === 1) {
console.log(`沾喜气成功`)
}
console.log(`当前喜气值:${total_value}`)
const { lottery_name } = await API.handleLotteryDraw()
lotteryName = lottery_name
console.log(`抽奖成功:${lotteryName}`)
}
const totalPoint = await API.queryTotalPoint()
console.log(`当前矿石:${totalPoint}`)
console.log(`签到成功`)
await sendEmail({
to: config.user.email,
text: `签到成功,拥有矿石:${totalPoint}`,
subject: '【掘金】签到成功'
})
} catch (err) {
console.log(`签到失败`)
console.log(err)
await sendEmail({
to: config.user.email,
text: `签到失败:${err.message}`,
subject: '【掘金】签到失败'
})
}
}
module.exports = {
signIn
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chinjiaqing/juejin-helper.git
[email protected]:chinjiaqing/juejin-helper.git
chinjiaqing
juejin-helper
juejin-helper
main

搜索帮助