Telegram bot #150

Merged
Sirherobrine23 merged 14 commits from Telegram_bot into main 2021-08-11 02:47:35 +00:00
13 changed files with 61 additions and 121 deletions
Showing only changes of commit 8aa68ce5c1 - Show all commits

View File

@ -31,11 +31,6 @@ const bot = new Telegraf(bds.telegram_token);
bot.start((ctx)=>ctx.reply(HelpAndStart.join("\n")));
bot.help((ctx)=>ctx.reply(HelpAndStart.join("\n")));
const ChatIDs = {}
function SaveID(id = "a"){return ChatIDs[id] = true}
function RemoveID(id = "a"){return delete ChatIDs[id]}
function GetID(){return ChatIDs}
// Basic server
bot.command("basic", ctx => {
const text = ctx.message.text.replace("/basic", "").trim();
@ -78,7 +73,7 @@ bot.command("platform", ctx => {
ctx.reply("We were unable to change the platform")
return ctx.reply(err.toString())
}
})
});
// Send Info
bot.command("info", ctx => {
@ -100,7 +95,7 @@ bot.command("info", ctx => {
` max_players: ${config.players}`,
` whitelist: ${config.whitelist}`,
]
return ctx.reply(InfoRes.join("\n"))
return ctx.reply(InfoRes.join("\n"));
});
// Log
@ -118,30 +113,28 @@ bot.command("log", ctx => {
// Live Log User
global.LiveLog = [];
bot.command("live_log", ctx => {
const option = ctx.message.text.replace("/platform", "").trim();
const option = ctx.message.text.replace("/live_log", "").trim();
if (/enable/.test(option)) {
global.LiveLog.push(ctx);
ctx.reply("Sucess");
return ctx.reply("Sucess");
} else if (/disable/.test(option)) {
// ctx.from.id
for (let ctx_Logs in global.LiveLog) {
if (global.LiveLog[ctx_Logs].from.id === ctx.from.id) {
delete global.LiveLog[ctx_Logs];
global.LiveLog = global.LiveLog.filter(a=>a);
ctx.reply("Ok");
}
}
} else ctx.reply("Invalid option")
ctx.reply(ctx.chat.id)
})
for (let ctx_Logs in global.LiveLog) {
if (global.LiveLog[ctx_Logs].from.id === ctx.from.id) {
delete global.LiveLog[ctx_Logs];
global.LiveLog = global.LiveLog.filter(a=>a);
return ctx.reply("Ok");
}
}
return ctx.reply("You are not in the list");
} else return ctx.reply("Invalid option");
});
// text
bot.on("message", ctx => {
global.ServerExec.command(ctx.message.text);
});
bot.on("message", ctx => global.ServerExec.command(`say ${ctx.message.text}`));
// catch
bot.catch(console.log);
// End And Lauch
bot.launch()
bot.launch();

88
package-lock.json generated
View File

