Skip to main content

No project description provided

Project description

Simplest telegram bot

The simplest telegram bot out there that could be embedded into your apps as a notification service and could listen and execute remote commands.

Installation

pip install pytele

Introduction

The simplest telegram bot out there that could be embedded into your apps as a notification service and can listen and execute remote commands.

from telegram import Bot

bot = Bot() # takens the BOT's token from environment variables - TELEGRAM_BOT_TOKEN
bot.send_msg(to='chait_id', msg='your message')

The bot could listen and execute remote commands. In order to get started, please create a .yaml file with the following structure:

# commands.yaml

commands:
  1:
    name: Git status
    description: Get status of git from current directory
    command: /gitstatus
    action: git status
  2:
    name: Linux list
    description: List all file under current directory
    command: /ls
    action: ls

The action field should be exactly the same as the command executed on the CLI, e.g.

action: ls - will list current directory
action: ls /etc - will list all files under /etc

Once created, register the commands via register_commands(...) method and start listening. The specified interval, instructs the bot at what intervals to poll messages from telegram servers. Defaults to 3 but could be overwritten.

bot.register_commands('example_commands.yaml')
bot.listen(interval=5)

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

pytele-0.1.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

pytele-0.1.0-py3-none-any.whl (5.6 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