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 993 additions and 982 deletions
Showing only changes of commit 573accb6c5 - Show all commits

View File

@ -45,11 +45,9 @@ bot.command("basic", ctx => {
try { try {
const Server = bds.start(); const Server = bds.start();
Server.log(function (data){ Server.log(function (data){
Object.getOwnPropertyNames(GetID()).forEach(Id => { for (let stx of global.LiveLog) stx.reply(data);
console.log(Id); });
if (ChatIDs[Id]) bot.telegram.sendMessage(Id, data) global.ServerExec = Server;
})
})
return ctx.reply("Server Started") return ctx.reply("Server Started")
} catch (err) { } catch (err) {
console.log(err) console.log(err)
@ -137,9 +135,13 @@ bot.command("live_log", ctx => {
ctx.reply(ctx.chat.id) ctx.reply(ctx.chat.id)
}) })
// text
bot.on("message", ctx => {
global.ServerExec.command(ctx.message.text);
});
// catch // catch
bot.catch(console.log); bot.catch(console.log);
// End And Lauch // End And Lauch
process.on("exit", bot.stop)
bot.launch() bot.launch()

View File

@ -2,7 +2,7 @@
const { resolve } = require("path"); const { resolve } = require("path");
const path = require("path") const path = require("path")
const fs = require("fs"); const fs = require("fs");
const { randomUUID } = require("crypto"); const randomUUID = require("uuid").v4;
function date(format) { function date(format) {
const today = new Date(), const today = new Date(),

3
package-lock.json generated
View File

@ -30,7 +30,8 @@
"open": "^8.0.0", "open": "^8.0.0",
"properties-to-json": "^0.2.1", "properties-to-json": "^0.2.1",
"request-ip": "^2.1.3", "request-ip": "^2.1.3",
"telegraf": "^4.0.0" "telegraf": "^4.0.0",
"uuid": "^8.3.2"
}, },
"bin": { "bin": {
"bds_maneger": "bin/bds_maneger.js" "bds_maneger": "bin/bds_maneger.js"

View File

@ -75,7 +75,8 @@
"open": "^8.0.0", "open": "^8.0.0",
"properties-to-json": "^0.2.1", "properties-to-json": "^0.2.1",
"request-ip": "^2.1.3", "request-ip": "^2.1.3",
"telegraf": "^4.0.0" "telegraf": "^4.0.0",
"uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^7.19.0", "eslint": "^7.19.0",

View File

@ -2,7 +2,7 @@ const child_process = require("child_process");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const { resolve, join } = require("path"); const { resolve, join } = require("path");
const { randomUUID } = require("crypto"); const randomUUID = require("uuid").v4;
const { CronJob } = require("cron"); const { CronJob } = require("cron");
const { GetCronBackup } = require("../lib/BdsSettings"); const { GetCronBackup } = require("../lib/BdsSettings");
const { Backup } = require("./backups"); const { Backup } = require("./backups");