Commit e2ec4a50 authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent a7c831c1
...@@ -11,8 +11,6 @@ const TelegramBot = require('node-telegram-bot-api'); ...@@ -11,8 +11,6 @@ const TelegramBot = require('node-telegram-bot-api');
const token = process.env.DEBUG === 'true' ? process.env.LOCAL_TOKEN : process.env.SERVER_TOKEN; const token = process.env.DEBUG === 'true' ? process.env.LOCAL_TOKEN : process.env.SERVER_TOKEN;
cron.schedule('*/15 * * * *', () => { cron.schedule('*/15 * * * *', () => {
runCron() runCron()
...@@ -20,13 +18,9 @@ cron.schedule('*/15 * * * *', () => { ...@@ -20,13 +18,9 @@ cron.schedule('*/15 * * * *', () => {
}); });
const bot = new TelegramBot(token, {polling: true}); const bot = new TelegramBot(token, {polling: true});
runCron()
bot.on('message', (msg) => { bot.on('message', (msg) => {
console.log(msg) console.log(msg)
processMessage(msg) processMessage(msg)
...@@ -373,8 +367,8 @@ async function generateText(current, num, msg) { ...@@ -373,8 +367,8 @@ async function generateText(current, num, msg) {
async function runCron() { async function runCron() {
let admins=await db.getAllAdmins()
let name = './back/'+'backup-' + moment().format('YYYY-MM-DD---HH-mm')+'.sql' let name = './back/' + 'backup-' + moment().format('YYYY-MM-DD---HH-mm') + '.sql'
const result = await mysqldump({ const result = await mysqldump({
connection: { connection: {
host: '195.201.22.255', host: '195.201.22.255',
...@@ -383,11 +377,7 @@ async function runCron() { ...@@ -383,11 +377,7 @@ async function runCron() {
database: 'accounting', database: 'accounting',
}, dumpToFile: name, }, dumpToFile: name,
}); });
for (let i=0;i<admins.length;i++) bot.sendDocument('-1001392333493', name)
{
bot.sendDocument(admins[i].teleid, name)
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment