From d18b06483a4b62b2d871d8c3cbbc5be4dec042fc Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 13 Jul 2023 01:03:36 -0700 Subject: text to speech notification --- lib/payments.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/payments.js') diff --git a/lib/payments.js b/lib/payments.js index e1e0590e..2d322a15 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -7,6 +7,8 @@ import { db, g, s, t } from "$lib/db"; import { l, err, warn } from "$lib/logging"; import { fail } from "$lib/utils"; import { callWebhook } from "$lib/webhooks"; +import dollarsToWords from "dollars-to-words"; +import got from "got"; export const types = { internal: "internal", @@ -122,7 +124,6 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { let equivalentRate = invoice.rate * (store.rates[currency] / store.rates[invoice.currency]); - if (Math.abs(invoice.rate / store.rates[invoice.currency] - 1) < 0.01) { rate = equivalentRate; } else { @@ -171,6 +172,19 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { emit(uid, "payment", p); notify(user, `Received ${amount} sats`); callWebhook(invoice, p); + if (user.username === "bob") { + let words = dollarsToWords( + parseFloat(((amount * p.rate) / 100000000).toFixed(2)) + ); + + try { + let r = await got + .post("http://172.42.0.1:4020/tts", { json: { words, name: p.id } }) + .json(); + } catch (e) { + console.log(e); + } + } return p; }; -- cgit v1.2.3