From 78a39feab5181e6dfc11e84bf216a7e0164f11a1 Mon Sep 17 00:00:00 2001 From: pingport80 Date: Wed, 13 Oct 2021 12:33:07 +0530 Subject: [PATCH 1/4] add list of members who didn't show up --- app.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/app.ts b/app.ts index ce523fa..be981ce 100644 --- a/app.ts +++ b/app.ts @@ -119,6 +119,12 @@ setInterval(() => { }, { merge: true } ) + db.collection("members") + doc("sourceStatus") + .update( + { + reporter: false + }) } } }, 1000 * 60) @@ -196,6 +202,37 @@ setInterval(async () => { let memberData = memberDoc.data() as MemberData if (memberData[date].timeStamp === undefined) { let reporterName = memberData[date].reporter + const optKeyboard: telegramBot.SendMessageOptions = { + parse_mode: "Markdown", + reply_markup: { + keyboard: [[{ text: "Source Did not respond yet" }], [{ text: "Did not asked the report yet" }]] + } + } + const optRemove: telegramBot.SendMessageOptions = { + reply_markup: { + remove_keyboard: true + } + } + await bot.sendMessage( + memberNameChatIdMap[reporterName], + `Just in case your source didn't show up, let us know.`, + optKeyboard + ) + var chatId = parseInt(memberNameChatIdMap[reporterName]) + responseCallbacks[chatId] = async response => { + var status = (response.text == "Source Did not respond yet") ? true : false + db.collection("members") + .doc("sourceStatus") + .update({ + reporterName: status + } + ) + bot.sendMessage( + memberNameChatIdMap[reporterName], + `Alright, Thanks!`, + optRemove + ) + } bot.sendMessage( memberNameChatIdMap[reporterName], `Hey there, This is a gentle reminder. Please submit your report soon using the /report command.` @@ -223,6 +260,15 @@ setInterval(async () => { for (let idx = 0; idx < source.length; idx++) { let member = source[idx] const membersData = await db.collection("members").doc(member).get() + var sources = await db.collection("members") + .doc("sourceStatus") + .get() + .then( query => { + query._fieldsProto[source[idx]].booleanValue + }) + + sources && sourceNames.push(source[idx]) + const memberData = membersData.data() as MemberData if (memberData[date].timeStamp === undefined) { reporterNames.push(memberData[date].reporter) @@ -239,6 +285,10 @@ setInterval(async () => { oslGroupId, `Those who have not submitted the report yet:\n${reporterNames.join( "\n" + )} + \n\n + Those who did not respond to their reporters yet:\n${sourceNames.join( + "\n" )}` ) }) From 08f1e3502f3f01bd68b3199916d049d6c231e2b2 Mon Sep 17 00:00:00 2001 From: pingport80 Date: Thu, 9 Dec 2021 10:02:04 +0530 Subject: [PATCH 2/4] update the message --- app.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.ts b/app.ts index be981ce..4926ce5 100644 --- a/app.ts +++ b/app.ts @@ -205,7 +205,7 @@ setInterval(async () => { const optKeyboard: telegramBot.SendMessageOptions = { parse_mode: "Markdown", reply_markup: { - keyboard: [[{ text: "Source Did not respond yet" }], [{ text: "Did not asked the report yet" }]] + keyboard: [[{ text: "yes" }], [{ text: "no" }]] } } const optRemove: telegramBot.SendMessageOptions = { @@ -215,7 +215,7 @@ setInterval(async () => { } await bot.sendMessage( memberNameChatIdMap[reporterName], - `Just in case your source didn't show up, let us know.`, + `Did your source respond yet`, optKeyboard ) var chatId = parseInt(memberNameChatIdMap[reporterName]) From 7bb15bf89385b2de3ecb12fd5aded1d52a078e1a Mon Sep 17 00:00:00 2001 From: pingport80 Date: Thu, 9 Dec 2021 10:03:24 +0530 Subject: [PATCH 3/4] add missing dot --- app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.ts b/app.ts index 4926ce5..cd489d0 100644 --- a/app.ts +++ b/app.ts @@ -120,7 +120,7 @@ setInterval(() => { { merge: true } ) db.collection("members") - doc("sourceStatus") + .doc("sourceStatus") .update( { reporter: false From d461455817358c7e444f1d643e3d006903b80747 Mon Sep 17 00:00:00 2001 From: pingport80 Date: Thu, 9 Dec 2021 10:07:01 +0530 Subject: [PATCH 4/4] update app.ts --- app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.ts b/app.ts index cd489d0..dd075fd 100644 --- a/app.ts +++ b/app.ts @@ -220,7 +220,7 @@ setInterval(async () => { ) var chatId = parseInt(memberNameChatIdMap[reporterName]) responseCallbacks[chatId] = async response => { - var status = (response.text == "Source Did not respond yet") ? true : false + var status = (response.text == "no") ? true : false db.collection("members") .doc("sourceStatus") .update({