This repository contains the code for a prayer reminder bot named @PrayPalBot that interacts with users via Telegram and utilizes the Muslim Salah API for prayer time data. User settings are stored in an SQLite database.
Features:
- Schedules prayer reminders based on user location and lead time preferences (handled in
reminders.py). - Fetches prayer times and handles timezones (in
prayers.py). - Manages user interactions through Telegram commands (implemented in
command_handler.py).- Guides users through setup process (
/start) - Allows users to view current settings (
/showsettings) - Provides today's prayer times for the user's location (
/todayprayertimes) - Shows the next upcoming prayer time reminder (
/nextsalat)
- Guides users through setup process (
- Offers optional email notifications for errors (requires configuration in
send_email.pyandcredentials.py). - Utilizes background tasks (
apscheduler) to automatically update reminders daily at midnight (UTC). - Logs errors and scheduler activity.
Project Structure:
main.py: The main script responsible for coordinating all functionalities.command_handler.py: Handles user interactions through Telegram commands.database_handler.py: Manages user settings in an SQLite database.prayers.py: Fetches prayer times and timezone information from an external API.reminders.py: Handles scheduling and sending prayer reminders to users.send_email.py: Provides a function to send emails using Gmail's SMTP server.utils.py: Contains utility functions and configurations for the bot, including logging and caching.config.py: Defines configuration settings like database name and log file path.credentials.py: Stores sensitive information like API keys and email credentials.run.sh: A shell script to manage the bot process (ensures only one instance runs).
Dependencies:
python-telegram-bot==13.7.0(for Telegram bot interaction)apscheduler(for job scheduling)cachetools(for caching functionality)requests(for making API requests)sqlite3(for database access)pytz(for timezone handling)
Getting Started:
- Clone the repository:
git clone https://github.com/firmanelhakim/praypalbot.git - Install required dependencies:
pip install -r requirements.txt - Create an empty file named
praypalbot.dbin the project directory. The bot uses this SQLite database to store user settings. - Configure settings (API keys, database name, email settings - modify
credentials.pyandconfig.pyaccordingly) - Run the bot:
./run.sh(assumingrun.shhas execute permissions) OR simply run withpython3 main.py
Security Considerations:
- DO NOT commit
credentials.pyto version control. Use environment variables or a secure configuration file for sensitive information. - Consider using app passwords for programmatic access to email instead of storing actual passwords.
How to Contribute
We welcome contributions to this project! Here are some ways you can help:
- Report issues: If you encounter any bugs or have suggestions for improvement, please create an issue on this repository.
- Fix bugs: If you're comfortable with the codebase, feel free to submit a pull request with your fix.
- Propose new features: If you have ideas for new functionality, open an issue to discuss it and potentially submit a pull request.
Making a Pull Request
- Fork this repository.
- Clone your forked repository to your local machine.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Open a pull request from your forked repository to the upstream repository.
We appreciate any contributions you can make!
License:
This project is licensed under the MIT License: https://opensource.org/licenses/MIT. This license allows for free use, modification, and distribution of the code, with attribution to the original author.
Additional Notes:
- Feel free to contact the project maintainers if you have any questions or need assistance.