https://github.com/escalopa/gopray
A Telegram Bot to get muslim prayer's time in Kazan Russia, And subscribe to get notified on upcoming prayers, Built with golang
https://github.com/escalopa/gopray
muslim-prayer-times redis subscriptions telegram-bot
Last synced: 2 months ago
JSON representation
A Telegram Bot to get muslim prayer's time in Kazan Russia, And subscribe to get notified on upcoming prayers, Built with golang
- Host: GitHub
- URL: https://github.com/escalopa/gopray
- Owner: escalopa
- License: other
- Created: 2023-01-04T11:58:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T21:49:28.000Z (6 months ago)
- Last Synced: 2025-01-19T15:20:05.327Z (4 months ago)
- Topics: muslim-prayer-times, redis, subscriptions, telegram-bot
- Language: Go
- Homepage: https://t.me/kz_prayers_bot
- Size: 374 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gopray 🙏
A Telegram Bot to get muslim prayers time, And subscribe to get notified on the prayers time

[](https://wakatime.com/badge/user/965e81db-2a88-4564-b236-537c4a901130/project/5b8bc34a-26b1-4a61-be8d-f9b854b1e43a)
[](https://goreportcard.com/report/github.com/escalopa/gopray)
[](https://codecov.io/gh/escalopa/gopray)## Contributing 🤼
Before we start talking about the bot, I would really appreciate if you can contribute to this project by adding more features or fixing bugs. It is totally open source and free to use. 😁
## Usecase 🛠️
```mermaid
graph LR
A[User] --> |Get Prayers Time| B((Bot))
A[User] --> |Subscribe To Bot| B((Bot))
A[User] --> |Change Bot Language| B((Bot))
B((Bot)) --> |Notify Users about prayers| B((Bot))
A[User] --> |Send Feedback Messages\nOr Bug Reports| B((Bot))
B((Bot)) --> |Store Prayers Time| D[[Run Time Memory]]
B((Bot)) --> |Store User ID For Subscriptions| C[[Database]]
```## Subscription Feature 📢
This feature allows the bot to notify users `20 min` before the prayers time. (Time is set by the `UPCOMING_REMINDER` env variable)
Users can subscribe to the bot by sending `/subscribe` command to the bot. And unsubscribe by sending `/unsubscribe` command to the bot.
Also on friday the bot will remind the user to pray Gomaa prayer. at `7:00 PM` (Time is set by the `GOMOAA_REMINDER_HOUR` env variable), This is value to when to remind them, The prayer time is calculated based on the prayers time of the day and sent to the user.
### How it works 🤔
In order to implement this feature, We have to make to bot wait until `20 min` are left before the prayer's time. And then send a notification to the subscribed users.
Also, when the time of the prayer's arrive we should also notify them.
So for that I use simple `channels` to sleep the goroutine until the time is right to send the notification.
The first sleep is until the `20 min` before the prayer's time. And the second is until the prayer's time.
for more details check the [notifier code](./telegram/internal/adapters/notifier/notifier.go).
## Bot Options 🤖
### Default Commands 📝
| Command | Description |
|--------------|-----------------------------------------------------|
| /help | Get help message showing all possible commands |
| /prayers | Get prayers time |
| /date | Get prayers time by date |
| /subscribe | Subscribe to get notified on the prayers time |
| /unsubscribe | Unsubscribe to not get notified on the prayers time |
| /lang | Change the bot language (Default English) |
| /feedback | Send feedback to the bot owner |
| /bug | Report a bug to the bot owner |### Admin Commands 📝
| Command | Description |
|----------|------------------------------------|
| /subs | Get subscribers count |
| /sall | Send message to all subscribers |
| /respond | Respond to feedback or bug message |## References 📚
- [Telegram API (Telego)](https://github.com/SakoDroid/telego)
- [Prayer Times Site](http://dumrt.ru/ru/help-info/prayertime/)## Upcoming Features 🚀
### Version 1 Milestones 🏁
- [x] Support date format for `/prayersdate` command with leading zeros and with delimiters (. / -)
- [x] Implement subscriptions & notifications
- [x] Update text messages to be more user-friendly### Version 2 Milestones 🏁
- [x] store prayers time in memory to reduce the number of requests to the database since the prayers time is not changing
- [x] make response endpoint for admin to respond to feedback & bug messages
- [x] remind about gomaa prayer on friday### Version 3 Milestones 🏁
- [x] Add time keyboard to `/date` command
- [x] Remove selection message for `/date` & `/lang` after the use interacts with the message or timeout
- [x] On new user commands terminate other going channels that are listening to the chat
- [x] Add feature to delete old prayer time message when new one is sent
- [x] Add feature to send all subscribers a message from admin
- [x] Add feature to get count of subscribers for admin
- [x] Write more robust tests for core features### Version 4 Milestones 🏁
- [x] Add different languages support (AR, RU, TT, TR, UZ)
- [x] Use script messages in the bot
- [x] Set user script before command if nor set
- [x] USe script commands in notifications
- [x] Fix prayers timetable for other languages### Version 5 Milestones 🏁
- [x] Refactor the code to be more readable and maintainable
- [x] Enhance logging to be more informative and useful
- [x] Enable using many bot in the same code