forked from kopykatA/lntxbot
/
commands.go
69 lines (59 loc) · 2.67 KB
/
commands.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"strings"
"github.com/docopt/docopt-go"
"github.com/kballard/go-shellquote"
)
func renderUsage() string {
return s.ServiceId + `
Usage:
c start
c decode <invoice>
c (receive | invoice | fund) <satoshis> [<description>...] [--preimage=<preimage>]
c (pay [now] | paynow | withdraw) [<invoice>] [<satoshis>]
c (send | tip) <satoshis> [<receiver>...] [--anonymous]
c balance
c transactions [--page=<page>]
c giveaway <satoshis>
c coinflip <satoshis> [<num_participants>]
c fundraise <satoshis> <num_participants> <receiver>...
c help
c stop
c toggle spammy
Things to know:
- ` + "`/send` or `/tip`" + ` can send funds to any Telegram user, he'll be able to claim the funds once he registers with ` + "`/start`" + `;
- To send funds to users without username, use the autocomplete prompt Telegram gives you when you start typing "@" and their name: ` + "`/send 500 @autocomplete-here`" + `;
- Replying to a message with ` + "`/tip <satoshis>`" + ` will send that amount to the messge author (the bot must be added to the group for this to work).
- ` + "`/pay now` or `/paynow`" + ` will skip the payment confirmation;
- ` + "`/giveaway`" + ` will create a button in a chat and the first user to click that button will claim the satoshis you're giving away;
- ` + "`/stop`" + ` will make you stop receiving notifications from the bot, but you'll not lose your account. You can call ` + "`/start`" + ` to receive notifications again.
- ` + "`/toggle spammy`" + ` will make the bot send messages in a group when satoshis are sent there (the default behavior is to send messages to the parties involved privately) (in a supergroup it must be issued by an admin).
Plus:
- Forward any message containing an invoice to this chat to pay it (after confirmation);
- In a group, reply to a message containing an invoice with ` + "`/pay`, `/pay now` or `/paynow`" + ` to pay it;
- Take a picture of a QR code to pay it (after confirmation);
- Inline bot actions: you can do stuff in groups and private chats without having to add the bot!
a. ` + "`@" + s.ServiceId + " invoice <amount>`" + ` to generate an invoice in place,
b. ` + "`@" + s.ServiceId + " giveaway <amount>`" + ` to start a giveaway anywhere.
`
}
var parser = docopt.Parser{
HelpHandler: func(_ error, _ string) {},
OptionsFirst: false,
SkipHelpFlags: true,
}
func parse(message string) (opts docopt.Opts, isCommand bool, err error) {
if strings.HasPrefix(message, "/") {
isCommand = true
message = message[1:]
} else {
return
}
var argv []string
argv, err = shellquote.Split(message)
if err != nil {
return
}
opts, err = parser.ParseArgs(s.Usage, argv, "")
return
}