Giter Club home page Giter Club logo

lnbitsbot-js's Introduction

lnbitsbot-js

This is a Basic Template Telegram Bot For LNBits written in Common js. It will allow you to access your LNBits wallet and create and process invoices. This template only supplies the methods for the basic wallet, however it can be extended to use other extensions. Checks and balances are minimal, and developers who use this template should implement their own.

Written in Node.js

What does it do?

The template contains basic functions to:

  • Get Balance
  • Create Invoice
  • Check Invoice
  • Decode Invoice
  • Pay Invoice

Telegram Bot

How to setup your bot:

  • Step 1. Get a botfather token for your bot

  • Step 2. Get your Admin key and Invoice/read key from LNBits Wallet Page.

    LNBits wallet page

  • Step 3. Copy .env.example to .env. Add your values from Step 1 and 2 to .env

  • Step 4. Run your bot and check that it works.

$ yarn
$ yarn start

CAVEAT: This is a demo and proof of concept bot, if the bot is deployed there is a balance, anyone who accesses your bot will be able to spend the balance by the 'pay invoice' button.

Deploy your bot to fly.io as a Node App

First, sign up for an account at Fly.io (no credit card required).

Then, install the Fly.io CLI onto your device here.

git clone https://github.com/lightningames/lnbitsbot-js.git
cd lnbitsbot-js
$ fly auth login
$ fly launch

Next,

  • give it an app name
  • postgres - select no
  • deploy now - select no

You should now have a fly.toml file

Edit the fly.toml

[env]
    LNBITS_URL='https://your.lnbits.here.com'

NOTE: Don't enter secret environment variables here (admin and invoice key). Fly.io offers secrets (via the fly secrets command) that are exposed as environment variables in your runtime. Example: you can run


$ fly secrets set BOT_TOKEN=<bot_token_here>.
$ fly secrets set ADMIN_KEY=<admin key here>
$ fly secrets set INVOICE_KEY=<invoice key here>

Also see: https://fly.io/docs/reference/secrets/#setting-secrets

See the .env.example for other variables that need to be set as secrets.

Then deploy changes to your app, by running:

$ flyctl deploy

Also see Fly.io Docs to Run a Node App

lnbitsbot-js's People

Contributors

bitkarrot avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar

lnbitsbot-js's Issues

Handle multiple users

Handle multiple users with the User Manager Extension, so for each new user in telegram, they have their own LNBits wallet.

Allow each user to set an email address in LNBits as a backup option in case they lose access to telegram

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.