Giter Site home page Giter Site logo

txtelegrambot's Introduction

Telegram Bot Service (unofficial) in Twisted Python 3

A customisable bot for the Telegram Bot API written in Twisted Python 3

Uses:

  • TelegramBotAPI: An implementation of the Telegram Bot API messages and some simple clients.
  • pyPlugin: Simple framework-less plugin loader for Python.

Installation

pip3 install txTelegramBot

Usage

  • Create a config.ini as follows, and set it up with your Telegram Bot API token, etc:

    [telegrambot]
    # Your Telegram Bot API token
    token = 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
    
    [proxy]
    # address = www.example.com:8080
    
    [message_plugins]
    1 = plugins/*.py
    # 2 = other/plugins/foo.py
    
    [env]
    # Set any additional environment variables your plugins may need
    BOT_NAME = txTelegramBot
    # FOO = bar
    
  • Write a plugin using the following template and add it in the [message_plugins] section above:

    from twisted.internet import defer
    from TelegramBotAPI.types import sendMessage
    from TelegramBot.plugin.message import MessagePlugin
    
    
    class MyPlugin(MessagePlugin):
        def startPlugin(self):
            pass
    
        def stopPlugin(self):
            pass
    
        @defer.inlineCallbacks
        def on_message(self, msg):
            m = sendMessage()
            m.chat_id = msg.chat.id
            m.text = 'You said: %s' % msg.text
            rsp = yield self.send_message(m)
            defer.returnValue(True)
    
  • Run the bot:

    $ twistd -n telegrambot -c config.ini
    

txtelegrambot's People

Contributors

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