forked from cyclic-software/starter-micro-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (21 loc) · 788 Bytes
/
index.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
26
27
28
29
30
require('dotenv').config()
const { Telegraf } = require('telegraf')
const { getPrayerTimes } = require('./utils')
const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN || '');
bot.start((ctx) => ctx.reply('Assalamualaikum, Welcome to Prayer Time Bot'));
bot.help((ctx) => ctx.reply('Send me a sticker'));
bot.hears('hi', (ctx) => ctx.reply('Hey there'));
bot.command('hariini', async (ctx) => {
const waktu = await getPrayerTimes("today", "SGR03")
let str = ''
waktu.prayerTime.map((time) => {
Object.entries(time).forEach(([key, value]) => {
str = str.concat(`${key}: ${value}\n`)
})
})
ctx.reply(str)
});
console.log('--------running')
bot.launch();
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));