-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateTwitterBio.js
38 lines (32 loc) · 1.1 KB
/
updateTwitterBio.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
const axios = require("axios");
const sendTwitWithMedia = require("./twitWithMedia");
const supabase = require("./supabase");
const umbril = require("./umbril");
async function updateTwitterBio() {
let getJWTToken = await umbril.getJWTToken();
let getLNBalance = await getLNDBalance(getJWTToken);
let countUsers = await supabase.countUsers();
let addTotalSats = await supabase.addTotalSats("satAmount");
let addTotalFees = await supabase.addTotalFees("fee");
// Update BIO tweet
sendTwitWithMedia.updateBio(getLNBalance, addTotalSats, addTotalFees, countUsers);
}
function getLNDBalance(JWTToken) {
return new Promise((resolve, reject) => {
axios
.get(`http://umbrel.local/api/v1/lnd/channel`, {
headers: {
Authorization: `JWT ${JWTToken}`,
},
})
.then((res) => {
let totalBalance = 0;
for (let i = 0; i < res.data.length; i++) {
totalBalance += Number(res.data[i].localBalance);
}
resolve(totalBalance);
})
.catch((error) => reject(error.response.data));
});
}
module.exports = updateTwitterBio;