GithubHelp home page GithubHelp logo

malekkhatab / affiliatetelegrambot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aritzherrero4/affiliatetelegrambot

0.0 0.0 0.0 38 KB

A simple python Telegram bot to generate Amazon affiliate links

License: GNU General Public License v3.0

Python 100.00%

affiliatetelegrambot's Introduction

Affiliate link generator - Telegram Bot

This simple python bot generates affiliate links from telegram messages. It can work added in a group or speaking directly to it. It would recognize any Amazon URL in any message and reply with the affiliate URL.

The setup is done using Heroku as the host for the bot.

NOTE: It will only recognize the first Amazon URL in the message for now.

Admitted URLs

You set the base URL using a env variable. this bot can automatically detect the following Amazon URLs. If the URL is shortened, it works too:

  • .../gp/product/PRODUCTCODE/...
  • .../dp/PRODUCTCODE/...
  • .../gp/aw/d/PRODUCTCODE

If you find different URS schemes, they can be added to the regular expression and will work.

Env variables

There are 3 required env variables that must be configured in Heroku to work.

  • affiliate_tag : The affiliate tag you want to use for the generated URL.

  • search_url: The base URL used for the link. For example "amazon.es" for the Spanish Amazon website products. The URL must be provided without http/https and without www.

  • TOKEN: The API Token of the telegram bot. This can be obtained after creating a bot with botFather.

There is an optional variable that can be set with the chat_id of the developer with the bot to receive messages when an URL is not filtered or the product code is not found.

  • DEV_CHAT_ID: Telegram chat id of the chat to send the messages

How to create your own bot

If you want to create your own bot, fork or clone this repo and configure it to run locally. For this steps to work, you will need git, python3 and pip installed. Other dependencies might be necessary depending on your operating system.

First, you need to clone the repo with the bot source code.

git clone https://github.com/Aritzherrero4/AffiliateTelegramBot.git

Then, install the python requirements.

cd AffiliateTelegramBot
pip install -r requirements.txt

Set the environment variables correctly and run the bot.

python3 bot.py

NOTE: To keep the bot running, the python program must be running. This configuration is useful for an always on server like set-up.

Useful links

Telegram bots

affiliatetelegrambot's People

Contributors

aritzherrero4 avatar malekkhatab 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.