From 10c3e0901406aa88e7732ace520c517b9e82d249 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 12 Sep 2018 20:30:42 +0800 Subject: [PATCH] modify opay check condition --- background.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/background.js b/background.js index cb6224e..ca2b0da 100644 --- a/background.js +++ b/background.js @@ -242,11 +242,11 @@ new cron.CronJob({ //eslint-disable-line let db = await DB.connect() 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 }) if (result.rowCount > 0) { result.rows.forEach(t => { - checkDonate(t.name, t.opayid).then(() => {}).catch(() => {}) + checkDonate(t.name, t.opayid, t.join).then(() => {}).catch(() => {}) }) } } catch (err) { @@ -260,7 +260,7 @@ new cron.CronJob({ //eslint-disable-line 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 opayid !== 'string' || opayid.trim().length === 0) return null let url = `https://payment.opay.tw/Broadcaster/CheckDonate/${opayid}` @@ -308,13 +308,15 @@ const checkDonate = async (loginName = null, opayid = null) => { text, values }) - let msg = `/me 感謝 ${i.name} 贊助了 ${i.amount} 元, ${i.msg}` - process.send({ - type: 'twitchSend', - data: { - msg, channel: loginName - } - }) + if (join) { + let msg = `/me 感謝 ${i.name} 贊助了 ${i.amount} 元, ${i.msg}` + process.send({ + type: 'twitchSend', + data: { + msg, channel: loginName + } + }) + } } catch (err) { console.log(err) }