@ -14,7 +14,6 @@
"adm-zip": "^0.5.1",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"create-desktop-shortcuts": "^1.4.0",
"cron": "^1.8.2",
"express": "^4.17.1",
"express-fileupload": "^1.2.1",
@ -25,7 +24,6 @@
"minimist": "^1.2.5",
"node-cron": "^3.0.0",
"node-fetch": "^2.6.1",
"node-localstorage": "^2.1.6",
"oci-sdk": "^2.0.0",
"open": "^8.0.0",
"properties-to-json": "^0.2.1",
@ -1430,14 +1428,6 @@
"node": ">= 0.10"
}
},
"node_modules/create-desktop-shortcuts": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/create-desktop-shortcuts/-/create-desktop-shortcuts-1.5.0.tgz",
"integrity": "sha512-XYRHuBKCfZHbHYHnltfX3HrxIMPWEGNaark+QQmAxeiqAlfMEViTEcJsi+MVMDJy5QXRkXM6bUh9xIWtONoCEw==",
"dependencies": {
"which": "^2.0.2"
}
},
"node_modules/cron": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
@ -2994,7 +2984,8 @@
"node_modules/graceful-fs": {
"version": "4.2.6",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ=="
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==",
"dev": true
},
"node_modules/gtoken": {
"version": "5.3.0",
@ -3218,6 +3209,7 @@
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
"dev": true,
"engines": {
"node": ">=0.8.19"
}
@ -3462,7 +3454,8 @@
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
},
"node_modules/isomorphic-fetch": {
"version": "3.0.0",
@ -4178,17 +4171,6 @@
"node": ">= 6.0.0"
}
},
"node_modules/node-localstorage": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-2.2.1.tgz",
"integrity": "sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==",
"dependencies": {
"write-file-atomic": "^1.1.4"
},
"engines": {
"node": ">=0.12"
}
},
"node_modules/nodemon": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.12.tgz",
@ -6221,14 +6203,6 @@
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
}
},
"node_modules/slide": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=",
"engines": {
"node": "*"
}
},
"node_modules/sort-keys": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
@ -6941,6 +6915,7 @@
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"dependencies": {
"isexe": "^2.0.0"
},
@ -6978,16 +6953,6 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"node_modules/write-file-atomic": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
"integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
"dependencies": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
"slide": "^1.1.5"
}
},
"node_modules/xdg-basedir": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz",
@ -8133,14 +8098,6 @@
"vary": "^1"
}
},
"create-desktop-shortcuts": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/create-desktop-shortcuts/-/create-desktop-shortcuts-1.5.0.tgz",
"integrity": "sha512-XYRHuBKCfZHbHYHnltfX3HrxIMPWEGNaark+QQmAxeiqAlfMEViTEcJsi+MVMDJy5QXRkXM6bUh9xIWtONoCEw==",
"requires": {
"which": "^2.0.2"
}
},
"cron": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
@ -9381,7 +9338,8 @@
"graceful-fs": {
"version": "4.2.6",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ=="
"integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==",
"dev": true
},
"gtoken": {
"version": "5.3.0",
@ -9533,7 +9491,8 @@
"imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o="
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
"dev": true
},
"inflight": {
"version": "1.0.6",
@ -9712,7 +9671,8 @@
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
},
"isomorphic-fetch": {
"version": "3.0.0",
@ -10282,14 +10242,6 @@
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",
"integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA=="
},
"node-localstorage": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-2.2.1.tgz",
"integrity": "sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==",
"requires": {
"write-file-atomic": "^1.1.4"
}
},
"nodemon": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.12.tgz",
@ -12017,11 +11969,6 @@
"is-fullwidth-code-point": "^3.0.0"
}
},
"slide": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc="
},
"sort-keys": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
@ -12576,6 +12523,7 @@
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
@ -12601,16 +12549,6 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"write-file-atomic": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
"integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
"requires": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
"slide": "^1.1.5"
}
},
"xdg-basedir": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz",

View File

@ -14,7 +14,7 @@
"ci": "node .Build/test/ci.js",
"eslint": "eslint --debug .",
"eslint:debug": "eslint --debug .",
"eslint:fix": "eslint --fix .",
"eslint:fix": "eslint --debug --fix .",
"nexe": "node .Build/nexe_build.js",
"Docker": "node .Build/DockerImage.js",
"dev:telegram": "node bin/telegram_bot.js -e js"
@ -59,7 +59,6 @@
"adm-zip": "^0.5.1",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"create-desktop-shortcuts": "^1.4.0",
"cron": "^1.8.2",
"express": "^4.17.1",
"express-fileupload": "^1.2.1",
@ -70,7 +69,6 @@
"minimist": "^1.2.5",
"node-cron": "^3.0.0",
"node-fetch": "^2.6.1",
"node-localstorage": "^2.1.6",
"oci-sdk": "^2.0.0",
"open": "^8.0.0",
"properties-to-json": "^0.2.1",