Compare commits

...
2 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
6 changed files with 48 additions and 25 deletions
+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...
+7 -7
View File
@@ -6,13 +6,13 @@ import (
)
const (
helpMessage = "ℹ️ *Info*\n_This bot is a Lightning Bitcoin wallet and can sends tips on Telegram. Simply add it to your group. 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" +
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.\n"
@@ -26,13 +26,13 @@ const (
"📲 *Lightning Wallets*\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) {
+23 -7
View File
@@ -12,18 +12,34 @@ 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 {
@@ -32,7 +48,7 @@ func (bot TipBot) invoiceHandler(m *tb.Message) {
return
}
if len(strings.Split(m.Text, " ")) < 2 {
bot.telegram.Send(m.Sender, helpInvoiceUsage(""))
bot.telegram.Send(m.Sender, helpInvoiceUsage(invoiceEnterAmountMessage))
return
}
@@ -44,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
}
+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" +
+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) {
+4 -4
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" +
@@ -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)))