A tip bot and Lightning wallet on Telegram ⚡️

logo

@LightningTipBot 🏅

A Telegram Lightning ⚡️ Bitcoin wallet and tip bot for group chats.

This repository contains everything you need to set up and run your own tip bot. If you simply want to use this bot in your group chat without having to install anything just start a conversation with @LightningTipBot and invite it into your group chat.

Setting up the bot

Installation

To build the bot from source, clone the repository and compile the source code.

git clone https://github.com/LightningTipBot/LightningTipBot.git
cd LightningTipBot
go build .
cp config.yaml-example config.yaml

After the configuration (see below), start it using the command

./LightningTipBot

Configuration

You need to edit config.yaml before starting the bot.

Create a Telegram bot

First, create a new Telegram bot by starting a conversation with the @BotFather. After you have created your bot, you will get an Api Token which you need to add to telegram_api_key in config.yaml accordingly.

Set up LNbits

You can either use your own LNbits instance (recommended) or create an account at lnbits.com to use their custodial service (easy).

  1. Create a wallet in LNbits (lnbits_url).
  2. Get the Admin key in the API Info tab of your user (lnbits_admin_key).
  3. Enable the User Manager extension.
  4. Get the Admin ID of the User Manager (lnbits_admin_id).

Getting LNbits keys

How to set up a lnbits wallet and the User Manager extension.

More configuration

  • webhook_server: URL that can reach the bot. This is used for creating webhooks with LNbits to receive notifications about payments (optional).
  • db_path: User database file path.
  • transactions_path: Transaction log file path.
  • message_dispose_duration: Duration in seconds after which commands will be deleted from channel (only if the bot is channel admin).

Features

Commands

/tip 🏅 Reply to a message to tip it: /tip <amount> [<memo>]
/balance 👑 Check your balance: /balance
/send 💸 Send funds to a user: /send <amount> <@username> [<memo>]
/invoice ⚡️ Create a Lightning invoice to receive payments: /invoice <amount> [<memo>]
/pay ⚡️ Pay a Lightning invoice: /pay <invoice>
/help 📖 Read this help.
/info 📚 More info.
/donate 🙏 Donate to @LightningTipBot: /donate <amount>

Live tooltips

The bot replies to a tipped message to indicate to all participants how many and what amount of tips a post has received. This tooltip will be updated as new tips are given to a post.

How to set up a lnbits wallet and the User Manager extension.

Link to BlueWallet or Zap

Every user can link their wallet to an external app like Bluewallet or Zeus by using the command /link. If you host the bot, you will have to enable the LndHub extension in LNbits. You also need to edit the lnbits_public_url entry in config.yaml accordingly to an address that can be reached by the user's wallet (Tor should be fine as well).

QR code payment example.

Pay invoices by sending QR codes

To pay a Lightning invoice, you can snap a photo of a QR code and send it directly to the bot. Note that you might need to zoom in, center the QR code, or crop the image if the bot fails to decode the QR code from the photo. By the way, you can also just send an the invoice as a string, the bot will automatically detect it and initiate a payment.

QR code payment example.

Auto-delete commands

To minimize the clutter all the heavy tipping can cause in a group chat, the bot will remove all failed commands (for example due to a syntax error) from the chat immediately. All successful commands will stay visible for message_dispose_duration seconds (default 10s) and then be removed. The tips will sill be visible for everyone in the Live tooltip. This feature only works, if the bot is made admin of the group.

Made with

  • LNbits – Free and open-source lightning-network wallet/accounts system.
  • telebot – A Telegram bot framework in Go.
  • gozxing – barcode image processing library in Go.
  • ln-decodepay – Lightning Network BOLT11 invoice decoder.
