small-simple-bot

    0.3.0 • Public • Published

    Small Simple Bot

    A Really simple Telegram Bot

    Usage

    In your desktop / Local network

    Write my-bot.coffee:

    SmallSimpleBot = require 'small-simple-bot'
    
    bot = new SmallSimpleBot
        token: '123456789:YourBotsTelegramToken'
        adms: [
            { username: 'aurium', id: 123456789 }
            { username: 'diguliu', id: 987654321 }
        ]
    
    bot.addInteractions(
        require './my-interaction-module'
        require './other-interaction-module'
    )
    
    do bot.run

    In a server

    Write my-bot.coffee:

    SmallSimpleBot = require 'small-simple-bot'
    
    bot = new SmallSimpleBot
        token: '123456789:YourBotsTelegramToken'
        webhookPath: 'hidden-end-point'
        adms: [
            { username: 'aurium', id: 123456789 }
            { username: 'diguliu', id: 987654321 }
        ]
    
    bot.addInteractions(
        require './my-interaction-module'
        require './other-interaction-module'
    )
    
    server = do require('http').createServer
    
    bot.bindServer server
    
    server.listen process.env.PORT or 3000

    Create an interation module

    Write my-interaction-module.coffee:

    module.exports = (bot, update)->
        msg = update.message?.text or ''
        if update.toMe and msg
            bot.sendMessage "You said #{msg}", update.message.chat.id

    Keywords

    none

    Install

    npm i small-simple-bot

    DownloadsWeekly Downloads

    17

    Version

    0.3.0

    License

    AGPL-3.0

    Unpacked Size

    45.2 kB

    Total Files

    10

    Last publish

    Collaborators

    • aurium