|
|
@@ -9,29 +9,30 @@ const langData=fs.readFileSync('./string/lang.json', 'utf8');
|
|
|
const language = JSON.parse(langData);
|
|
|
var lang = language.en;
|
|
|
|
|
|
+
|
|
|
bot.start( (ctx) => {
|
|
|
console.log('started:', ctx.from.id)
|
|
|
return ctx.reply(lang.welcome)
|
|
|
})
|
|
|
|
|
|
+
|
|
|
bot.command('spanish', (ctx) => {
|
|
|
lang = language.es;
|
|
|
ctx.reply(lang.langChanged)
|
|
|
})
|
|
|
|
|
|
+
|
|
|
bot.command('english', (ctx) => {
|
|
|
lang = language.en;
|
|
|
ctx.reply(lang.langChanged)
|
|
|
})
|
|
|
|
|
|
-bot.command('help', (ctx) => ctx.reply(lang.help))
|
|
|
|
|
|
+bot.command('donate', (ctx) => ctx.reply(lang.donate))
|
|
|
|
|
|
-//bot.hears('hi', (ctx) => ctx.reply('Hey there!'))
|
|
|
|
|
|
-//bot.hears(/buy/i, (ctx) => ctx.reply('Buy-buy!'))
|
|
|
+bot.command('help', (ctx) => ctx.reply(lang.help))
|
|
|
|
|
|
-//bot.on('sticker', (ctx) => ctx.reply('👍'))
|
|
|
|
|
|
bot.on('audio', (ctx) => {
|
|
|
console.log('message received: ', ctx.from.id)
|
|
|
@@ -46,8 +47,12 @@ bot.on('audio', (ctx) => {
|
|
|
filename = filename.replace(new RegExp("\\" + specialChars[i], 'gi'), '')
|
|
|
}
|
|
|
filename = filename + ".mp3"
|
|
|
- const downloadDir = "/var/music/bot/"
|
|
|
- var file = fs.createWriteStream(downloadDir+filename);
|
|
|
+ const downloadDir = "/var/music/bot/" + audio.performer + "/";
|
|
|
+
|
|
|
+ if (!fs.existsSync(downloadDir)){
|
|
|
+ fs.mkdirSync(downloadDir);
|
|
|
+ }
|
|
|
+ const file = fs.createWriteStream(downloadDir+filename);
|
|
|
|
|
|
const promise = telegram.getFile(audio.file_id)
|
|
|
promise.then(function(result){
|