Giter VIP home page Giter VIP logo

telegram's Introduction

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)

telegram's People

Contributors

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