Files
LightningTipBot/text.go
T
LightningTipBotandGitHub 3fe903bc51 Force start2 (#21)
* force-init only on / commands

* return statemet

* anytext handler in all commands

* comment

* warning

* get rid of init bot wallet error
2021-08-25 02:13:42 +02:00

36 lines
759 B
Go

package main
import (
"strings"
log "github.com/sirupsen/logrus"
"github.com/LightningTipBot/LightningTipBot/pkg/lightning"
tb "gopkg.in/tucnak/telebot.v2"
)
const (
initWalletMessage = "You don't have a wallet yet. Enter */start*"
)
func (bot TipBot) anyTextHandler(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 {
return
}
// check if user is in database, if not, initialize wallet
if !bot.UserHasWallet(m.Sender) {
bot.startHandler(m)
return
}
// could be an invoice
invoiceString := strings.ToLower(m.Text)
if lightning.IsInvoice(invoiceString) {
m.Text = "/pay " + invoiceString
bot.confirmPaymentHandler(m)
return
}
}