From 664b473eedd2ed97481e78c73a5ef8b4183c0443 Mon Sep 17 00:00:00 2001 From: Banerjee Aditya Date: Wed, 7 Feb 2024 12:41:55 +0800 Subject: [PATCH 01/10] add ping service --- {whatsapp-bot => ping}/.gitignore | 3 - ping/README.md | 15 ++++ ping/bun.lockb | Bin 0 -> 7714 bytes ping/package.json | 16 ++++ ping/src/components/logger.ts | 23 +++++ ping/src/index.ts | 30 +++++++ ping/tsconfig.json | 23 +++++ whatsapp-bot/.prettierrc | 7 -- whatsapp-bot/README.md | 36 -------- whatsapp-bot/bun.lockb | Bin 78146 -> 0 bytes whatsapp-bot/package.json | 25 ------ whatsapp-bot/src/components/bot.ts | 48 ----------- whatsapp-bot/src/components/logger.ts | 26 ------ whatsapp-bot/src/components/whatsapp.ts | 106 ------------------------ whatsapp-bot/src/constants/message.ts | 3 - whatsapp-bot/src/index.ts | 4 - whatsapp-bot/tsconfig.json | 23 ----- 17 files changed, 107 insertions(+), 281 deletions(-) rename {whatsapp-bot => ping}/.gitignore (98%) create mode 100644 ping/README.md create mode 100755 ping/bun.lockb create mode 100644 ping/package.json create mode 100644 ping/src/components/logger.ts create mode 100644 ping/src/index.ts create mode 100644 ping/tsconfig.json delete mode 100644 whatsapp-bot/.prettierrc delete mode 100644 whatsapp-bot/README.md delete mode 100755 whatsapp-bot/bun.lockb delete mode 100644 whatsapp-bot/package.json delete mode 100644 whatsapp-bot/src/components/bot.ts delete mode 100644 whatsapp-bot/src/components/logger.ts delete mode 100644 whatsapp-bot/src/components/whatsapp.ts delete mode 100644 whatsapp-bot/src/constants/message.ts delete mode 100644 whatsapp-bot/src/index.ts delete mode 100644 whatsapp-bot/tsconfig.json diff --git a/whatsapp-bot/.gitignore b/ping/.gitignore similarity index 98% rename from whatsapp-bot/.gitignore rename to ping/.gitignore index b6fafbb..468f82a 100644 --- a/whatsapp-bot/.gitignore +++ b/ping/.gitignore @@ -1,8 +1,5 @@ # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore -# WhatsApp Web -.wwebjs_cache - # Logs logs diff --git a/ping/README.md b/ping/README.md new file mode 100644 index 0000000..afde3a9 --- /dev/null +++ b/ping/README.md @@ -0,0 +1,15 @@ +# ping + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run src/index.ts +``` + +This project was created using `bun init` in bun v1.0.25. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/ping/bun.lockb b/ping/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..3ad4946825b11c700aaf400c0ca2600e1f84c5b7 GIT binary patch literal 7714 zcmeHMd011&77rL)5WynWtq5wN6iEUhSX2a_6``VnR8Ul~2nhs2z}y54xZq2 zf~X*FD9Yl3)`D6=3RWMeMMc@H+A7wiMXieQopZ_H{ra^K``-Ir|8V#&XXeiQe&@`& zXXeg588eEfpk%y7Vku83jWS)Nkm|z4kwgTBiNq2iM-(9o50G=BtaY_nES6EpNfXie zcCWCM;dgHxocL%@&9L5&!&{3i9Yz(W&ryAwW(iQY=<7+|y&RVnq~3xKu6+FxKj9hf)zzG|Uj%{h>cdxJZEn;ef#s2N&L#iGl*L zEs_Mt<-#D^BD}8)_uz{4=*4371G!Z#(?MeYV0Nb-#NxP@E(=Gm4Bvi%NWnL=`ut*H zX15nlBwVVzT#OZRUdkS(oB!dVg5vZoR5K z=3el*B*V7Rd1p5%w}oC1r}E~lGe10Oe7^{XGk0fY9p7daYc)1OxCq?v9~FG6SWMuu zhWTP0TtHt~@2L>H2MiPdzBfqlD@#+m2tEri&VYxU2;{cCX}q9@ihnKkCMPPLo3L*8o2O@VGH!>6gcc3fJfbE`R3U~)K9!#NQ0E9*bbrF4}j`K&J0cuI+gA$+7J8)q^iETq{ zK+#0v_(5>t+y}#j?RV932uLhMVx8E;tp9!NQyHjm0{`Wr#p>i`QnP>DHNC&v3%9X) z)}=FZ-R!RVOkUxn3VKko>}Fm_ZR!D$Z(;5ilE#deZpZFSQp&#^kT~jkYQgx0p%K*& zEi&^T=7Wudm&6^K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=V@0DBIVzJM`(m&Bn)9%v}AI=l+Dnr+iAM9$V%tEDk?$q{_$spsOG%%OmWi#{lMf zBkw1qXO{;V&Z=tIm}XgL5_z^we_y!@>sf z`y;l8zpNH-%h=wpBt7tEj&OR&^KHW{YD{j`=0AB<>&c2ad23K^`M!_#6py;?xnbtH_jzUUn|zfz3wTM( zO43F>Z9U;WSadgf2ZI;itE8}ZDzf(%Ouul?*}ZK>t=0*)UwTdc>WMR!2G4Bw`ewzB z`B#n^?R}Wrp)btea=7V2s)3&3>YT+3v`T_L=PPsSKA2C4-pc=r2go~*$iHF)^Zf8v z@NY41J@D28|630v;YTBsY_-&Npk#quv6PYrNF-d6O61O#35AZPd}~um94(9xS(yq< z10>>LX@p397*f6JEXalLfp67(M);8hMb|-L%Xb9WpAg_)f!_sqhQ~bz-%)rz#wSM!V(14=rFrPopPhk&E9M|Ooo8LJR$H8|r$qx?H^0(t! zbFDiqz#fue?5ho_Q6VMo^aa=%OLCCfTK?8t0aw6ck!&oWlIDfHNIZE-$$DgzJ4l1wa( zvEkai&H=xX1?oIA$>#!_J=X^HkW4el=t7SGY=a(>izYc=x`*~P$ySrBF!X>2{)ml@ zY&Kj-U6Bkn$rNjA@u7ncvn07{k`va}0xB*aFeGbDvcuY1EBK%YJVf%^B!3J&_FOxz zjrAX3EI|hrlKUn(X295i8hAjF>If|AibUoLr-b2ALK)X(saz(g1q`tOuJvT@G?(q>u`fi6iCCbd?9cZm4S*!Xa{bBsGD@lL>>x zlw79dN+ZKVDQ<);n1|gw4lOwJa^T8?qq`a3xmEztS>cT1j)&(5m>^hY>fcd7g)kso z79o)cW!+FQhXEn8$*~1eyB-zqfmam zQ~-rP2jYH12OT!(b<~aDyT+)&^mv*A_7bpH%`S}y5~{09sBY-G#sJ+C3gQ@dG0o = SERVER_LIST.split(","); +const pingInterval = Number(PING_INTERVAL); + +const pingServers = () => { + servers.forEach((server: string) => { + ping.promise + .probe(server) + .then((result) => { + const { alive } = result; + if (alive) { + const { time } = result; + defaultLogger.info( + `Received response from ${server} (Round-trip time: ${time} ms)` + ); + } else { + errorLogger.error(`No response from ${server}`); + } + }) + .catch((error) => { + errorLogger.error(`Error pinging ${server}: ${error}`); + }); + }); +}; + +setInterval(pingServers, pingInterval); diff --git a/ping/tsconfig.json b/ping/tsconfig.json new file mode 100644 index 0000000..1ad2744 --- /dev/null +++ b/ping/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + "baseUrl": "./src", + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + /* Linting */ + "skipLibCheck": true, + "strict": true, + "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/whatsapp-bot/.prettierrc b/whatsapp-bot/.prettierrc deleted file mode 100644 index b783b5c..0000000 --- a/whatsapp-bot/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "printWidth": 80, - "trailingComma": "all" -} diff --git a/whatsapp-bot/README.md b/whatsapp-bot/README.md deleted file mode 100644 index 4082fe9..0000000 --- a/whatsapp-bot/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# EchoFinder WhatsApp Bot - -This is the EchoFinder Telegram bot. It allows you to search for messages, and returns results based on similarity. - -## Setup - -### Dependencies - -To install dependencies: - -```bash -bun install -``` - -### Environment Variables - -```bash -BOT_CHAT_IDS= # comma separated, no spaces -DEBUG_MODE= -``` - -### Running - -To run: - -```bash -bun run start - -# or - -bun run dev -``` - -## Acknowledgements - -This project was created using `bun init` in bun v1.0.25. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/whatsapp-bot/bun.lockb b/whatsapp-bot/bun.lockb deleted file mode 100755 index 01cd06e9390386c1591adc524a49476d029bb45e..0000000000000000000000000000000000000000 G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4Ke&g_U^P*6!MkETe4?cZ0QutF$qQ{*(8l^m-2H>A+@JN}gA;NOVLys9<{MY5_W^hYC-Iy$9Rn`mUt%vPi28Br{4 z54Rz3Cx$4DcymKIvpR|+MXK4WI9R7ObJ*00wN!-tPLu3nUzU3zL6&O>Wbsua1&zvz z1g^6A7#<|SZZ^B^#TSjhOia21a@xj9pE)zw<(ADPcY%xKjJ$>7@SCL>z{A}p@EUM9 zY+@_i7>mz`u}_G}*fo3ChxpJtOi%+YcaSk*(raa#?rHIcEqYk(cwYgAMcW=QgOuT! z@kTJucmZ~$yc*R=(RPnTMDaDdc4+TlwbQ5ZsLWd+aaoQ7$m;s1~M_p zLSQBLEp^GDm7ckr>s@i$OTGQ8hTakU;Ot^LB=N#1`2E1v`s{&E;DvM28Pm8RtcpQLrIAsmz=S7;NORmDW2X$1RWjNprT|^!aI#15mL+_v3=0g z2e7@?;Xu#T;BkRWsp4&5BPJOirOJAKp$%L-K0r~LEeYK4q8vEj|IF@~YoZgSXU?vB z1Y&kSV-d;^hU@}17Rl&A`k)$Yq^A@GMeu{73 { - const metadata = this.getMessageMetadata(message); - this.logger.info(metadata); - } -} diff --git a/whatsapp-bot/src/components/logger.ts b/whatsapp-bot/src/components/logger.ts deleted file mode 100644 index 3b891f1..0000000 --- a/whatsapp-bot/src/components/logger.ts +++ /dev/null @@ -1,26 +0,0 @@ -import log4js from 'log4js'; - -export class Logger { - static configure( - logLevel: string = 'debug', - logFile: string = 'logs/combined.log', - errorFile: string = 'logs/error.log', - ) { - log4js.configure({ - appenders: { - console: { type: 'console' }, - file: { type: 'file', filename: logFile }, - error: { type: 'file', filename: errorFile }, - }, - categories: { - default: { appenders: ['console', 'file'], level: logLevel }, - error: { appenders: ['error', 'file'], level: 'error' }, - }, - }); - } - - static getLogger(category: string = 'default') { - Logger.configure(); - return log4js.getLogger(category); - } -} diff --git a/whatsapp-bot/src/components/whatsapp.ts b/whatsapp-bot/src/components/whatsapp.ts deleted file mode 100644 index 2eaaca1..0000000 --- a/whatsapp-bot/src/components/whatsapp.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { Client, type Message } from 'whatsapp-web.js'; -import { type Logger as Log4js } from 'log4js'; -import { Logger } from 'components/logger'; -import qrcode from 'qrcode-terminal'; -import puppeteer from 'puppeteer'; - -const { BOT_CHAT_IDS = '', DEBUG_MODE = 'TRUE' } = process.env; - -export type MessageMetadata = { - text: string; - chatId: string; - date: number; - messageId: string; - userId: string; - firstName: string; - lastName?: string; -}; - -export class WhatsApp { - protected client: Client; - protected logger: Log4js; - protected chatIds: Array; - - protected constructor() { - this.logger = Logger.getLogger('Whatsapp'); - this.client = new Client({}); - this.chatIds = `${BOT_CHAT_IDS}`.split(','); - } - - protected registerEvents() { - this.client.on('qr', (qr) => { - this.logger.info('received whatsapp qr code', qr); - qrcode.generate(qr, { small: true }); - }); - this.client.on('authenticated', (session) => { - this.logger.info('successfully authenticated session', session); - }); - this.client.on('auth_failure', (message) => { - this.logger.error('session authentication unsuccessful', message); - }); - this.client.on('ready', () => { - this.logger.info('whatsapp client is ready'); - }); - this.client.on('disconnected', (reason) => { - this.logger.info('whatsapp client was disconnected', reason); - }); - this.client.on('message', async (message) => { - await this.processMessage(message); - }); - } - - async initialize() { - await puppeteer.launch({ headless: true }); - this.registerEvents(); - await this.client.initialize(); - } - - protected getFullName(name: string): Record { - const [firstName, lastName] = name.split(' '); - return { - firstName, - lastName, - }; - } - - private validateChatId(chatId: string) { - if (DEBUG_MODE.toUpperCase() === 'TRUE') return true; - if (!chatId) { - this.logger.warn('Chat ID is required'); - return false; - } else if (typeof chatId !== 'string' && typeof chatId !== 'number') { - this.logger.warn('chatId must be a string or number'); - return false; - } else if (this.chatIds.includes(chatId)) { - this.logger.warn('Chat ID does not match bot configuration'); - return false; - } - return true; - } - - protected getMessageMetadata(message: Message): MessageMetadata { - const { from, body, timestamp, id, author, _data } = - message as Message & { _data: { notifyName: string } }; - const { _serialized: messageId } = id; - const { notifyName } = _data; - const { firstName, lastName } = this.getFullName(notifyName); - let metadata = { - text: body, - chatId: from, - date: timestamp, - messageId, - userId: author as string, - firstName: firstName as string, - lastName, - }; - return metadata; - } - - protected async processMessage( - message: Message, - ): Promise { - const { chatId } = this.getMessageMetadata(message); - if (!this.validateChatId(chatId)) return; - this.logger.info('Received whatsapp message', message); - } -} diff --git a/whatsapp-bot/src/constants/message.ts b/whatsapp-bot/src/constants/message.ts deleted file mode 100644 index c2092a6..0000000 --- a/whatsapp-bot/src/constants/message.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const MESSAGE = { - HELP: 'This is the EchoFinder Telegram bot. It allows you to search for messages, and returns results based on similarity.', -}; \ No newline at end of file diff --git a/whatsapp-bot/src/index.ts b/whatsapp-bot/src/index.ts deleted file mode 100644 index 4756339..0000000 --- a/whatsapp-bot/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Bot } from 'components/bot'; - -const bot = Bot.getInstance(); -await bot.initialize(); diff --git a/whatsapp-bot/tsconfig.json b/whatsapp-bot/tsconfig.json deleted file mode 100644 index 06489d5..0000000 --- a/whatsapp-bot/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - "baseUrl": "./src", - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - /* Linting */ - "skipLibCheck": true, - "strict": true, - "noFallthroughCasesInSwitch": true, - "forceConsistentCasingInFileNames": true - } -} From 7a7c3ded1538c661facc34fb41cb6e0edd50cca6 Mon Sep 17 00:00:00 2001 From: Banerjee Aditya Date: Wed, 7 Feb 2024 13:05:39 +0800 Subject: [PATCH 02/10] fix health service implementation --- {ping => health}/.gitignore | 0 {ping => health}/README.md | 21 +++++++++++++-- health/bun.lockb | Bin 0 -> 10253 bytes {ping => health}/package.json | 9 ++++--- {ping => health}/src/components/logger.ts | 2 +- health/src/index.ts | 25 ++++++++++++++++++ {ping => health}/tsconfig.json | 0 ping/bun.lockb | Bin 7714 -> 0 bytes ping/src/index.ts | 30 ---------------------- 9 files changed, 51 insertions(+), 36 deletions(-) rename {ping => health}/.gitignore (100%) rename {ping => health}/README.md (53%) create mode 100755 health/bun.lockb rename {ping => health}/package.json (58%) rename {ping => health}/src/components/logger.ts (87%) create mode 100644 health/src/index.ts rename {ping => health}/tsconfig.json (100%) delete mode 100755 ping/bun.lockb delete mode 100644 ping/src/index.ts diff --git a/ping/.gitignore b/health/.gitignore similarity index 100% rename from ping/.gitignore rename to health/.gitignore diff --git a/ping/README.md b/health/README.md similarity index 53% rename from ping/README.md rename to health/README.md index afde3a9..f6370e0 100644 --- a/ping/README.md +++ b/health/README.md @@ -1,4 +1,8 @@ -# ping +# Health Check + +## Setup + +### Dependencies To install dependencies: @@ -9,7 +13,20 @@ bun install To run: ```bash -bun run src/index.ts +bun run start + +# or + +bun run dev +``` + +### Environment Variables + +```bash +SERVER_LIST= +PING_INTERVAL= +LOG_FILE= +ERROR_LOG_FILE= ``` This project was created using `bun init` in bun v1.0.25. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/health/bun.lockb b/health/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..cacda747948c141333d036455ab4b944be245b2c GIT binary patch literal 10253 zcmeHNd0fof`=4q;aVyESB#jbX%uF*a%2pQ@LfN{ua$9C`J?V0eXP8&3PswOMQ6Ssla1 z@uQCJd9ifrzjD^x+PMDwOSg}9i~B<(5aX7F(cw>Nw6e@44H%)K-~fCm4hgWCD`haI zK)w@$5iOLm1>rJ@Po1(nR~izG230`0Bh>o~eB}rX0u0I+_~3Ji(BBWsLa~obCh%wY zgo{G3$ty5l59*&lssrf;Ee1mu(jZZgfbH+gSOR5zC{Jd#wDXZh1pCbs$tt0}0X&Dc zRQs9QE%?34^e0GBFRNXP-KZORKRVAbTN0Fh&F0*s_Af1sruC0Jx`LVi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g7J$ea{=h9QN8A6r|NjO;HVr2L literal 0 HcmV?d00001 diff --git a/ping/package.json b/health/package.json similarity index 58% rename from ping/package.json rename to health/package.json index 80185bb..ae2a929 100644 --- a/ping/package.json +++ b/health/package.json @@ -2,6 +2,10 @@ "name": "ping", "module": "src/index.ts", "type": "module", + "scripts": { + "start": "bun run src/index.ts", + "dev": "bun run --hot src/index.ts" + }, "devDependencies": { "@types/bun": "latest" }, @@ -9,8 +13,7 @@ "typescript": "^5.0.0" }, "dependencies": { - "@types/ping": "^0.4.4", - "log4js": "^6.9.1", - "ping": "^0.4.4" + "axios": "^1.6.7", + "log4js": "^6.9.1" } } \ No newline at end of file diff --git a/ping/src/components/logger.ts b/health/src/components/logger.ts similarity index 87% rename from ping/src/components/logger.ts rename to health/src/components/logger.ts index 3ee64f1..4099892 100644 --- a/ping/src/components/logger.ts +++ b/health/src/components/logger.ts @@ -13,7 +13,7 @@ log4js.configure({ }, categories: { default: { appenders: ["console", "file"], level: "info" }, - error: { appenders: ["error", "file"], level: "error" }, + error: { appenders: ["console", "error", "file"], level: "error" }, }, }); diff --git a/health/src/index.ts b/health/src/index.ts new file mode 100644 index 0000000..2b0876c --- /dev/null +++ b/health/src/index.ts @@ -0,0 +1,25 @@ +import axios, { AxiosError } from "axios"; +import { logger } from "components/logger"; + +const { SERVER_LIST = "", PING_INTERVAL = "300000" } = process.env; +const { defaultLogger, errorLogger } = logger; +const servers: Array = SERVER_LIST.split(","); +const pingInterval = Number(PING_INTERVAL); + +const pingServers = async () => { + const promises = servers.map(async (server: string) => { + defaultLogger.info(`Checking server health ${server}`); + try { + await axios.get(server); + } catch (error) { + if((error as AxiosError).response?.status) { + defaultLogger.info(`Server at ${server} is healthy.`); + } else { + errorLogger.error(`Server at ${server} is down.`); + } + } + }); + await Promise.all(promises); +}; + +setInterval(pingServers, pingInterval); diff --git a/ping/tsconfig.json b/health/tsconfig.json similarity index 100% rename from ping/tsconfig.json rename to health/tsconfig.json diff --git a/ping/bun.lockb b/ping/bun.lockb deleted file mode 100755 index 3ad4946825b11c700aaf400c0ca2600e1f84c5b7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7714 zcmeHMd011&77rL)5WynWtq5wN6iEUhSX2a_6``VnR8Ul~2nhs2z}y54xZq2 zf~X*FD9Yl3)`D6=3RWMeMMc@H+A7wiMXieQopZ_H{ra^K``-Ir|8V#&XXeiQe&@`& zXXeg588eEfpk%y7Vku83jWS)Nkm|z4kwgTBiNq2iM-(9o50G=BtaY_nES6EpNfXie zcCWCM;dgHxocL%@&9L5&!&{3i9Yz(W&ryAwW(iQY=<7+|y&RVnq~3xKu6+FxKj9hf)zzG|Uj%{h>cdxJZEn;ef#s2N&L#iGl*L zEs_Mt<-#D^BD}8)_uz{4=*4371G!Z#(?MeYV0Nb-#NxP@E(=Gm4Bvi%NWnL=`ut*H zX15nlBwVVzT#OZRUdkS(oB!dVg5vZoR5K z=3el*B*V7Rd1p5%w}oC1r}E~lGe10Oe7^{XGk0fY9p7daYc)1OxCq?v9~FG6SWMuu zhWTP0TtHt~@2L>H2MiPdzBfqlD@#+m2tEri&VYxU2;{cCX}q9@ihnKkCMPPLo3L*8o2O@VGH!>6gcc3fJfbE`R3U~)K9!#NQ0E9*bbrF4}j`K&J0cuI+gA$+7J8)q^iETq{ zK+#0v_(5>t+y}#j?RV932uLhMVx8E;tp9!NQyHjm0{`Wr#p>i`QnP>DHNC&v3%9X) z)}=FZ-R!RVOkUxn3VKko>}Fm_ZR!D$Z(;5ilE#deZpZFSQp&#^kT~jkYQgx0p%K*& zEi&^T=7Wudm&6^K&91L8A8@^_$Rez;xw-WdDxp4cnIMX4&oU4l_4q12MLK2%H>Sh* zZr0MX0Y5zaxXN;#qEFDe(X4{$y;CwxEi&=lL3lA{NMTznm}h(V;&aPKWesUgUT3(y ze8S^m!nh%)wzR!E8*_hK{9!ZJayL%Kk*4Mmp@;4ydM%vxIPUz_Ghbg`Ubn&i!B`+7 zyv+TCT{FxxR)1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E8}ZDzf(%Ouul?*}ZK>t=0*)UwTdc>WMR!2G4Bw`ewzB z`B#n^?R}Wrp)btea=7V2s)3&3>YT+3v`T_L=PPsSKA2C4-pc=r2go~*$iHF)^Zf8v z@NY41J@D28|630v;YTBsY_-&Npk#quv6PYrNF-d6O61O#35AZPd}~um94(9xS(yq< z10>>LX@p397*f6JEXalLfp67(M);8hMb|-L%Xb9WpAg_)f!_sqhQ~bz-%)rz#wSM!V(14=rFrPopPhk&E9M|Ooo8LJR$H8|r$qx?H^0(t! zbFDiqz#fue?5ho_Q6VMo^aa=%OLCCfTK?8t0aw6ck!&oWlIDfHNIZE-$$DgzJ4l1wa( zvEkai&H=xX1?oIA$>#!_J=X^HkW4el=t7SGY=a(>izYc=x`*~P$ySrBF!X>2{)ml@ zY&Kj-U6Bkn$rNjA@u7ncvn07{k`va}0xB*aFeGbDvcuY1EBK%YJVf%^B!3J&_FOxz zjrAX3EI|hrlKUn(X295i8hAjF>If|AibUoLr-b2ALK)X(saz(g1q`tOuJvT@G?(q>u`fi6iCCbd?9cZm4S*!Xa{bBsGD@lL>>x zlw79dN+ZKVDQ<);n1|gw4lOwJa^T8?qq`a3xmEztS>cT1j)&(5m>^hY>fcd7g)kso z79o)cW!+FQhXEn8$*~1eyB-zqfmam zQ~-rP2jYH12OT!(b<~aDyT+)&^mv*A_7bpH%`S}y5~{09sBY-G#sJ+C3gQ@dG0o = SERVER_LIST.split(","); -const pingInterval = Number(PING_INTERVAL); - -const pingServers = () => { - servers.forEach((server: string) => { - ping.promise - .probe(server) - .then((result) => { - const { alive } = result; - if (alive) { - const { time } = result; - defaultLogger.info( - `Received response from ${server} (Round-trip time: ${time} ms)` - ); - } else { - errorLogger.error(`No response from ${server}`); - } - }) - .catch((error) => { - errorLogger.error(`Error pinging ${server}: ${error}`); - }); - }); -}; - -setInterval(pingServers, pingInterval); From 09ab1a3784eaef17df7d9ff2626f691f694ff0c0 Mon Sep 17 00:00:00 2001 From: Banerjee Aditya Date: Wed, 7 Feb 2024 13:06:21 +0800 Subject: [PATCH 03/10] add health service dockerfile --- health/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 health/Dockerfile diff --git a/health/Dockerfile b/health/Dockerfile new file mode 100644 index 0000000..f626150 --- /dev/null +++ b/health/Dockerfile @@ -0,0 +1,14 @@ +FROM oven/bun + +WORKDIR /app + +COPY package.json . +COPY bun.lockb . + +RUN bun install + +COPY . . + +EXPOSE 3000 + +CMD ["bun", "run", "start"] \ No newline at end of file From c05dd043ddb4576248bc56259b620750c7b3969c Mon Sep 17 00:00:00 2001 From: Banerjee Aditya Date: Wed, 7 Feb 2024 13:07:15 +0800 Subject: [PATCH 04/10] add docker commands for health service --- health/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/health/package.json b/health/package.json index ae2a929..1645a84 100644 --- a/health/package.json +++ b/health/package.json @@ -4,7 +4,10 @@ "type": "module", "scripts": { "start": "bun run src/index.ts", - "dev": "bun run --hot src/index.ts" + "dev": "bun run --hot src/index.ts", + "build": "docker build -t echofinder-health:latest .", + "local": "docker run --env-file .env echofinder-health:latest", + "prod": "docker run echofinder-health:latest" }, "devDependencies": { "@types/bun": "latest" From e559fa4d289a5d0dfcf5c32c2ea15c35a1e9fc87 Mon Sep 17 00:00:00 2001 From: Banerjee Aditya Date: Wed, 7 Feb 2024 14:09:04 +0800 Subject: [PATCH 05/10] update health check service --- health/src/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/health/src/index.ts b/health/src/index.ts index 2b0876c..612afbc 100644 --- a/health/src/index.ts +++ b/health/src/index.ts @@ -12,7 +12,7 @@ const pingServers = async () => { try { await axios.get(server); } catch (error) { - if((error as AxiosError).response?.status) { + if ((error as AxiosError).response?.status) { defaultLogger.info(`Server at ${server} is healthy.`); } else { errorLogger.error(`Server at ${server} is down.`); @@ -22,4 +22,10 @@ const pingServers = async () => { await Promise.all(promises); }; -setInterval(pingServers, pingInterval); +defaultLogger.info( + `Starting health check for servers ${servers.join(", ")}...` +); +setTimeout( + () => pingServers().then(() => setInterval(pingServers, pingInterval)), + 3000 +); From 58ced4005d4e4df6a5f02c3b5a33aa87c6a298b7 Mon Sep 17 00:00:00 2001 From: Banerjee Aditya Date: Wed, 7 Feb 2024 17:33:41 +0800 Subject: [PATCH 06/10] update telebot message search flow --- telegram-bot/bun.lockb | Bin 85051 -> 89300 bytes telegram-bot/package.json | 1 + telegram-bot/src/components/bot.ts | 36 +++++++++++++------------- telegram-bot/src/constants/message.ts | 3 ++- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/telegram-bot/bun.lockb b/telegram-bot/bun.lockb index 0d6d77de0b192b6dcf3c86790d4acd0227cb3d7c..e415ae25d4a016be2303f903b96c6b7ba11a54dd 100755 GIT binary patch delta 13932 zcmeHOd0dsn*MA0hkVip4RJ>eNKygDZ%LOi1ga`L6R7^|DCDg0nhTMw_ngXe5?!Hsr zv~o{PQ(XF~|Eq=x8SfMZJ4dw$>6Y|cw8v(#VCi)0=wH@%cu!{=m%P{mG<<6;$~q;L`+x(TVVYOnbO3tzY^e zO};Vo5x*lw_Y-o3ybv_h0HXj5vUCL$RR>-VDVmuNrc(`gF)(%fNE=`dXdlpdz+~7c ztz85rgBL=$3h*+>gOxW0v_Ei`hWk)^E*Py)2>_0TWu$1oW@$M1WLOPgGC%?*gEAc9 zcH2PP=*N&FdEK=aK$GEfFbm?}1f~fc1)n^*4VVns01PMQO#;rP4kJ*ZnY;;119SwY z4i=aTr{vWDO&wf-N&XBxL^C-6O!5V=k`!+TO*5VjYy{2*rU@Lu@(|twOyi6gk)bSE zoKdK!3@{SYr-3R3sxIyYOa^oUCdH+^oonqL^`Vo7s|ifzP{@Y&?<-UUO_7t~aAezU zX+xhw8}+^oOuZeB^x=asbb}yul-j^>WuC2HzwkkhzQg?ZZdZTy9zWq)-ej+D z&kmXv^9poPpZ&mO!_7LX?lecvuzrIxvQKcUTW!N`O=q!ZRGg z6q8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b^#7^-0IY=EYeDE&9f>; z^IF0X-3{1HOT{7rR=Y6lLfci*)fy2dGDX0;FARRwTm74hn8v6y!nSW*>ajSLs@V!pKtzZ+VQhl^ah?X^yYi(W#vI_sDv${Irw zZ!OU=F3NhEoNj$WP7QU5Pj9atYAer2ba=6KztyL(t_-g;7Gyy)uvHn;?DGm+^T9KhbvckWU8F}4L9Jh%3lv_ zx#31U55f3;gsl6UB0asWD#otX+6>}z-@Cfk{LnXa=bvs+iB%6Rd##gA5rqZTYt2M2 ztE3qs=f0NJW&ZE)4S%(+3d*>*^O;O(<%tL@qB%05D##0NTyv2ZaNkh6cX*STy%((* z%Y>-XQQyq?B-i7ekB-&sj2^_E3{|+X)~C(kq~BT=ExcCC2>2bax<|mDLDsfb=ow~x z0%ASKo-x+j5ty~Wx)6b$Vykrva0{)J7$~%ehQea&7cJ1U(z4jI)+*v1C}7=1+m~91 zc%SD+vFf8lrZqVdX5O(DMj{IC>tqwgJiTzk7mwifoQ4Ne z=%RkqcFX9c{kxZKTZ(&rz;WwXOIWqtw%SKwi`Y)v9xlWI!MVjct8*(5wZnYw`(^Xb zew{ zt;9HZG~LRHgY7L=AvtGf9<-{+9k(`v_}rJ#-uN{C{rmO}_IX4%B!QQ$=X2j;d$rHJ zm$QbaHo2;>+v?cn#~cN5*26dveC}&*^N&q=_kmXb?BJX!D13XSfcxItQ#&4;`{cC0 zhOW-!z8Pl}^?vKhBft2EU`>TH3e{$Kvhd#NXvdh1s?{jU{lNNTj>(5c@!{hxo9|Erh#POjYqo=N)rZzH$d zGI{ZgH>`Z0FykM`kLVQNn;rOznA76Y>n-ewpSsC<#V1BukBt(oUrKK)7UjN_I8MAM F{slhB!6*O# diff --git a/telegram-bot/package.json b/telegram-bot/package.json index e836c83..c8be7d6 100644 --- a/telegram-bot/package.json +++ b/telegram-bot/package.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@types/bun": "latest", + "@types/express": "^4.17.21", "@types/node-telegram-bot-api": "^0.64.2", "prettier": "^3.2.5" }, diff --git a/telegram-bot/src/components/bot.ts b/telegram-bot/src/components/bot.ts index fd6c6bc..0cd23a0 100644 --- a/telegram-bot/src/components/bot.ts +++ b/telegram-bot/src/components/bot.ts @@ -105,15 +105,17 @@ export class Bot { chatId: string, message: string, message_id?: string, - ): Promise { + ): Promise { this.logger.info(`Sending message to chat ${chatId}`, { message }); + let result; if (message_id) { - this.client.sendMessage(chatId, message, { + result = this.client.sendMessage(chatId, message, { reply_to_message_id: Number(message_id), }); } else { - this.client.sendMessage(chatId, message); + result = this.client.sendMessage(chatId, message); } + return result; } async saveMessage(message: Message): Promise { @@ -132,27 +134,25 @@ export class Bot { async search(message: Message): Promise { const regex = new RegExp(/\/search/); - const { chat_id, message_content, message_id } = - this.getMessageMetadata(message); + const { + chat_id: chatId, + message_content: messageContent, + message_id: messageId, + } = this.getMessageMetadata(message); try { - const query = message_content.replace(regex, '').trim(); + const query = messageContent.replace(regex, '').trim(); const response = await this.apiClient.get('/messages/search', { search_string: query, - chat_id, + chatId, }); const data = response; - const { documents } = data; - const results = documents - .map((doc: string, i: number) => { - const index = i + 1; - return `${index}. ${doc}`; - }) - .join('\n'); - if (!results || results.length === 0) { - await this.sendMessage(chat_id, MESSAGE.NO_RESULTS, message_id); - return; + const { ids: foundMessageIds } = data; + const foundMessageId = foundMessageIds?.shift(); + if (foundMessageId) { + await this.sendMessage(chatId, MESSAGE.FOUND, foundMessageId); + } else { + await this.sendMessage(chatId, MESSAGE.NO_RESULTS, messageId); } - this.sendMessage(chat_id, results, message_id); } catch (error) { this.logger.error(error); } diff --git a/telegram-bot/src/constants/message.ts b/telegram-bot/src/constants/message.ts index 62599f0..b2032bd 100644 --- a/telegram-bot/src/constants/message.ts +++ b/telegram-bot/src/constants/message.ts @@ -2,5 +2,6 @@ export const MESSAGE = { HELP: 'This is the EchoFinder Telegram bot. It allows you to search for messages, and returns results based on similarity. Usage: /search ', PROMPT: 'Search usage: /search ', NO_RESULTS: 'No results found. Try a different search string.', - PROCESSING_UPDATE: 'Processing update' + PROCESSING_UPDATE: 'Processing update', + FOUND: 'We found this message that we think matches your search!', }; From d623fa859f4e53758b7cb5ce0395050ef464e707 Mon Sep 17 00:00:00 2001 From: Aditya Banerjee Date: Wed, 7 Feb 2024 19:44:04 +0800 Subject: [PATCH 07/10] add suggestions flow --- telegram-bot/src/components/bot.ts | 78 ++++++++++++++++++++------- telegram-bot/src/constants/error.ts | 1 + telegram-bot/src/constants/message.ts | 3 +- 3 files changed, 63 insertions(+), 19 deletions(-) diff --git a/telegram-bot/src/components/bot.ts b/telegram-bot/src/components/bot.ts index 0cd23a0..0ac08a9 100644 --- a/telegram-bot/src/components/bot.ts +++ b/telegram-bot/src/components/bot.ts @@ -1,5 +1,9 @@ import { type Logger as Log4js } from 'log4js'; -import Client, { type Message } from 'node-telegram-bot-api'; +import Client, { + type InlineKeyboardButton, + type Message, + type SendMessageOptions, +} from 'node-telegram-bot-api'; import { Logger } from 'components/logger'; import { MESSAGE } from 'constants/message'; import { ERROR } from 'constants/error'; @@ -51,6 +55,23 @@ export class Bot { this.client.on('message', (message: Message) => { this.saveMessage(message); }); + this.client.on('callback_query', (query) => { + const { data: stringifiedData, message } = query; + const { chat } = message!; + const { id: chatId } = chat; + const data = JSON.parse(stringifiedData ?? '{}'); + const { type, id: suggestionId } = data; + switch (type) { + case 'see_suggestion': + this.sendMessage(chatId, MESSAGE.CLOSE_MATCH, { + reply_to_message_id: suggestionId, + }); + break; + default: + this.logger.error(ERROR.INVALID_CALLBACK_QUERY); + return; + } + }); this.logger.info('Bot initialised successfully'); } @@ -87,12 +108,16 @@ export class Bot { async help(message: Message) { const { chat_id, message_id } = this.getMessageMetadata(message); - await this.sendMessage(chat_id, MESSAGE.HELP, message_id); + await this.sendMessage(chat_id, MESSAGE.HELP, { + reply_to_message_id: message_id, + }); } async prompt(message: Message) { const { chat_id, message_id } = this.getMessageMetadata(message); - await this.sendMessage(chat_id, MESSAGE.PROMPT, message_id); + await this.sendMessage(chat_id, MESSAGE.PROMPT, { + reply_to_message_id: message_id, + }); } validateMesssage(message: Message): boolean { @@ -102,20 +127,15 @@ export class Bot { } async sendMessage( - chatId: string, + chatId: string | number, message: string, - message_id?: string, + options?: Partial, ): Promise { - this.logger.info(`Sending message to chat ${chatId}`, { message }); - let result; - if (message_id) { - result = this.client.sendMessage(chatId, message, { - reply_to_message_id: Number(message_id), - }); - } else { - result = this.client.sendMessage(chatId, message); - } - return result; + this.logger.info(`Sending message to chat ${chatId}`, { + message, + options, + }); + return this.client.sendMessage(chatId, message, options); } async saveMessage(message: Message): Promise { @@ -132,6 +152,19 @@ export class Bot { } } + getInlineKeyboard(messageIds: number[]): Array { + return messageIds.map((id: number, i: number) => { + const index = i + 1; + return { + text: `${index}`, + callback_data: JSON.stringify({ + type: 'see_suggestion', + id, + }), + }; + }); + } + async search(message: Message): Promise { const regex = new RegExp(/\/search/); const { @@ -143,15 +176,24 @@ export class Bot { const query = messageContent.replace(regex, '').trim(); const response = await this.apiClient.get('/messages/search', { search_string: query, - chatId, + chat_id: chatId, }); const data = response; const { ids: foundMessageIds } = data; const foundMessageId = foundMessageIds?.shift(); if (foundMessageId) { - await this.sendMessage(chatId, MESSAGE.FOUND, foundMessageId); + const inlineKeyboardMarkup = + this.getInlineKeyboard(foundMessageIds); + await this.sendMessage(chatId, MESSAGE.FOUND, { + reply_to_message_id: foundMessageId, + reply_markup: { + inline_keyboard: [inlineKeyboardMarkup], + }, + }); } else { - await this.sendMessage(chatId, MESSAGE.NO_RESULTS, messageId); + await this.sendMessage(chatId, MESSAGE.NO_RESULTS, { + reply_to_message_id: messageId, + }); } } catch (error) { this.logger.error(error); diff --git a/telegram-bot/src/constants/error.ts b/telegram-bot/src/constants/error.ts index 43a9371..234a644 100644 --- a/telegram-bot/src/constants/error.ts +++ b/telegram-bot/src/constants/error.ts @@ -1,3 +1,4 @@ export const ERROR = { NO_FROM: 'No from field in message', + INVALID_CALLBACK_QUERY: 'Invalid callback query', }; diff --git a/telegram-bot/src/constants/message.ts b/telegram-bot/src/constants/message.ts index b2032bd..6737aa8 100644 --- a/telegram-bot/src/constants/message.ts +++ b/telegram-bot/src/constants/message.ts @@ -3,5 +3,6 @@ export const MESSAGE = { PROMPT: 'Search usage: /search ', NO_RESULTS: 'No results found. Try a different search string.', PROCESSING_UPDATE: 'Processing update', - FOUND: 'We found this message that we think matches your search!', + FOUND: 'We found this message that we think matches your search! If it was\'nt the message you were looking for, the buttons below correspond to the next 4 closest matches.', + CLOSE_MATCH: 'This message was also a close match to your query.' }; From 2402437c5d6574f4021a1c661358d41c9f72e514 Mon Sep 17 00:00:00 2001 From: Aditya Banerjee Date: Wed, 7 Feb 2024 19:45:58 +0800 Subject: [PATCH 08/10] fix typo in message constants --- telegram-bot/src/components/bot.ts | 4 ++-- telegram-bot/src/constants/message.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/telegram-bot/src/components/bot.ts b/telegram-bot/src/components/bot.ts index 0ac08a9..b5c6c7e 100644 --- a/telegram-bot/src/components/bot.ts +++ b/telegram-bot/src/components/bot.ts @@ -180,10 +180,10 @@ export class Bot { }); const data = response; const { ids: foundMessageIds } = data; - const foundMessageId = foundMessageIds?.shift(); + const foundMessageId = foundMessageIds[0]?.shift(); if (foundMessageId) { const inlineKeyboardMarkup = - this.getInlineKeyboard(foundMessageIds); + this.getInlineKeyboard(foundMessageIds[0]); await this.sendMessage(chatId, MESSAGE.FOUND, { reply_to_message_id: foundMessageId, reply_markup: { diff --git a/telegram-bot/src/constants/message.ts b/telegram-bot/src/constants/message.ts index 6737aa8..9d4fcde 100644 --- a/telegram-bot/src/constants/message.ts +++ b/telegram-bot/src/constants/message.ts @@ -3,6 +3,6 @@ export const MESSAGE = { PROMPT: 'Search usage: /search ', NO_RESULTS: 'No results found. Try a different search string.', PROCESSING_UPDATE: 'Processing update', - FOUND: 'We found this message that we think matches your search! If it was\'nt the message you were looking for, the buttons below correspond to the next 4 closest matches.', + FOUND: 'We found this message that we think matches your search! If it wasn\'t the message you were looking for, the buttons below correspond to the next 4 closest matches.', CLOSE_MATCH: 'This message was also a close match to your query.' }; From 6e7dccb6543d422a660dde1f41c596ba1ad77f9c Mon Sep 17 00:00:00 2001 From: Aditya Banerjee Date: Wed, 7 Feb 2024 19:47:55 +0800 Subject: [PATCH 09/10] update bun.lockb for health service --- health/bun.lockb | Bin 10253 -> 10253 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/health/bun.lockb b/health/bun.lockb index cacda747948c141333d036455ab4b944be245b2c..b1cfff532c52c85052642d0e4fcc1384e96d622a 100755 GIT binary patch delta 20 bcmeAT=ndFlE6dIpXQ*eUXTI4*_9PboLm~zY delta 20 YcmeAT=ndFlE6dKr00x^~WKVJd05@O+wEzGB From 46f1463310cb4e666c54cba688e2fcb361311735 Mon Sep 17 00:00:00 2001 From: Vishesh Arora <> Date: Wed, 7 Feb 2024 22:59:49 +0800 Subject: [PATCH 10/10] Flatten IDs --- backend/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/main.py b/backend/main.py index d57596a..aa868bc 100644 --- a/backend/main.py +++ b/backend/main.py @@ -78,6 +78,7 @@ async def search_messages(search_string: str = Query(..., min_length=1), chat_id n_results=5 ) + results["ids"] = results["ids"][0] results["documents"] = results["documents"][0] return results