allah
This commit is contained in:
parent
3cae10d39b
commit
05acc96b2e
169
server/index.js
169
server/index.js
@ -1,24 +1,45 @@
|
|||||||
const express = require('express'),
|
const express = require("express"),
|
||||||
sqlite3 = require('sqlite3'),
|
sqlite3 = require("sqlite3"),
|
||||||
bodyParser = require('body-parser'),
|
bodyParser = require("body-parser"),
|
||||||
|
mc = require("minecraft-server-util"),
|
||||||
|
Discord = require("discord-webhook-node"),
|
||||||
|
geoIP = require("geoip-lite"),
|
||||||
|
fs = require("fs"),
|
||||||
|
config = require("./config.json"),
|
||||||
app = express(),
|
app = express(),
|
||||||
mc = require('minecraft-server-util'),
|
db = new sqlite3.Database("./servers.db");
|
||||||
discord = require('discord-webhook-node'),
|
|
||||||
geoip = require('geoip-lite'),
|
const createWebhook = url => new Discord.Webhook(url).setUsername("TaxenHeimer").setAvatar("https://cdn.discordapp.com/attachments/999167321631363126/999495738943868928/nn.png")
|
||||||
fs = require('fs'),
|
const countrify = e => require("./contrycode.json")[e]
|
||||||
config = require('./config.json')
|
const replaceMOTD = e => e.replace(/'/g, "\\'").replace(/-/g, '\\-')
|
||||||
var webhook = new discord.Webhook(config.main)
|
const makeEmbed = (mc, neit) => {
|
||||||
.setUsername("TaxenHeimer")
|
var Embed = new Discord.MessageBuilder()
|
||||||
.setAvatar("https://cdn.discordapp.com/attachments/999167321631363126/999495738943868928/nn.png")
|
.setTitle("TaxenHeimer")
|
||||||
var webhookfronce = new discord.Webhook(config.fronce)
|
.setColor("#00ff00")
|
||||||
.setAvatar("https://cdn.discordapp.com/attachments/999167321631363126/999495738943868928/nn.png")
|
.addField("**Host**", `\`${mc.Server}\``, true)
|
||||||
.setUsername("TaxenHeimer")
|
.addField("**Country**", `\`${countrify(mc.ip.country)}\``)
|
||||||
var neithook = new discord.Webhook(config.neit)
|
.addField("**Version**", `\`${mc.version.name} (${mc.version.protocol})\``, true)
|
||||||
.setAvatar("https://cdn.discordapp.com/attachments/999167321631363126/999495738943868928/nn.png")
|
.addField("**Players**", `\`${mc.players.online}/${mc.players.max}\``, true)
|
||||||
.setUsername("TaxenHeimer")
|
.addField("**Ping**", `\`${mc.roundTripLatency}ms\``, true)
|
||||||
app.use(bodyParser.json())
|
.addField("**Motd**", "```\n" + mc.motd.clean + "\n```")
|
||||||
app.use(bodyParser.urlencoded({extended: true}))
|
.addField("**Playerlist Sample**", "```\n" + mc.PlayerList + "\n```")
|
||||||
db = new sqlite3.Database('./servers.db')
|
.addField("**IP Range**", "```\n" + geoIP.pretty(mc.ip.range[0]) + " - " + geoIP.pretty(mc.ip.range[1]) + "```")
|
||||||
|
.setTimestamp()
|
||||||
|
|
||||||
|
if (neit) Embed.setText("<@390491795655622657>")
|
||||||
|
console.log(Embed)
|
||||||
|
return Embed
|
||||||
|
}
|
||||||
|
var webhooks = [
|
||||||
|
createWebhook(config.main),
|
||||||
|
createWebhook(config.fronce),
|
||||||
|
createWebhook(config.neit)
|
||||||
|
]
|
||||||
|
|
||||||
|
app.use(bodyParser.json()).use(bodyParser.urlencoded({
|
||||||
|
extended: true
|
||||||
|
}))
|
||||||
|
|
||||||
db.exec(`CREATE TABLE IF NOT EXISTS servers (
|
db.exec(`CREATE TABLE IF NOT EXISTS servers (
|
||||||
host text not null,
|
host text not null,
|
||||||
version text not null,
|
version text not null,
|
||||||
@ -28,87 +49,47 @@ db.exec(`CREATE TABLE IF NOT EXISTS servers (
|
|||||||
motd text not null,
|
motd text not null,
|
||||||
timestamp text not null
|
timestamp text not null
|
||||||
)`)
|
)`)
|
||||||
function countrify(code) {
|
|
||||||
var config = require('./countrycode.json')
|
app.post("/server", async (req, res) => {
|
||||||
return config[code]
|
var Server = req.body.server
|
||||||
}
|
if (!Server) return res.send("specify a server")
|
||||||
app.post('/server', async(req, res) => {
|
|
||||||
var server = req.body.server
|
|
||||||
if (!server) return res.send("specify a server")
|
|
||||||
var ipfile = fs.readFileSync(`${__dirname}/ip.txt`, 'utf8')
|
|
||||||
if (ipfile.includes(server)) return;
|
|
||||||
res.send("allah")
|
res.send("allah")
|
||||||
mc.status(server, 25565, {enableSRV: true}).then(res => {
|
if (fs.readFileSync(`${__dirname}/ip.txt`).toString().includes(Server)) return
|
||||||
var playerlist = ""
|
var Minecraft = await mc.status(Server, 25565, {
|
||||||
if (res.players.sample != null) {
|
enableSRV: true
|
||||||
res.players.sample.forEach(e => playerlist += `${e.name}::${e.id}\n`)
|
})
|
||||||
} else {
|
Minecraft.ip = geoIP.lookup(Server)
|
||||||
playerlist += "No players"
|
Minecraft.Server = `${Server}:25565`
|
||||||
}
|
var cleanMOTD = replaceMOTD(Minecraft.motd.clean)
|
||||||
var ip = geoip.lookup(server)
|
Minecraft.PlayerList = ""
|
||||||
if (res.motd.clean.includes("'")) var cleanmotd = res.motd.clean.replace(/'/g, "\\'")
|
Minecraft.players.sample ? Minecraft.players.sample.forEach(e => Minecraft.PlayerList += `${e.name}::${e.id}\n`) : Minecraft.PlayerList = "No Players"
|
||||||
else cleanmotd = res.motd.clean
|
|
||||||
if (res.motd.clean.includes('-')) var cleanmotd = res.motd.clean.replace(/-/g, '\\-')
|
|
||||||
else cleanmotd = res.motd.clean
|
|
||||||
db.exec(`INSERT INTO servers VALUES (
|
db.exec(`INSERT INTO servers VALUES (
|
||||||
'${server}:25565',
|
'${Minecraft.Server}',
|
||||||
'${res.version.name}',
|
'${Minecraft.version.name}',
|
||||||
'${res.players.online}/${res.players.max}',
|
'${Minecraft.players.online}/${Minecraft.players.max}',
|
||||||
'${playerlist}',
|
'${Minecraft.PlayerList}',
|
||||||
'${res.roundTripLatency}ms',
|
'${Minecraft.roundTripLatency}ms',
|
||||||
'${cleanmotd}',
|
'${cleanMOTD}',
|
||||||
'${(new Date()).toLocaleDateString('en-US')}'
|
'${new Date().toLocaleDateString('en-US')}'
|
||||||
)`)
|
)`)
|
||||||
if (ip.country === "FR") {
|
switch (Minecraft.ip.country) {
|
||||||
const embed = new discord.MessageBuilder()
|
default: break;
|
||||||
.setTitle("TaxenHeimer")
|
case "FR":
|
||||||
.setColor("#00ff00")
|
webhooks[1].send(makeEmbed(Minecraft))
|
||||||
.addField("**Host**", `\`${server}:25565\``, true)
|
break
|
||||||
.addField("**Country**", `\`${countrify(ip.country)}\``)
|
|
||||||
.addField("**Version**", `\`${res.version.name} (${res.version.protocol})\``, true)
|
|
||||||
.addField("**Players**", `\`${res.players.online}/${res.players.max}\``, true)
|
|
||||||
.addField("**Ping**", `\`${res.roundTripLatency}ms\``, true)
|
|
||||||
.addField("**Motd**", "```\n"+res.motd.clean+"\n```")
|
|
||||||
.addField("**Playerlist Sample**", "```\n"+playerlist+"\n```")
|
|
||||||
.addField("**IP Range**", "```\n" + geoip.pretty(ip.range[0]) + " - " + geoip.pretty(ip.range[1]) + "```")
|
|
||||||
.setTimestamp()
|
|
||||||
webhookfronce.send(embed)
|
|
||||||
}
|
}
|
||||||
if (res.version.name.includes("1.17")) {
|
switch(true) {
|
||||||
const embed = new discord.MessageBuilder()
|
case Minecraft.version.name.includes("1.17"):
|
||||||
.setText("<@390491795655622657>")
|
webhooks[2].send(makeEmbed(Minecraft, "neit"))
|
||||||
.setTitle("TaxenHeimer")
|
break;
|
||||||
.setColor("#00ff00")
|
default:
|
||||||
.addField("**Host**", `\`${server}:25565\``, true)
|
webhooks[0].send(makeEmbed(Minecraft))
|
||||||
.addField("**Country**", `\`${countrify(ip.country)}\``)
|
break
|
||||||
.addField("**Version**", `\`${res.version.name} (${res.version.protocol})\``, true)
|
|
||||||
.addField("**Players**", `\`${res.players.online}/${res.players.max}\``, true)
|
|
||||||
.addField("**Ping**", `\`${res.roundTripLatency}ms\``, true)
|
|
||||||
.addField("**Motd**", "```\n"+res.motd.clean+"\n```")
|
|
||||||
.addField("**Playerlist Sample**", "```\n"+playerlist+"\n```")
|
|
||||||
.addField("**IP Range**", "```\n" + geoip.pretty(ip.range[0]) + " - " + geoip.pretty(ip.range[1]) + "```")
|
|
||||||
.setTimestamp()
|
|
||||||
neithook.send(embed)
|
|
||||||
}
|
}
|
||||||
const embed = new discord.MessageBuilder()
|
|
||||||
.setTitle("TaxenHeimer")
|
|
||||||
.setColor("#00ff00")
|
|
||||||
.addField("**Host**", `\`${server}:25565\``, true)
|
|
||||||
.addField("**Country**", `\`${countrify(ip.country)}\``)
|
|
||||||
.addField("**Version**", `\`${res.version.name} (${res.version.protocol})\``, true)
|
|
||||||
.addField("**Players**", `\`${res.players.online}/${res.players.max}\``, true)
|
|
||||||
.addField("**Ping**", `\`${res.roundTripLatency}ms\``, true)
|
|
||||||
.addField("**Motd**", "```\n"+res.motd.clean+"\n```")
|
|
||||||
.addField("**Playerlist Sample**", "```\n"+playerlist+"\n```")
|
|
||||||
.addField("**IP Range**", "```\n" + geoip.pretty(ip.range[0]) + " - " + geoip.pretty(ip.range[1]) + "```")
|
|
||||||
.setTimestamp()
|
|
||||||
webhook.send(embed)
|
|
||||||
fs.appendFileSync(`${server}\n`)
|
|
||||||
}).catch(e => {})
|
|
||||||
})
|
})
|
||||||
app.listen(9000, () => {
|
app.listen(9000, () => {
|
||||||
console.clear()
|
console.clear()
|
||||||
console.log("server ready")
|
console.log("server ready")
|
||||||
})
|
})
|
||||||
process.on("unhandledRejection", callback => {})
|
//process.on("unhandledRejection", callback => console.log(callback))
|
||||||
process.on("uncaughtException", callback => {})
|
//process.on("uncaughtException", callback => console.log(callback))
|
Loading…
Reference in New Issue
Block a user