Code Monkey home page Code Monkey logo

10bot's Introduction

10bot

A bot to buy 10Bis coupons. The project is a Python script that automates the purchase of Shufersal Coupons in a 10bis account if there is sufficient credit and only on working days. The script generates a report containing the list of coupons and their barcodes and saves it in both PDF and HTML formats. The PDF file is then published to a designated WhatsApp group. To ensure consistent operation, the script can be scheduled to execute daily, using CRON or cloud Bot, such as Azure Function.

Bot Logic

Installation and usage

register to WhatApp API Provider

Register for a developer account in GREEN API. Go through the "Before you Start" instructions. Create instance, and authorized it.
write down idInstance, apiTokenInstance values, to be later use when installing.

repository download

download the repository

git clone https://github.com/kfiry77/10bot

install virtual environment and install requirements

cd 10bot
python -m venv .
source ./venv/bin/activate 
pip3 install -r requirements.txt

Addtional machine installations

Install prerequisites for weasyprint (for PDF report generation), as describe here

macOS

brew install weasyprint

linux / Ubuntu

apt install weasyprint

Windows

install gtk3 runtime and it's dependencies, and add the runtime to PATH environment variable

PATH=%PATH%;C:\Program Files\GTK3-Runtime Win64\bin

Execute script main

note: purchase won't be submitted if -d is specified.

python3 main.py -d 

When prompt, enter email id used for 10Bis Account. you should be getting an SMS with OTP. type it when prompt Enter OTP:

 user@machine:~/10bot python3 main.py -d 
 Enter Email: [email protected]
 Enter OTP: 12345

Enter the Green API data, you have noted initially.

*** Green API ***
Enter IntanceId : 1234567899 
Enter Api Token Instance : apiTokenInstance........
Enter ChatId/GroupId (Empty to create Group):

Hit enter to create a new chatgroup, enter the chatId(s) one by one ([email protected]), press enter when done.

Enter ChatId/GroupId (Empty to create Group):
Enter ChatId(Empty When Done): [email protected]
Enter ChatId(Empty When Done): [email protected]
Enter ChatId(Empty When Done):

Wait for the script execution

User [email protected] Logged In
budget available= True
Dry Run success, purchase will be skipped.
scanning Month:2023-11-01
scanning Month:2023-10-01
Created report until 2023-10-01

Validate, that it finishes correctly. Once finishes, a New group named "10Bot" will be added on WhatAppApplication a PDF with all the coupons will be shared in this group.

Add the script to the system crontab, by typing crontab -e and adding the following line to it.

0 23 * * *  (/bin/bash -c "cd /path/to/your/script && source .venv/bin/activate && python3 main.py  >> /path/to/your/log/10bot.log 2>&1 &") 

Whatsapp Group Commands:

The application now wakes up every day at 23:00, To disable specific day purchase (due to vacation), send /disable commands to the group. /enable command will enable it again. note that, only the command from last day is relevant, and of there is a conflict between command, the last one will be considered only.

references:

The code is bases from these repositories by Dvir Perets

TODO:

  • Bug Fix: user-token header is not needed due to 10bis change of API, RefreshToken API should be used instead.
  • Fix the holidays, to block only non-working day.
  • Add scrips the deployment to cloud providers:
    • Azure
    • GCP
  • Add Report generation.
    • Make the report formatter generic, for various kinds of files.
    • Make PDF report formatter.
  • Add report publisher, and make it generic using chain of responsibility GOF design pattern.
    • whatsApp Publisher
    • Google Drive or Microsoft OneDrive Publisher.
  • and make it generic to various kind for example: Google Drive share.
  • Bug Fix : Pdf is cannot be generated on windows due to weasyprint dependency.
  • describe software design with some plantuml class diagrams.
  • Coupon images crop, for a nicer report formatting.
  • Green API - send data to GroupChat
  • Before purchasing, read from whatapps group message, if a message /disable exists, then purchase will be skipped

10bot's People

Contributors

kfiry77 avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar

10bot's Issues

Buy 10bis credit instead of shufersal coupons

First of all, the repo is great, thanks.
It would be very helpful if instead of Shufersal coupons, I could configure the bot to buy 10bis credit.
If you have the option to buy 10bis credit too, you could buy one big Shufersal coupon instead of many small ones.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.