Skip to content

Commit

Permalink
hotfix new user creation (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
LightningTipBot authored Aug 23, 2021
1 parent e2017ec commit 827bfb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strings"

"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
log "github.com/sirupsen/logrus"

tb "gopkg.in/tucnak/telebot.v2"
Expand Down Expand Up @@ -94,21 +95,21 @@ 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
}
tx := bot.database.Save(user)
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
}

Expand Down

0 comments on commit 827bfb1

Please sign in to comment.