Comments
  • when more users are using the bot, got error message like this

    when more users are using the bot, got error message like this

    2021/08/22 19:09:40 runtime error: invalid memory address or nil pointer dereference gopkg.in/tucnak/telebot%2ev2.(*Bot).debug /home//go/pkg/mod/gopkg.in/tucnak/[email protected]/util.go:14 gopkg.in/tucnak/telebot%2ev2.(*Bot).deferDebug /home//go/pkg/mod/gopkg.in/tucnak/[email protected]/util.go:25 runtime.gopanic /usr/local/go/src/runtime/panic.go:1038 runtime.panicmem /usr/local/go/src/runtime/panic.go:221 runtime.sigpanic /usr/local/go/src/runtime/signal_unix.go:735 main.tipTooltipInitializedHandler /home//src/LightningTipBot/message.go:79 main.TipBot.initWallet /home//src/LightningTipBot/start.go:58 main.TipBot.startHandler /home//src/LightningTipBot/start.go:29 main.TipBot.balanceHandler /home//src/LightningTipBot/balance.go:22 gopkg.in/tucnak/telebot%2ev2.(*Bot).handle.func1 /home//go/pkg/mod/gopkg.in/tucnak/[email protected]/bot.go:462 gopkg.in/tucnak/telebot%2ev2.(*Bot).runHandler.func1 /home//go/pkg/mod/gopkg.in/tucnak/[email protected]/util.go:35 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:1581

  • Lightning address is empty in /help

    Lightning address is empty in /help

    The bot works as expected, but at help command, the lightning addresses displayed are incomplete. The @domain is missing.

    ℹ️ Info Your Lightning address is user@

    Already updated the config, but as described (https://github.com/LightningTipBot/LightningTipBot#lnurl-server), there is no config lnurl_public_server.

    my config looks like this:

    bot:
      socks_proxy:
          host: 127.0.0.1:9996
          username: test
          password: username
      tor_proxy:
          host: 127.0.0.1:9050
      http_proxy: ""
      lnurl_public_host_name: "mydomain.org"
      lnurl_server: "https://mydomain.org/lndhub/ext"
      lnurl_image: true
      admin_api_host: localhost:6060
    telegram:
      message_dispose_duration: 10
      api_key: "1234:xyz"
    lnbits:
      url: "http://127.0.0.1:5000"
      admin_key: "myadminkey"
      admin_id: "myadminid"
      webhook_server: "http://0.0.0.0:5588"
      lnbits_public_url: "https://mydomain.org"
    database:
      db_path: "data/bot.db"
      buntdb_path: "data/bunt.db"
      transactions_path: "data/transactions.db"
      shop_buntdb_path: "data/shop.db"
      groupsdb_path: "data/groups.db"
    generate:
      dalle_key: "asd"
      dalle_price: 1000
      worker: 2
    

    How can i fix the displayed lightning addresses?

  •  Error initializing your wallet. Try again later.

    Error initializing your wallet. Try again later.

    From our desktop tg client ( running Ubuntu and other *NIX ) we get that message .Please note that we are located so to speak in Rouseau Dominica Caribbean and Bahia Blanca Argentina SA. This happens also with a VPN conn with NL IP number

  • feature request: create a wallet for a  user when someone else /send to it if absent

    feature request: create a wallet for a user when someone else /send to it if absent

    a /send will fail right now if the recipient has not created a wallet already. Can we create a wallet by default if a user is being sent sats for the first time?

  • copying /tmp/go-build2378678836/b001/exe/a.out: open LightningTipBot: permission denied

    copying /tmp/go-build2378678836/b001/exe/a.out: open LightningTipBot: permission denied

    Hello, I get the following error when running go build . I have tried touch /tmp/myfile which gave me no response, so it seems to be fine.

    What can I do to fix it?

    Kind regards, jcjms.

  • no support on GitHub

    no support on GitHub

    Something is wrong with lightningtipbot or your lndhub nodes..i can't send out or receive funds..also when i go to send out sats it takes my sats but states it couldnt pay the invoice..have tried lnurl, and invoice..

  • Error initializing your wallet. Try again later.

    Error initializing your wallet. Try again later.

    We have one user in our group that is unable to start a wallet.

    she has also tried deleting the chat and starting over - this has been going on for a while now. the rest of us in the telegram group have no issues.

    anything in her settings that could cause this? I see an old issue ( #113 ) that was resolved but no information on what the problem was.

    thank you

    image

  • Feature: Language selection

    Feature: Language selection

    I think it would be nice to make this bot available in different language. I'm willing to help for French as soon as the idea is accepted and a translation process is defined.

  • settlement date incorrect or confusing

    settlement date incorrect or confusing

    Here is an example of a tip shown in tx history:

    Date Created 24/Aug/2021 07:21

    Date Settled 31/Dec/1970 16:00

    If the settled date is unknown, maybe should be left blank.

  • failed to initialize database

    failed to initialize database

    With the current Version and with Release Version v0.5 i got this error on first start

    INFO[0000] Starting Dalle image generation. Worker: 2, Price: 1000 sat INFO[2022-10-25 12:49:29] [PriceWatcher] Watcher started

    2022/10/25 12:49:29 /home/lightningtipbot/LightningTipBot/internal/telegram/database.go:96 [error] failed to initialize database, got error unable to open database file: no such file or directory ERRO[2022-10-25 12:49:29] Recovered panic: Initialize orm failed.
    goroutine 1 [running]: runtime/debug.Stack() /usr/local/go/src/runtime/debug/stack.go:24 +0x88 runtime/debug.PrintStack() /usr/local/go/src/runtime/debug/stack.go:16 +0x20 main.withRecovery() /home/lightningtipbot/LightningTipBot/main.go:93 +0x98 panic({0xc935c0, 0xf888d8}) /usr/local/go/src/runtime/panic.go:1038 +0x224 github.com/LightningTipBot/LightningTipBot/internal/telegram.AutoMigration() /home/lightningtipbot/LightningTipBot/internal/telegram/database.go:98 +0x628 github.com/LightningTipBot/LightningTipBot/internal/telegram.NewBot() /home/lightningtipbot/LightningTipBot/internal/telegram/bot.go:48 +0xe8 main.main() /home/lightningtipbot/LightningTipBot/main.go:40 +0x60

  • Support reading QR with LNURL Fallback Scheme defined in LUDS-01

    Support reading QR with LNURL Fallback Scheme defined in LUDS-01

    Galoy has added LNURL Fallback Scheme to Bitcoin Beach Wallet's static Paycode QR - context .

    Testing various Lightning Wallets, I noticed that Lightning Tip Bot cannot read the LNURL correctly. You can test for yourself here by scanning with Lightning Tip Bot.

    The QR encodes the following: https://pay.bbw.sv/IDEASARELIKEFLAMES?LIGHTNING=LNURL1DP68GURN8GHJ7URP0YHXYCNH9EEHVTEWWAJKCMPDDDHX7AMW9AKXUATJD3CZ76TYV4SHXCTJV4KXJ6M9VEKXZMT9WVFEEZHA

  • Lightning Address and LNURL does not work

    Lightning Address and LNURL does not work

    Iam running the LightningTipBot (v0.5) on my Raspiblitz (v1.8.0) based on LNBits (v0.9.4).

    LNBits is forwarded to Clearnet on Port 443 (https). If a LightningTipBot user on Telegram go to /advanced, he gets shown the Lightning Address like [email protected] or a LNURL decoded as https://mydomain.org/.well-known/lnurlp/0x7fa3a123456cb7fa\

    If try to make a Payment, errors are shown in LightningTipBot logs:

    level=warning msg="[HandleLNURL] Error: Get "[https://mydomain.org/.well-known/lnurlp/0x7fa3a123456cb7fa](https://mydomain.org/.well-known/lnurlp/0x7fa3a123456cb7fa%5C)": socks connect tcp 127.0.0.1:9996->mydomain.org:443: dial tcp 127.0.0.1:9996: connect: connection refused"

    I can not find a listening lnurl server on 9996 via netstat.

  • Feature: Create and Redeem Coupons

    Feature: Create and Redeem Coupons

    Instead of sending sats to a specific user, I would like to attach funds to a random ~8 digits coupon code - for anyone could redeem.

    This will allow users to write down the coupon code on a piece of paper, for example as a tip in a restaurant (without the awkwardness of asking the waiter for his telegram username). There could also be a captcha to solve, in order to block bots that try all possible coupon codes.

    It could also be nice to design a small note to print (the size of a business card), like:

    +-----------------------------------------------+
    |                Bitcoin Coupon!                |
    |    Redeemable with Telegram at www.ln.tips    |
    |           Coupon Code: ____________           |
    |       Value: ________ sats ≈ $ ________       |
    |           (dollar value may change)           |
    |       Expiry date (optional): _________       |
    |                                               |
    |       Sats is the base unit of Bitcoin        |
    |            like cents and dollars.            |
    |         1 Bitcoin = 100,000,000 sats          |
    +-----------------------------------------------+
    

    (sorry for my pronunciation, I'm not a native english speaker).

    Users could print several of these notes, keep in their wallet, and on the spot fill the missing placeholders and leave it as a tip.

    Obviously the tipper could "steal the funds" knowing the coupon code, but then why would he tip in the first place...

    The expiry date could be give an incentive for lazy no-coiners to hurry up.

  • WIP: update GetUserStr - GetUserStrMd

    WIP: update GetUserStr - GetUserStrMd

    • GetUserStr

    goos: darwin goarch: arm64 pkg: github.com/LightningTipBot/LightningTipBot/internal/telegram BenchmarkGetUserName BenchmarkGetUserName-10 20432500 58.77 ns/op BenchmarkGetUserStrNoUsername BenchmarkGetUserStrNoUsername-10 13479517 88.93 ns/op BenchmarkGetUserStrNoFirstName BenchmarkGetUserStrNoFirstName-10 12947025 92.27 ns/op PASS

    • updated GetUserStr

    goos: darwin goarch: arm64 pkg: github.com/LightningTipBot/LightningTipBot/internal/telegram BenchmarkGetUserName BenchmarkGetUserName-10 19599570 58.22 ns/op BenchmarkGetUserStrNoUsername BenchmarkGetUserStrNoUsername-10 22363182 53.96 ns/op BenchmarkGetUserStrNoFirstName BenchmarkGetUserStrNoFirstName-10 21759808 54.73 ns/op PASS

    • GetUserStrMd

    BenchmarkGetUserStrMdName-10 15102800 75.20 ns/op BenchmarkGetUserStrMdNoUsername BenchmarkGetUserStrMdNoUsername-10 7925005 151.2 ns/op BenchmarkGetUserStrMdNoFirstName BenchmarkGetUserStrMdNoFirstName-10 8326500 144.3 ns/op PASS

    • updated GetUserStdMd

    BenchmarkGetUserStrMdName-10 15895222 75.47 ns/op BenchmarkGetUserStrMdNoUsername BenchmarkGetUserStrMdNoUsername-10 10507543 114.8 ns/op BenchmarkGetUserStrMdNoFirstName BenchmarkGetUserStrMdNoFirstName-10 10276515 111.1 ns/op PASS

    Both passing all defined tests

    /private/var/folders/tt/fs3zvlp53cgf_dtv5hhyc6cc0000gn/T/GoLand/___users_test_go.test -test.v -test.paniconexit0 -test.run ^\QTestGetUserStr\E|\QTestGetUserStrMd\E$ === RUN TestGetUserStr --- PASS: TestGetUserStr (0.00s) === RUN TestGetUserStr/NoUserName --- PASS: TestGetUserStr/NoUserName (0.00s) === RUN TestGetUserStr/UserName --- PASS: TestGetUserStr/UserName (0.00s) === RUN TestGetUserStr/NoUserName#01 --- PASS: TestGetUserStr/NoUserName#01 (0.00s) === RUN TestGetUserStr/NoUserName#02 --- PASS: TestGetUserStr/NoUserName#02 (0.00s) === RUN TestGetUserStrMd --- PASS: TestGetUserStrMd (0.00s) === RUN TestGetUserStrMd/NoUserName --- PASS: TestGetUserStrMd/NoUserName (0.00s) === RUN TestGetUserStrMd/UserName --- PASS: TestGetUserStrMd/UserName (0.00s) === RUN TestGetUserStrMd/NoUserName#01 --- PASS: TestGetUserStrMd/NoUserName#01 (0.00s) === RUN TestGetUserStrMd/NoUserName#02 --- PASS: TestGetUserStrMd/NoUserName#02 (0.00s) PASS

    Process finished with the exit code 0

Pro-bot - A telegram bot to play around with the community telegram channels

pro-bot ?? Pro Bot A Telegram Bot to Play Around With The Community Telegram Cha

Jan 24, 2022
lightning - forward messages between a qq group and a telegram group

lightning The purpose of this project is to forward messages between a qq group and a telegram group. Getting Started Clone this project: git clone ht

Nov 9, 2022
A bot based on Telegram Bot API written in Golang allows users to download public Instagram photos, videos, and albums without receiving the user's credentials.

InstagramRobot InstagramRobot is a bot based on Telegram Bot API written in Golang that allows users to download public Instagram photos, videos, and

Dec 16, 2021
This bot keeps information about your crypto wallet.

Telegram bot @crypto_wallet_gobot This bot writes to database information about your cryptocurrencies. Functions: add currency(example: btc) amount(ex

Jan 12, 2022
Bot - Telegram Music Bot in Go

Telegram Music Bot in Go An example bot using gotgcalls. Setup Install the serve

Jun 28, 2022
Bot-template - A simple bot template for creating a bot which includes a config, postgresql database

bot-template This is a simple bot template for creating a bot which includes a c

Sep 9, 2022
The serverless OTP telegram service use telegram as OTP service, and send OTP through webhook

Setup OTP First thing, you need prepare API(webhook) with POST method, the payload format as below { "first_name": "Nolan", "last_name": "Nguyen",

Jul 24, 2022
IRC, Slack, Telegram and RocketChat bot written in go
IRC, Slack, Telegram and RocketChat bot written in go

go-bot IRC, Slack & Telegram bot written in Go using go-ircevent for IRC connectivity, nlopes/slack for Slack and Syfaro/telegram-bot-api for Telegram

Dec 20, 2022
Golang telegram bot API wrapper, session-based router and middleware

go-tgbot Pure Golang telegram bot API wrapper generated from swagger definition, session-based routing and middlewares. Usage benefits No need to lear

Nov 16, 2022
Bot that polls activity API for Github organisation and pushes updates to Telegram.

git-telegram-bot Telegram bot for notifying org events Requirements (for building) Go version 1.16.x Setup If you don't have a telegram bot token yet,

Apr 8, 2022
Library for working with golang telegram client + bot based on tdlib. This library was taken from the user Arman92 and changed for the current version of tdlib.

go-tdlib Golang Telegram TdLib JSON bindings Install To install, you need to run inside a docker container (it is given below) go get -u github.com/ka

Dec 2, 2022
Telegram bot for distorting images and stickers using CAS
Telegram bot for distorting images and stickers using CAS

Distortioner Telegram bot for distorting pictures, stickers, voice messages and GIFs using Content Aware Scale. Currently resides here: @distortionerb

Dec 21, 2022
Telegram bot check your TrainingPeaks profile workouts and send notification if some workouts added or changed

TrainingPeaks Bot Telegram bot check your TrainingPeaks profile workouts and sen

Dec 29, 2021
UcodeQrTelebot ver2 - Easy way to get QR and U-code using Utopia API in telegram bot
UcodeQrTelebot ver2 - Easy way to get QR and U-code using Utopia API in telegram bot

UcodeQrTelebot Easy way to get QR and U-code using Utopia API in telegram bot Us

Dec 30, 2021
RaspChecker - A Telegram bot that allows you to monitor your Raspberry Pi's temperature and shut it down. Written in Golang.

RaspChecker Remotely monitor your Raspberry Pi's temperature and shut it down if you want. All through Telegram. How to set up In order to run the bot

Jan 2, 2022
go telegram bot, used for video collect and more.

For what 我的想法: 部署一个私有的tg api server到国外的vps 通过 sshfs(sftp) 挂载我国内的nas到vps上 在tg上转发视频到我的bot 通过此程序handle此转发 透过私有api server会下载视频到我的vps上 将视频移动到挂载目录,自动同步到我的na

Jan 15, 2022
A Telegram bot that asks you a question and evaluate the response you provide.
A Telegram bot that asks you a question and evaluate the response you provide.

PiSquared A Telegram bot that asks you a question and evaluate the response you provide. Thanks to the labse_bert model, the evaluation of the answer

Nov 13, 2022
This repository will guide you to steal whatever the user copies and send content to telegram bot.

copy-clipboard-stealer-with-telegram This repository will guide you to steal whatever the user copies and send content to telegram bot. Setting Envior

Oct 4, 2022
Telegram Bot Framework for Go

Margelet Telegram Bot Framework for Go is based on telegram-bot-api It uses Redis to store it's states, configs and so on. Any low-level interactions

Dec 22, 2022