Giter VIP home page Giter VIP logo

paysysmirbot's Introduction

How and why

An example of this bot runs in @paysysmirbot. This telegram bot uses beautifulsoup4 to scrap data from Payment System MIR official website. It handles exchange-rated data (directly scraping it from the website and calculates the inverted exchange rate 1 / x). Script packing data from the website to a simple JSON file along with some metadata. As long as exchange rates change only once per day, the bot checks the date in JSON metadata at first. If the data was recorded today, it will use without requesting new data from the website. The script will request new data if it wouldn't find the JSON file or if the file will be outdated. The script stores JSON data files in data directory.

Available commands

/start - welcomes user, sends exchange rates and tips about other two commands
/rates - whenever you want to know the exchange rates\

Good to know

The bot uses User-Agent from the external file, which doesn't appear in the repo. Remember to put the correct User-Agent to the script (with decouple or manually), otherwise, your request to the website will be denied.

Logging

Since the website might try to block scraping (or if the structure of the page will change), the bot has simple logging implemented. Logs are stored in the logs directory. All logs are stored in the file main_log.txt. It contains both: information about the scraping script - whenever the JSON file was loaded or when scripts made a new request to the website and dump data to the file, and information about all user interactions with the bot (who and when entered different commands).

Templates

The bot uses message templates, which storing in the JSON file in templates directory and accessing to the messages by its key in the file.

Changelog

2023/03/22 Removed /notify command. Removed the number of currencies check in script.py.
2023/01/12 Added logging to stdout, should be working with docker logs too.
2023/01/12 Added aiocron for scheduled data update (every three hours) to avoid situations when the data file was generated today, but it contains old data, due to slow exchange rate updates on the source website.

paysysmirbot's People

Contributors

iwatkot avatar

Watchers

 avatar

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.