Skip to content

Latest commit

 

History

History
138 lines (93 loc) · 4.09 KB

CONTRIBUTING.md

File metadata and controls

138 lines (93 loc) · 4.09 KB

Contributing to Amibot-tg

Note: The dev branch is the most up-to date version of this repository and where major features are currently being worked on

We welcome contributions to Amibot-tg from the community. If you would like to contribute, please follow these steps:

  1. Fork this repository
  2. Create a new branch (git checkout -b dev/my-feature)
  3. Make your changes and commit them (git commit -am 'Add my feature')
  4. Push to the branch (git push origin dev/my-feature)
  5. Open a pull request

Please make sure your code follows the PEP 8 style guide and includes any necessary documentation or tests.

Requirements

To use Amibot-tg, you'll need:

  • Python 3.11 or higher
  • The following Python packages:
    • pymongo
    • grpcio
    • protobuf
    • google-api-python-client
    • grpc-gateway-protoc-gen-openapiv2
    • python-telegram-bot
    • python-dotenv
  • A token generated by the Telegram BotFather
  • Miscellaneos:

Getting started

Clone the repository:

git clone https://github.com/achintya-7/Amibot-tg.git
cd Amibot-tg

Installing dependencies

  1. Install Python dependencies, pre-commit hooks and setup the virtual environment:

    make install
  2. Install Nodemon

    npm install -g nodemon
  3. Install docker. While knowing docker isn't a prerequisite, you have to install and run docker in the background in order to use MongoDB.

Updating the Token

Before running the bot, you'll need to update the token in the env.py file with the token generated by the Telegram BotFather. To generate a token:

  1. Open Telegram and search for the BotFather.

  2. Send the BotFather the /newbot command.

  3. Follow the prompts to name and create your bot.

  4. The BotFather will provide you with a token for your bot. Copy this token and replace the 'token' keyword with it.

    TOKEN = os.environ.get("TOKEN", "token")

    To something like this!

    TOKEN = os.environ.get("TOKEN", "5123422892:ABEyasfEXf...")

Generating Protobuf

If you make any changes to the amizone.proto file, you'll need to regenerate the corresponding Python code. You can do this by running the following command:

make gen

Setting Up MongoDB

To run the bot, you'll need to set up a MongoDB instance. You can use Docker to create a local instance by running the following command:

make mongo

Running the Bot with Nodemon

If you want to automatically restart the bot whenever you make changes to the code, you can use Nodemon. Run the following command instead of poetry run python main.py:

make dev

Linting/Formatting

Always make sure to check the quality of code before committing/pushing i.e making sure that the codebase is properly formatted and linted.

Use the following command to Lint and format.

make check

Go Amizone

This project uses go-amizone via gRPC to get its data. While knowledge of gRPC isn't a requirement, you can test how we get data through this Postman collection

Usage

Once the bot is up and running, you can use the following commands to interact with it:

  • /start: Start the bot and display the available commands.
  • /login "amzione_id" "amizone_password": Logs you in Amizone.
  • /attendance: Get your attendance information.
  • /schedule: Get your class schedule.
  • /about: Get details about our project.

Testing CI/CD

For testing CI/CD, we use act. Act is a tool that allows you to run GitHub Actions locally. It spins up a Docker container that emulates the GitHub Actions environment, allowing you to test your workflows locally. To install act, run the following command:

brew install act

Further, you can run the following command to test the CI/CD pipeline:

act -W .github/workflows/workflow-file-name.yml