modify opay check condition
This commit is contained in:
parent
a8a3f595ec
commit
10c3e09014
@ -242,11 +242,11 @@ new cron.CronJob({ //eslint-disable-line
|
|||||||
let db = await DB.connect()
|
let db = await DB.connect()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let text = `select "name", "id", "opayid" from "public"."twitch_channel" where "opayid" != '' and "join" = true`
|
let text = `select "name", "id", "opayid", "join" from "public"."twitch_channel" where "opayid" != ''`
|
||||||
let result = await db.query({ text })
|
let result = await db.query({ text })
|
||||||
if (result.rowCount > 0) {
|
if (result.rowCount > 0) {
|
||||||
result.rows.forEach(t => {
|
result.rows.forEach(t => {
|
||||||
checkDonate(t.name, t.opayid).then(() => {}).catch(() => {})
|
checkDonate(t.name, t.opayid, t.join).then(() => {}).catch(() => {})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -260,7 +260,7 @@ new cron.CronJob({ //eslint-disable-line
|
|||||||
timeZone: 'Asia/Taipei'
|
timeZone: 'Asia/Taipei'
|
||||||
})
|
})
|
||||||
|
|
||||||
const checkDonate = async (loginName = null, opayid = null) => {
|
const checkDonate = async (loginName = null, opayid = null, join = false) => {
|
||||||
if (typeof loginName !== 'string' || loginName.trim().length === 0) return null
|
if (typeof loginName !== 'string' || loginName.trim().length === 0) return null
|
||||||
if (typeof opayid !== 'string' || opayid.trim().length === 0) return null
|
if (typeof opayid !== 'string' || opayid.trim().length === 0) return null
|
||||||
let url = `https://payment.opay.tw/Broadcaster/CheckDonate/${opayid}`
|
let url = `https://payment.opay.tw/Broadcaster/CheckDonate/${opayid}`
|
||||||
@ -308,6 +308,7 @@ const checkDonate = async (loginName = null, opayid = null) => {
|
|||||||
text,
|
text,
|
||||||
values
|
values
|
||||||
})
|
})
|
||||||
|
if (join) {
|
||||||
let msg = `/me 感謝 ${i.name} 贊助了 ${i.amount} 元, ${i.msg}`
|
let msg = `/me 感謝 ${i.name} 贊助了 ${i.amount} 元, ${i.msg}`
|
||||||
process.send({
|
process.send({
|
||||||
type: 'twitchSend',
|
type: 'twitchSend',
|
||||||
@ -315,6 +316,7 @@ const checkDonate = async (loginName = null, opayid = null) => {
|
|||||||
msg, channel: loginName
|
msg, channel: loginName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user