Skip to main content

A package to deliver notifications via your telegram bot

Project description

Installation

$ pip install notipi 

Setup

In order to use notipi library - you would be needing two environment variables: BOT_API_TOKEN and CHAT_ID

To get BOT_API_TOKEN:

  • In the telegram app, initiate conversation with @BotFather and follow the instructions to create a new bot and get the BOT_API_TOKEN
  • You will be required to enter bot's account name and username.
  • Detailed instructions can be found at Telegram website

To get CHAT_ID:

  • Once a new bot is created, send a dummy message to the bot via Telegram app so that your chat gets assigned an ID.
  • Run the following script with your BOT_API_TOKEN to get your CHAT_ID
from notipi.notipi import get_chat_id
get_chat_id(BOT_API_TOKEN)

This will give the following output:

Your CHAT ID: 1234567890

Once the BOT_API_TOKEN and CHAT_ID are obtained, set the environment variables

export BOT_API_TOKEN=<bot_api_token>
export CHAT_ID=<chat_id>

Usage

Once the required environment variables are in place, following script can be used to send messages to your telegram app.

from notipi.notipi import notify

def example():
    for i in range(1000):
        if i%100==0:
            notify(f"Currently at {i}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notipi-0.0.2.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

notipi-0.0.2-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page