tangoxfm-discord-kit 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -0
- package/src/db.js +14 -0
- package/src/events.js +5 -0
- package/src/index.js +11 -0
- package/src/parser.js +89 -0
- package/src/premium.js +49 -0
- package/src/utils.js +20 -0
- package/src/webhooks.js +22 -0
package/package.json
ADDED
package/src/db.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// db.js
|
|
2
|
+
// Placeholder PostgreSQL wrapper. Safe, no errors.
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
async connect() {
|
|
6
|
+
console.log("[DB] connect() not implemented yet");
|
|
7
|
+
return null;
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
async query(sql, params = []) {
|
|
11
|
+
console.log("[DB] query() not implemented yet", sql, params);
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
package/src/events.js
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// index.js
|
|
2
|
+
// Exports all core modules so bot + watcher can import them cleanly.
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
parser: require("./parser"),
|
|
6
|
+
db: require("./db"),
|
|
7
|
+
premium: require("./premium"),
|
|
8
|
+
webhooks: require("./webhooks"),
|
|
9
|
+
events: require("./events"),
|
|
10
|
+
utils: require("./utils")
|
|
11
|
+
};
|
package/src/parser.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// packages/core/src/parser.js
|
|
2
|
+
|
|
3
|
+
function parseLine(line) {
|
|
4
|
+
if (!line || typeof line !== "string") {
|
|
5
|
+
return { type: "unknown", raw: line };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const lower = line.toLowerCase();
|
|
9
|
+
|
|
10
|
+
if (lower.includes("joined")) {
|
|
11
|
+
return {
|
|
12
|
+
type: "player_join",
|
|
13
|
+
player: extractPlayerName(line),
|
|
14
|
+
raw: line
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (lower.includes("left")) {
|
|
19
|
+
return {
|
|
20
|
+
type: "player_leave",
|
|
21
|
+
player: extractPlayerName(line),
|
|
22
|
+
raw: line
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (lower.includes("kit") && lower.includes("created")) {
|
|
27
|
+
return {
|
|
28
|
+
type: "kit_created",
|
|
29
|
+
kit: extractKitName(line),
|
|
30
|
+
raw: line
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (lower.includes("bind") && lower.includes("added")) {
|
|
35
|
+
return {
|
|
36
|
+
type: "bind_added",
|
|
37
|
+
bind: extractBind(line),
|
|
38
|
+
raw: line
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (lower.includes("explosion") || lower.includes("c4") || lower.includes("rocket")) {
|
|
43
|
+
return {
|
|
44
|
+
type: "raid_event",
|
|
45
|
+
raw: line
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (lower.includes("world") && lower.includes("wipe")) {
|
|
50
|
+
return {
|
|
51
|
+
type: "wipe",
|
|
52
|
+
raw: line
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (lower.includes("admin") && lower.includes("executed")) {
|
|
57
|
+
return {
|
|
58
|
+
type: "admin_command",
|
|
59
|
+
command: extractAdminCommand(line),
|
|
60
|
+
raw: line
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { type: "unknown", raw: line };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function extractPlayerName(line) {
|
|
68
|
+
const match = line.match(/(\w+)\s+(joined|left)/i);
|
|
69
|
+
return match ? match[1] : "Unknown";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function extractKitName(line) {
|
|
73
|
+
const match = line.match(/kit\s+(\w+)/i);
|
|
74
|
+
return match ? match[1] : "UnknownKit";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function extractBind(line) {
|
|
78
|
+
const match = line.match(/bind\s+(.+)/i);
|
|
79
|
+
return match ? match[1].trim() : "UnknownBind";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function extractAdminCommand(line) {
|
|
83
|
+
const match = line.match(/executed\s+(.+)/i);
|
|
84
|
+
return match ? match[1].trim() : "UnknownCommand";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
parseLine
|
|
89
|
+
};
|
package/src/premium.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// premium.js
|
|
2
|
+
// Simple premium system with boolean + free limits.
|
|
3
|
+
|
|
4
|
+
const FREE_LIMITS = {
|
|
5
|
+
binds: 10
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const premiumStatus = new Map();
|
|
9
|
+
// premiumStatus.set(serverId, true);
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
|
|
13
|
+
setPremium(serverId, value) {
|
|
14
|
+
premiumStatus.set(serverId, value);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
isPremium(serverId) {
|
|
18
|
+
return premiumStatus.get(serverId) === true;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
requirePremium(serverId, featureName) {
|
|
22
|
+
if (!this.isPremium(serverId)) {
|
|
23
|
+
return {
|
|
24
|
+
allowed: false,
|
|
25
|
+
message: `❌ This feature requires **Premium**.\nUpgrade here: https://yourwebsite.com/premium`
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return { allowed: true };
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
checkLimit(serverId, featureName, currentCount) {
|
|
33
|
+
if (this.isPremium(serverId)) {
|
|
34
|
+
return { allowed: true };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const limit = FREE_LIMITS[featureName];
|
|
38
|
+
if (!limit) return { allowed: true };
|
|
39
|
+
|
|
40
|
+
if (currentCount >= limit) {
|
|
41
|
+
return {
|
|
42
|
+
allowed: false,
|
|
43
|
+
message: `❌ Free limit reached for **${featureName}**.\nYou can only use **${limit}** on the free plan.\nUpgrade here: https://yourwebsite.com/premium`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { allowed: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// utils.js
|
|
2
|
+
// Small helpers shared across bot + watcher.
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
log(...args) {
|
|
6
|
+
console.log("[Core]", ...args);
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
safeJSON(str) {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(str);
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
delay(ms) {
|
|
18
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
19
|
+
}
|
|
20
|
+
};
|
package/src/webhooks.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// webhooks.js
|
|
2
|
+
// Simple Discord webhook + channel sender helpers.
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
async sendWebhook(url, payload) {
|
|
6
|
+
console.log("[Webhook] sendWebhook() not implemented yet", url, payload);
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
async sendDiscordMessage(client, channelId, content) {
|
|
10
|
+
try {
|
|
11
|
+
const channel = await client.channels.fetch(channelId);
|
|
12
|
+
if (!channel) {
|
|
13
|
+
console.log("[Webhook] Channel not found:", channelId);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await channel.send(content);
|
|
18
|
+
} catch (err) {
|
|
19
|
+
console.error("[Webhook] Error sending message:", err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|