Compare commits

..
9 Commits
Author SHA1 Message Date
LightningTipBotandGitHub 3317cf09e1 force initialize user on PM (#19) 2021-08-24 23:54:24 +02:00
LightningTipBotandGitHub 13759ff048 Improve help (#15)
* help text

* log command

* comment

* improve help

* improved feedback

* hotfix new user creation (#17)

* improved feedback

* better help

* better help

* botfather commands
2021-08-24 01:41:10 +02:00
LightningTipBotandGitHub 827bfb108d hotfix new user creation (#17) 2021-08-23 20:46:57 +02:00
LightningTipBotandGitHub e2017ecfe9 Improve help (#14)
* improve help
2021-08-23 13:09:39 +02:00
LightningTipBot 059cb5cdd8 resize image 2021-08-23 00:46:49 +02:00
LightningTipBot 80d0ec57b1 Better readme 2021-08-23 00:32:57 +02:00
LightningTipBot 790f0943cc smaller image 2021-08-23 00:29:22 +02:00
LightningTipBot 4af2ca8799 qr code example 2021-08-23 00:22:04 +02:00
LightningTipBot 323fd14c9e Better readme 2021-08-23 00:15:22 +02:00
10 changed files with 73 additions and 39 deletions
+11 -5
View File
@@ -4,9 +4,9 @@
# @LightningTipBot 🏅
A tip bot and Lightning ⚡️ Bitcoin Wallet for Telegram group chats. It can also be used as a personal Lightning wallet by anyone who has a Telegram account.
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](https://t.me/LightningTipBot) and invite it into your chat.
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](https://t.me/LightningTipBot) and invite it into your group chat.
## Setting up the bot
@@ -21,9 +21,7 @@ go build .
cp config.yaml-example config.yaml
```
Alternatively, you can download binary releases [here](https://github.com/LightningTipBot/LightningTipBot/releases) **(note: no realses yet)**.
After you have configured the bot, start it using the command
After the configuration (see below), start it using the command
```
./LightningTipBot
@@ -81,6 +79,14 @@ The bot replies to a tipped message to indicate to all participants how many and
<img alt="How to set up a lnbits wallet and the User Manager extension." src="resources/tooltips.png" >
</p>
### 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.
<p align="center">
<img alt="QR code payment example." src="resources/qr_code_example.jpg" >
</p>
### 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.
+4 -4
View File
@@ -7,7 +7,7 @@
help - Read the help.
balance - Check your balance.
tip - Reply to a message to tip it.
send - Send funds to a user.
invoice - Create a Lightning invoice to receive payments.
pay - Pay a Lightning invoice.
tip - Reply to a message to tip. Example: /tip 50
send - Send funds to a Telegram user. Example: /send 100 @LightningTipBot
invoice - Create a Lightning invoice to receive payments. Example: /invoice 1000
pay - Pay a Lightning invoice. Example: /pay lnbc10n1ps...
+11 -9
View File
@@ -6,16 +6,16 @@ import (
)
const (
helpMessage = "ℹ️ *Info*\n_This bot sends Bitcoin tips on the Lightning Network⚡️. The basic unit of tips are Satoshis (sat). 100,000,000 sat = 1 Bitcoin. There will only ever be 21 Million Bitcoin._\n\n" +
helpMessage = "ℹ️ *Info*\n_This bot is a Bitcoin Lightning ⚡️ wallet that can sends tips on Telegram. To tip, add the bot to a group chat. The basic unit of tips are Satoshis (sat). 100,000,000 sat = 1 Bitcoin. There will only ever be 21 Million Bitcoin. Type /info for more._\n\n" +
"❤️ *Donate*\n" +
"_This bot charges no fees but generates costs. If you like to support this bot, please consider a donation. To donate, just tip @LightningTipBot or try_ `/send 1000 @LightningTipBot`\n\n" +
"_This bot charges no fees but costs satoshis to operate. If you like the bot, please consider supporting it with a donation. To donate, just tip @LightningTipBot or try_ `/send 1000 @LightningTipBot`\n\n" +
"⚙️ *Commands*\n" +
"*/tip* 🏅 Reply to a message to tip it: `/tip <amount> [<memo>]`\n" +
"*/balance* 👑 Check your balance: `/balance`\n" +
"*/send* 💸 Send funds to a user: `/send <amount> <@username> [<memo>]`\n" +
"*/tip* 🏅 Reply to a message to tip: `/tip <amount> [<memo>]`\n" +
"*/balance* 👑 Check balance: `/balance`\n" +
"*/send* 💸 Send funds to a Telegram user: `/send <amount> <@user> [<memo>]`\n" +
"*/invoice* ⚡️ Receive over Lightning: `/invoice <amount> [<memo>]`\n" +
"*/pay* ⚡️ Pay over Lightning: `/pay <invoice>`\n" +
"*/help* 📖 Read this help (more: */info*).\n"
"*/help* 📖 Read this help.\n"
infoMessage = "🧡 *Bitcoin*\n" +
"_Bitcoin is the currency of the internet. It is permissionless and decentralized and has no masters and no controling authority. Bitcoin is sound money that is faster, more secure, and more inclusive than the legacy financial system._\n\n" +
@@ -24,13 +24,15 @@ const (
"⚡️ *The Lightning Network*\n" +
"_The Lightning Network is a payment protocol that enables fast and cheap Bitcoin payments that require almost no energy. It is what scales Bitcoin to the billions of people around the world._\n\n" +
"📲 *Lightning Wallets*\n" +
"_Your funds on this bot can be sent to any other Lightning wallet and vice versa. If you don't have a Lightning wallet yet, check out_ [Phoenix](https://phoenix.acinq.co/)_,_ [Breez](https://breez.technology/)_,_ [Muun](https://muun.com/)_ (non-custodial), or_ [Wallet of Satoshi](https://www.walletofsatoshi.com/) _(easy)_.\n\n" +
"_Your funds on this bot can be sent to any other Lightning wallet and vice versa. Recommended Lightning wallets for your phone are_ [Phoenix](https://phoenix.acinq.co/)_,_ [Breez](https://breez.technology/)_,_ [Muun](https://muun.com/)_ (non-custodial), or_ [Wallet of Satoshi](https://www.walletofsatoshi.com/) _(easy)_.\n\n" +
"📄 *Open Source*\n" +
"_This bot is free and_ [open source](https://github.com/LightningTipBot/LightningTipBot) _software. You can run it on your own computer and use it in your own community. You don't have to trust anyone to keep your funds safe._\n\n" +
"_This bot is free and_ [open source](https://github.com/LightningTipBot/LightningTipBot) _software. You can run it on your own computer and use it in your own community._\n\n" +
"✈️ *Telegram*\n" +
"_Add this bot to your Telegram group chat to /tip posts. If you make the bot admin of the group it will also clean up commands to keep the chat tidy._\n\n" +
// "🏛 *Terms*\n" +
// "_We are not custodian of your funds. Any amount you load onto your wallet will be legally considered a donation that belongs to us. We will act in your best interest but we're also aware that the situation without KYC is tricky until we figure something out. Do not give us all your money. Be aware that this bot is in beta development. Use at your own risk._\n\n" +
"❤️ *Donate*\n" +
"_This bot charges no fees but generates costs. If you like to support this bot, please consider a donation. To donate, just tip @LightningTipBot or try_ `/send 1000 @LightningTipBot`"
"_This bot charges no fees but costs satoshis to operate. If you like the bot, please consider supporting it with a donation. To donate, just tip @LightningTipBot or try_ `/send 1000 @LightningTipBot`"
)
func (bot TipBot) helpHandler(m *tb.Message) {
+24 -7
View File
@@ -12,26 +12,43 @@ import (
tb "gopkg.in/tucnak/telebot.v2"
)
func helpInvoiceUsage(errormsg string) string {
helpstr := "📖 Oops, that didn't work. %s\n\n" +
const (
invoiceEnterAmountMessage = "Did you enter an amount?"
invoiceValidAmountMessage = "Did you enter a valid amount?"
invoiceHelpText = "📖 Oops, that didn't work. %s\n\n" +
"*Usage:* `/invoice <amount> [<memo>]`\n" +
"*Example:* `/invoice 1000 Take this! 💸`"
)
func helpInvoiceUsage(errormsg string) string {
if len(errormsg) > 0 {
helpstr = fmt.Sprintf(helpstr, fmt.Sprintf("_%s_", errormsg))
return fmt.Sprintf(invoiceHelpText, fmt.Sprintf("%s", errormsg))
} else {
helpstr = fmt.Sprintf(helpstr, "")
return fmt.Sprintf(invoiceHelpText, "")
}
return helpstr
}
// func helpInvoiceUsage(errormsg string) string {
// helpstr := "📖 Oops, that didn't work. %s\n\n" +
// "*Usage:* `/invoice <amount> [<memo>]`\n" +
// "*Example:* `/invoice 1000 Take this! 💸`"
// if len(errormsg) > 0 {
// helpstr = fmt.Sprintf(helpstr, fmt.Sprintf("%s", errormsg))
// } else {
// helpstr = fmt.Sprintf(helpstr, "")
// }
// return helpstr
// }
func (bot TipBot) invoiceHandler(m *tb.Message) {
log.Infof("[%s:%d %s:%d] %s", m.Chat.Title, m.Chat.ID, GetUserStr(m.Sender), m.Sender.ID, m.Text)
if m.Chat.Type != tb.ChatPrivate {
// delete message
NewMessage(m).Dispose(0, bot.telegram)
return
}
if len(strings.Split(m.Text, " ")) < 2 {
bot.telegram.Send(m.Sender, helpInvoiceUsage(""))
bot.telegram.Send(m.Sender, helpInvoiceUsage(invoiceEnterAmountMessage))
return
}
@@ -43,7 +60,7 @@ func (bot TipBot) invoiceHandler(m *tb.Message) {
}
if amount > 0 {
} else {
bot.telegram.Send(m.Sender, helpInvoiceUsage("Did you use a valid amount?"))
bot.telegram.Send(m.Sender, helpInvoiceUsage(invoiceValidAmountMessage))
return
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

+2 -2
View File
@@ -12,7 +12,7 @@ import (
)
const (
sendValidAmountMessage = "Did you use a valid amount?"
sendValidAmountMessage = "Did you enter a valid amount?"
sendUserNotFoundMessage = "User %s could not be found. You can /send only to Telegram tags like @%s."
sendIsNotAUsser = "🚫 %s is not a username. You can /send only to Telegram tags like @%s."
sendUserHasNoWalletMessage = "🚫 User %s hasn't created a wallet yet."
@@ -21,7 +21,7 @@ const (
sendErrorMessage = "🚫 Transaction failed: %s"
confirmSendInvoiceMessage = "Do you want to pay to %s?\n\n💸 Amount: %d sat"
confirmSendAppendMemo = "\n✉️ %s"
sendCancelledMessage = "🚫 Sending cancelled."
sendCancelledMessage = "🚫 Send cancelled."
errorTryLaterMessage = "🚫 Internal error. Please try again later.."
sendHelpText = "📖 Oops, that didn't work. %s\n\n" +
"*Usage:* `/send <amount> <user> [<memo>]`\n" +
+1
View File
@@ -55,6 +55,7 @@ func (bot TipBot) initWallet(tguser *tb.User) error {
return err
}
} else if !user.Initialized {
// update all tip tooltips (with the "initialize me" message) that this user might have received before
tipTooltipInitializedHandler(user.Telegram, bot)
user.Initialized = true
err = UpdateUserRecord(user, bot)
+8 -1
View File
@@ -1,9 +1,10 @@
package main
import (
log "github.com/sirupsen/logrus"
"strings"
log "github.com/sirupsen/logrus"
"github.com/LightningTipBot/LightningTipBot/pkg/lightning"
tb "gopkg.in/tucnak/telebot.v2"
)
@@ -13,6 +14,12 @@ func (bot TipBot) anyTextHandler(m *tb.Message) {
if m.Chat.Type != tb.ChatPrivate {
return
}
// check if user is in database, if not, initialize wallet
if !bot.UserHasWallet(m.Sender) {
log.Infof("User %s has no wallet, force-initializing", GetUserStr(m.Sender))
bot.startHandler(m)
}
// could be an invoice
invoiceString := strings.ToLower(m.Text)
if lightning.IsInvoice(invoiceString) {
+5 -5
View File
@@ -11,12 +11,12 @@ import (
)
const (
tipDidYouReplyMessage = "Did you reply to a message to tip? To reply to a message, right-click -> Reply on your computer or swipe the message on your phone."
tipDidYouReplyMessage = "Did you reply to a message to tip? To reply to any message, right-click -> Reply on your computer or swipe the message on your phone. If you want to send directly to another Telegram user's wallet, use the /send command."
tipEnterAmountMessage = "Did you enter an amount?"
tipValidAmountMessage = "Did you use a valid amount?"
tipValidAmountMessage = "Did you enter a valid amount?"
tipYourselfMessage = "📖 You can't tip yourself."
tipSentMessage = "💸 %d sat sent to %s."
tipReceivedMessage = "🏅 You've received a %d sat tip from %s."
tipReceivedMessage = "🏅 %s has tipped you %d sat."
tipErrorMessage = "🚫 Transaction failed: %s"
tipHelpText = "📖 Oops, that didn't work. %s\n\n" +
"*Usage:* `/tip <amount> [<memo>]`\n" +
@@ -83,7 +83,7 @@ func (bot *TipBot) tipHandler(m *tb.Message) {
if !bot.UserHasWallet(to) {
log.Infof("[/tip] User %s has no wallet.", toUserStr)
err = bot.CreateWalletForUser(to)
err = bot.CreateWalletForTelegramUser(to)
if err != nil {
errmsg := fmt.Errorf("[/tip] Error: Could not create wallet for %s", toUserStr)
log.Errorln(errmsg)
@@ -138,7 +138,7 @@ func (bot *TipBot) tipHandler(m *tb.Message) {
if !messageHasTip {
bot.telegram.Forward(to, m.ReplyTo, tb.Silent)
}
bot.telegram.Send(to, fmt.Sprintf(tipReceivedMessage, amount, fromUserStrMd))
bot.telegram.Send(to, fmt.Sprintf(tipReceivedMessage, fromUserStrMd, amount))
if len(tipMemo) > 0 {
bot.telegram.Send(to, fmt.Sprintf("✉️ %s", MarkdownEscape(tipMemo)))
+7 -6
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"strings"
"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
log "github.com/sirupsen/logrus"
tb "gopkg.in/tucnak/telebot.v2"
@@ -94,13 +95,13 @@ func (bot *TipBot) GetUserBalance(user *tb.User) (amount int, err error) {
return
}
func (bot *TipBot) CreateWalletForUser(tbUser *tb.User) error {
user, err := GetUser(tbUser, *bot)
func (bot *TipBot) CreateWalletForTelegramUser(tbUser *tb.User) error {
user := &lnbits.User{Telegram: tbUser}
userStr := GetUserStr(tbUser)
log.Printf("[CreateWalletForUser] Creating wallet for user %s ... ", userStr)
err = bot.createWallet(user)
log.Printf("[CreateWalletForTelegramUser] Creating wallet for user %s ... ", userStr)
err := bot.createWallet(user)
if err != nil {
errmsg := fmt.Sprintf("[CreateWalletForUser] Error: Could not create wallet for user %s", userStr)
errmsg := fmt.Sprintf("[CreateWalletForTelegramUser] Error: Could not create wallet for user %s", userStr)
log.Errorln(errmsg)
return err
}
@@ -108,7 +109,7 @@ func (bot *TipBot) CreateWalletForUser(tbUser *tb.User) error {
if tx.Error != nil {
return tx.Error
}
log.Printf("[CreateWalletForUser] Wallet created for user %s. ", userStr)
log.Printf("[CreateWalletForTelegramUser] Wallet created for user %s. ", userStr)
return nil
}