-
Notifications
You must be signed in to change notification settings - Fork 0
/
responseToTwit.js
71 lines (67 loc) · 3.18 KB
/
responseToTwit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const config = require("./config.js");
const sendTwitWithMedia = require("./twitWithMedia");
const formatNumber = require("./formatNumber");
module.exports.sendTwit = function sendTwit(tweet, status, extradata) {
return new Promise(async (resolve, reject) => {
// Who sent the tweet?
let name = tweet.user.screen_name;
// If we want the conversation thread
let id = tweet.id_str;
// Start a reply back to the sender
let replyText = "";
switch (status) {
case "success":
let satoshiDigit = (extradata.amountandfee.sat / 100000000).toFixed(8);
let satoshiDigitString = satoshiDigit.toString();
replyText = `@${name} ✅ PAID ${formatNumber(extradata.amountandfee.sat)} Satoshi / ${satoshiDigitString.replace("0.0", ".0")} #BTC with ❤️ & ⚡ in ${extradata.time / 1000} secs. Fees: ${
extradata.amountandfee.fee
} Sat/s. To donate ${extradata.amountandfee.sat}+ Sats use command:\n\n!donate ${extradata.amountandfee.sat}\n\nFollow us @${config.twitteraccount}`;
break;
case "paidbasic":
replyText = `@${name} ✅ PAID with ❤️ & ⚡\n\nFollow us @${config.twitteraccount}`;
break;
case "invalidinvoice":
replyText = `⚠️ @${name} We have already PAID you ${config.defaultPayOut} Satoshi or your QR is invalid.\n\nFollow us @${config.twitteraccount}`;
break;
case "tryagain":
replyText = `@${name} Please try again and only send QR Code screenshot.`;
break;
case "invalidqr":
replyText = `@${name} ${extradata.err}`;
break;
case "alreadypaid":
replyText = `⚠️ We've already tipped or paid @${name}. You can try tipping again in 24 hours if it's unclaimed.\n\nTo donate ${config.defaultPayOut}+ Satoshi use command:\n\n!donate ${config.defaultPayOut}\n\nFollow us @${config.twitteraccount}`;
break;
case "alreadypaidout":
replyText = `⚠️ We've already tipped or paid @${name}. To donate ${config.maxTipAmount}+ Satoshi use command:\n\n!donate ${config.maxTipAmount}\n\nFollow us @${config.twitteraccount}`;
break;
case "followrequired":
replyText = `@${name} please follow us and then resend QR Code.`;
break;
case "alreadytip":
replyText = `⚠️ @${name} We have already tipped or paid this pleb.\n\nFollow us @${config.twitteraccount}`;
break;
case "error":
replyText = `⚠️ @${name} Please regenerate your lightning network QR Code and try again.\n\nFollow us @${config.twitteraccount}`;
break;
default:
replyText = "@" + name + " Failed, please try again later";
}
// Post that tweetreplyText, qrPath, id, media, postQR
try {
let twitOut = await sendTwitWithMedia.twitWithMedia(replyText, false, id, false);
//console.log(twitOut)
resolve(twitOut);
} catch (err) {
console.log("Failed to twit from Power Of satoshi, trying again: ", err);
try {
let twitOut = await sendTwitWithMedia.twitWithMedia(replyText, false, id, false);
//console.log(twitOut)
resolve(twitOut);
} catch (err) {
//console.log(err)
reject(err);
}
}
});
};