Skip to content
CodeWithTanimPublic

About

This script is for Messenger ChatBOT. By using this you can run this script in your BOT file

Resources

Stars

6 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Quran Verse Bot

Coding

A Facebook Messenger bot command that shares random Quranic verses with Arabic text, Bengali translations, English translations, and a randomly selected image.

Developed by CodeWithTanim

GitHub Repository

Features

  • Random Quranic Verses: Selects a random verse from a predefined collection of Quranic passages.
  • Arabic Text: Includes the Arabic text of each stored verse.
  • Bengali Translation: Shares Bengali translations to help Bengali-speaking users understand the verses.
  • English Translation: Includes English translations alongside the Arabic and Bengali text.
  • Verse References: Displays the associated Surah name and verse reference.
  • Random Images: Selects one image at random from a collection of five configured image URLs.
  • Combined Message and Image: Sends the selected verse and its image together in one Messenger message.
  • Automatic Image Download: Downloads the selected image before attaching it to the message.
  • Automatic File Cleanup: Attempts to delete the temporary image after sending the message.
  • Simple Command Execution: Requires no arguments to generate a verse.
  • Lightweight Implementation: Uses Node.js with asynchronous file and message handling.

Requirements

  • Node.js
  • A compatible Facebook Messenger bot framework
  • axios
  • request
  • fs-extra
  • A working bot session with permission to send messages and attachments
  • An accessible cache directory inside the command directory

Installation

Clone the repository or download the JavaScript command file.

git clone https://github.com/CodeWithTanim/quran.git

Navigate to your bot's command directory and place the file there with the following name:

quran.js

Install the required dependencies if they are not already installed:

npm install axios request fs-extra

Make sure the following directory exists inside the command directory:

cache/

Restart your Messenger bot after installation.

Usage

Open a Messenger group where your bot is active and run the command using your configured prefix.

<prefix>quran

No additional arguments are required.

Each execution selects one verse from the stored collection and one image from the configured image list.

How It Works

  1. The command stores a collection of Quranic passages with Arabic text, Bengali translations, English translations, and references.
  2. When a user executes the command, the bot randomly selects one passage.
  3. The bot randomly selects an image URL from the configured image list.
  4. The image is downloaded and saved temporarily as cache/zac.jpg.
  5. The bot sends the verse text and downloaded image together.
  6. After sending the message, the bot attempts to remove the temporary image file.

Command Configuration

Property Value
Command Name quran
Version 1.0.0
Author Credit MSRTanim
Category random-img
Permission 0 as intended by the configuration
Cooldown 0 seconds

The exact permission behavior depends on your bot framework. The configuration uses hasPermision, which may be a typo if the framework expects hasPermssion.

Technical Details

Component Technology
Language JavaScript
Runtime Node.js
HTTP Requests request
File Handling fs-extra
Message Delivery Messenger bot framework
Content Selection JavaScript random selection

Important Notes

  • The command uses a predefined collection of verses rather than retrieving verses dynamically from a Quran API.
  • The image URLs are hardcoded in the source code.
  • Image downloads depend on the availability and accessibility of the configured URLs.
  • The command uses a fixed temporary filename, cache/zac.jpg. Concurrent executions could conflict if multiple requests run at the same time.
  • The image cleanup callback uses fs.unlinkSync(). If the file is missing or cannot be deleted, this may cause an error.
  • Quranic text, verse references, and translations should be checked against reliable Quran sources before publication. Translation wording can vary between editions.
  • The script imports axios but does not use it in the provided implementation.

Future Improvements

  • Add more verified Quranic verses.
  • Include Surah names and verse numbers in a consistent format.
  • Add a command to retrieve a specific Surah and verse.
  • Support multiple Bengali and English translation editions.
  • Replace the deprecated request package with a maintained HTTP client.
  • Use unique temporary filenames to prevent conflicts.
  • Improve error handling for failed image downloads and message delivery.
  • Add an option to send the verse without an image.
  • Add support for Quran recitation audio.
  • Retrieve verified verse text from a trusted Quran data source.

Connect With Me

GitHub X (Twitter) Facebook Instagram YouTube

GitHub: CodeWithTanim

Thank You

Thank you for checking out this project. May the Quranic verses shared through this command inspire reflection, patience, and goodness.

Developed by CodeWithTanim

About

This script is for Messenger ChatBOT. By using this you can run this script in your BOT file

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages