forked from MyZubster-Ecosystem/myzubster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
97 lines (82 loc) · 2.46 KB
/
Copy pathbot.js
File metadata and controls
97 lines (82 loc) · 2.46 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const PaymentNotifier = require('./paymentNotifier');
const history = require('./history');
const notifier = new PaymentNotifier();
// Carica la storia nel notifier
history.completed.forEach(p => {
notifier.recordPayment(
p.issue,
p.bounty,
p.contributor,
p.txid,
p.address
);
});
history.pending.forEach(p => {
notifier.registerWallet(
p.contributor,
p.address,
p.issue,
p.bounty
);
});
// Comandi del bot
const commands = {
'/register': (args) => {
const [address, issueId, bounty] = args;
if (!address || !issueId || !bounty) {
return '❌ Uso: /register <address> <issueId> <bounty>';
}
const wallet = notifier.registerWallet('contributor', address, issueId, bounty);
return `✅ Wallet registrato per issue #${issueId}!\nAddress: \`${address}\`\nBounty: ${bounty} XMR`;
},
'/pay': (args) => {
const [issueId, bounty, contributor, txid, address] = args;
if (!issueId || !bounty || !contributor || !txid || !address) {
return '❌ Uso: /pay <issueId> <bounty> <contributor> <txid> <address>';
}
const payment = notifier.recordPayment(issueId, bounty, contributor, txid, address);
return `✅ Pagamento registrato per issue #${issueId}!\nTXID: \`${txid}\``;
},
'/status': () => {
return notifier.generateReport();
},
'/history': () => {
let msg = '📊 **Storico Pagamenti MyZubster**\n\n';
msg += '✅ **Pagamenti Completati:**\n';
history.completed.forEach(p => {
msg += `- #${p.issue}: ${p.bounty} XMR → ${p.contributor} (${p.date})\n`;
});
msg += '\n⏳ **In Attesa:**\n';
history.pending.forEach(p => {
msg += `- #${p.issue}: ${p.bounty} XMR → ${p.contributor}\n`;
});
msg += '\n🔄 **In Review:**\n';
history.review.forEach(p => {
msg += `- #${p.issue}: ${p.bounty} XMR → ${p.contributor}\n`;
});
return msg;
},
'/confirm': (args) => {
const [txid] = args;
if (!txid) return '❌ Uso: /confirm <txid>';
notifier.confirmPayment(txid);
return `✅ Pagamento confermato: \`${txid}\``;
}
};
function processCommand(text) {
const [cmd, ...args] = text.split(' ');
if (commands[cmd]) {
return commands[cmd](args);
}
return `❌ Comando non riconosciuto.
Comandi disponibili:
/register <address> <issueId> <bounty>
/pay <issueId> <bounty> <contributor> <txid> <address>
/status
/history
/confirm <txid>`;
}
module.exports = {
processCommand,
notifier
};