Compare commits

..
Author SHA1 Message Date
gohumble 21f5dfe60c trim whitespaces in send handler 2022-10-20 09:35:51 +02:00
2 changed files with 12 additions and 2 deletions
-1
View File
@@ -3,7 +3,6 @@
</p>
# @LightningTipBot 🏅
[![Twitter](https://img.shields.io/twitter/follow/LightningTipB0t.svg?style=social)](https://twitter.com/intent/follow?screen_name=LightningTipB0t)
A Telegram Lightning ⚡️ Bitcoin wallet and tip bot for group chats.
+12 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"regexp"
"strings"
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
@@ -85,13 +86,23 @@ func (bot *TipBot) sendHandler(ctx intercept.Context) (intercept.Context, error)
amount, err := decodeAmountFromCommand(ctx.Text())
// info: /send 10 <user> DEMANDS an amount, while /send <ln@address.com> also works without
// todo: /send <user> should also invoke amount input dialog if no amount is given
if err != nil {
return ctx, err
}
// CHECK whether first or second argument is a LIGHTNING ADDRESS
arg := ""
space := regexp.MustCompile(`\s+`)
ctx.Message().Text = space.ReplaceAllString(ctx.Message().Text, " ")
if len(strings.Split(ctx.Message().Text, " ")) > 2 {
arg, err = getArgumentFromCommand(ctx.Message().Text, 2)
if err != nil {
return ctx, err
}
} else if len(strings.Split(ctx.Message().Text, " ")) == 2 {
arg, err = getArgumentFromCommand(ctx.Message().Text, 1)
if err != nil {
return ctx, err
}
}
if err == nil {
if lightning.IsLightningAddress(arg) {