Giter Club home page Giter Club logo

tori2telegram's Introduction

README for Telegram Bot Python Script

Overview

This Python script is designed to scrape and post items from a Finnish online marketplace (https://www.tori.fi) to a specified Telegram user. It includes features such as log file rotation and customizable settings for item posting time frame and script execution intervals.

Features

  • Automated Web Scraping: Retrieves item details from a specific URL.
  • Telegram Notifications: Sends item updates to a Telegram user.
  • Configurable Time Frame and Sleep Interval: Customizable settings for item posting time frame and execution intervals.
  • Log File Rotation: Automatically manages log file sizes, rotating them when they exceed a specified size.
  • Continuous Operation: Designed to run continuously in the background.

Prerequisites

  • Python 3.6 or later.
  • PIP for package installation.

Setting Up the Telegram Bot

To receive notifications, you need to create a Telegram bot and obtain a token:

  1. Open Telegram and search for 'BotFather'.
  2. Start a conversation with BotFather and create a new bot by sending /newbot.
  3. Follow the instructions to name your bot and get a username.
  4. BotFather will provide a token. Copy this token.
  5. Find your Telegram user ID by messaging @userinfobot.
  6. Create a .env file in the project directory with the following content:
    TELEGRAM_TOKEN=your_telegram_bot_token
    USER_ID=your_telegram_user_id
    LOG_LEVEL=DEBUG_or_INFO
    SLEEP_INTERVAL=define_seconds

Installation

  1. Clone the Repository (if applicable):

    git clone [repository-url]
    cd [repository-directory]
  2. Install Dependencies:

    pip3 install -r requirements.txt
  3. Environment Setup: Create a .env file with the following content:

    TELEGRAM_TOKEN=your_telegram_bot_token
    USER_ID=your_telegram_user_id
    LOG_LEVEL=DEBUG  # Can be INFO, WARNING, ERROR, CRITICAL
    SLEEP_INTERVAL=120  # Time in seconds for script sleep interval
    

Running the Script

Execute the script using the following command:

nohup python3 tori2telegram.py > tori2telegram.log 2>&1 &

This command runs the script in the background, detaching it from the terminal, and logs output to tori2telegram.log.

Stopping the Script

To stop the running script:

  1. Find the Process ID (PID):

    ps -ef | grep tori2telegram.py
  2. Terminate the Process:

    kill [PID]

    Replace [PID] with the actual process ID.

Configuration

Time Frame Configuration

  • TIME_FRAME_MINUTES: Set within the script to define the window for considering new items.

Script Sleep Interval

  • SLEEP_INTERVAL: Defined in the .env file, this variable sets the pause duration (in seconds) between execution cycles.

Log File Rotation

  • The script includes functionality to automatically rotate the log file tori2telegram.log when it reaches a specified size limit, keeping the log management efficient.

Important Notes

  • Adjust the sleep interval with caution to avoid server rate-limiting or high resource consumption.

Legal and Compliance Notice

This script is designed for personal, non-commercial use only. It functions by notifying the user about new listings on Tori.fi, sending direct links (not the content) to a specified personal Telegram account. Users should be aware that this script must be used in compliance with the terms of service of Tori.fi, and any applicable data protection and privacy laws. The script does not create a database or redistribute content from Tori.fi. Users are responsible for ensuring that their use of the script aligns with all legal and regulatory requirements. This tool is not endorsed by or affiliated with Tori.fi or Telegram. For any concerns or questions about legal compliance, users are encouraged to consult with a legal professional.

tori2telegram's People

Contributors

majnikool 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.