Skip to content

Commit

Permalink
Added fun phrases for zap receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
blackcoffeexbt committed Oct 31, 2023
1 parent 439a8bd commit 910717a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nostrZapLamp/nostrZapLamp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,23 @@ uint16_t getRandomNum(uint16_t min, uint16_t max) {
*/
void zapReceiptEvent(const std::string& key, const char* payload) {
if(lastPayload != payload) { // Prevent duplicate events from multiple relays triggering the same logic, as we are using multiple relays, this is likely to happen
// define an array of phrases to use when a zap is a received
String zapPhrases[] = {
"Zap!",
"A zap happened! ",
"The zappenning!",
"Zap! Zap!",
"Pew pew!",
"Zap! Zap! Zap!"
};

lastPayload = payload;
String bolt11 = getBolt11InvoiceFromEvent(payload);
// Serial.println("BOLT11: " + bolt11);
uint64_t amountInSatoshis = getAmountInSatoshis(bolt11);
Serial.println("Zapped! " + String(amountInSatoshis));
// Choose a random phrase from the array
int randomPhraseIndex = getRandomNum(0, sizeof(zapPhrases) / sizeof(zapPhrases[0]) - 1);
Serial.println(zapPhrases[randomPhraseIndex] + " " + String(amountInSatoshis) + " sats");
flashLightning(amountInSatoshis);
}
}
Expand Down

0 comments on commit 910717a

Please sign in to comment.