Skip to content

Commit

Permalink
Merge pull request cyclic-software#1 from nordinz7/develop
Browse files Browse the repository at this point in the history
fix: removed express and minor changes
  • Loading branch information
nordinz7 authored Apr 28, 2023
2 parents 58e21d9 + f34ca1f commit 3cdf66a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 403 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# telegram-bot-prayer-time
# Telegram-bot-prayer-time

## Fetch daily prayer times from https://www.e-solat.gov.my/

### Telegram Info:
- Name: WaktuSolatMalaysia
- username: @WaktuSolatMalaysiaBot

## Available commands
## send "/hariini" without quotes, you will get today prayer time.
17 changes: 4 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require('dotenv').config()
const app = require('express')()
const { Telegraf } = require('telegraf')
const { getPrayerTimes } = require('./utils')

Expand All @@ -13,7 +12,7 @@ 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", "JHR03")
const waktu = await getPrayerTimes("today", "SGR03")
let str = ''
waktu.prayerTime.map((time) => {
Object.entries(time).forEach(([key, value]) => {
Expand All @@ -23,17 +22,9 @@ bot.command('hariini', async (ctx) => {
ctx.reply(str)
});

console.log('--------running')

bot.launch();

process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));

app.get('/prayerTime', async (req, res) => {
const { period, zone } = req.query
const prayerTime = await getPrayerTimes(period, zone)
res.json(prayerTime)
})

app.listen(process.env.PORT || 3000, () => {
console.log('--------server is ruuning on port', 3000)
})
process.once('SIGTERM', () => bot.stop('SIGTERM'));
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
"dependencies": {
"axios": "^1.3.6",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"nodemon": "^2.0.22",
"telegraf": "^4.12.2"
},
"scripts": {
"dev": "nodemon index"
}
}
}
Loading

0 comments on commit 3cdf66a

Please sign in to comment.