-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
25 lines (21 loc) · 788 Bytes
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { Telegraf } from 'telegraf'
import album from './lib/album.js'
import 'dotenv/config'
const bot = new Telegraf(process.env.BOT)
const channelID = process.env.CHAT
const args = process.argv.splice(2)
let url = args[0]
album(url)
.then(async (bgmAlbum) => {
console.info(`${bgmAlbum.bgms.length} music are fetched`)
await bot.telegram.sendPhoto(channelID, bgmAlbum.poster, {'caption': bgmAlbum.title})
bgmAlbum.bgms.forEach(async (bgm) => {
console.info(`Sending ${bgm.bgmName} to Telegram Group...`)
await bot.telegram.sendAudio(
channelID,
bgm.bgmSource,
{'caption': bgm.bgmName}
)
console.info(`${bgm.bgmName} to Telegram Group...`)
})
})