-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathhelp.go
132 lines (119 loc) · 6.32 KB
/
help.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package main
import (
"fmt"
tb "gopkg.in/tucnak/telebot.v2"
)
const (
helpMessage = "⚡️ *Wallet*\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. Type 📚 /basics for more._\n\n" +
"❤️ *Donate*\n" +
"_This bot charges no fees but costs satoshis to operate. If you like the bot, please consider supporting this project with a donation. To donate, use_ `/donate 1000`\n\n" +
"%s" +
"⚙️ *Commands*\n" +
"*/tip* 🏅 Reply to a message to tip: `/tip <amount> [<memo>]`\n" +
"*/balance* 👑 Check your balance: `/balance`\n" +
"*/send* 💸 Send funds to a user: `/send <amount> @user or [email protected] [<memo>]`\n" +
"*/invoice* ⚡️ Receive with Lightning: `/invoice <amount> [<memo>]`\n" +
"*/pay* ⚡️ Pay with Lightning: `/pay <invoice>`\n" +
"*/donate* ❤️ Donate to the project: `/donate 1000`\n" +
"*/advanced* 🤖 Advanced features.\n" +
"*/help* 📖 Read this help."
infoMessage = "🧡 *Bitcoin*\n" +
"_Bitcoin is the currency of the internet. It is permissionless and decentralized and has no masters and no controling authority. Bitcoin is sound money that is faster, more secure, and more inclusive than the legacy financial system._\n\n" +
"🧮 *Economnics*\n" +
"_The smallest unit of Bitcoin are Satoshis (sat) and 100,000,000 sat = 1 Bitcoin. There will only ever be 21 Million Bitcoin. The fiat currency value of Bitcoin can change daily. However, if you live on a Bitcoin standard 1 sat will always equal 1 sat._\n\n" +
"⚡️ *The Lightning Network*\n" +
"_The Lightning Network is a payment protocol that enables fast and cheap Bitcoin payments that require almost no energy. It is what scales Bitcoin to the billions of people around the world._\n\n" +
"📲 *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._\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. We will act in your best interest but we're also aware that the situation without KYC is tricky until we figure something out. Any amount you load onto your wallet will be considered a donation. 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 costs satoshis to operate. If you like the bot, please consider supporting this project with a donation. To donate, use_ `/donate 1000`"
helpNoUsernameMessage = "ℹ️ Please set a Telegram username."
advancedMessage = "%s\n\n" +
"👉 *Inline commands*\n" +
"*send* 💸 Send sats to chat: `%s send <amount> [<memo>]`\n" +
"*receive* 🏅 Request a payment: `%s receive <amount> [<memo>]`\n" +
"*faucet* 🚰 Create a faucet: `%s faucet <capacity> <per_user>`\n\n" +
"📖 You can use inline commands in every chat, even in private conversations. Wait a second after entering an inline command and *click* the result, don't press enter.\n\n" +
"⚙️ *Advanced commands*\n" +
"*/link* 🔗 Link your wallet to [BlueWallet](https://bluewallet.io/) or [Zeus](https://zeusln.app/)\n" +
"*/lnurl* ⚡️ Lnurl receive or pay: `/lnurl` or `/lnurl <lnurl>`\n" +
"*/faucet* 🚰 Create a faucet `/faucet <capacity> <per_user>`"
)
func (bot TipBot) makeHelpMessage(m *tb.Message) string {
dynamicHelpMessage := ""
// user has no username set
if len(m.Sender.Username) == 0 {
// return fmt.Sprintf(helpMessage, fmt.Sprintf("%s\n\n", helpNoUsernameMessage))
dynamicHelpMessage = dynamicHelpMessage + fmt.Sprintf("%s\n", helpNoUsernameMessage)
} else {
dynamicHelpMessage = "ℹ️ *Info*\n"
lnaddr, err := bot.UserGetLightningAddress(m.Sender)
if err != nil {
dynamicHelpMessage = ""
} else {
dynamicHelpMessage = dynamicHelpMessage + fmt.Sprintf("Your Lightning Address is `%s`\n", lnaddr)
}
}
dynamicHelpMessage = dynamicHelpMessage + "\n"
return fmt.Sprintf(helpMessage, dynamicHelpMessage)
}
func (bot TipBot) helpHandler(m *tb.Message) {
// check and print all commands
bot.anyTextHandler(m)
if !m.Private() {
// delete message
NewMessage(m, WithDuration(0, bot.telegram))
}
bot.trySendMessage(m.Sender, bot.makeHelpMessage(m), tb.NoPreview)
return
}
func (bot TipBot) basicsHandler(m *tb.Message) {
// check and print all commands
bot.anyTextHandler(m)
if !m.Private() {
// delete message
NewMessage(m, WithDuration(0, bot.telegram))
}
bot.trySendMessage(m.Sender, infoMessage, tb.NoPreview)
return
}
func (bot TipBot) makeadvancedHelpMessage(m *tb.Message) string {
dynamicHelpMessage := ""
// user has no username set
if len(m.Sender.Username) == 0 {
// return fmt.Sprintf(helpMessage, fmt.Sprintf("%s\n\n", helpNoUsernameMessage))
dynamicHelpMessage = dynamicHelpMessage + fmt.Sprintf("%s", helpNoUsernameMessage)
} else {
dynamicHelpMessage = "ℹ️ *Info*\n"
lnaddr, err := bot.UserGetLightningAddress(m.Sender)
if err != nil {
dynamicHelpMessage = ""
} else {
dynamicHelpMessage = dynamicHelpMessage + fmt.Sprintf("Your Lightning Address:\n`%s`\n", lnaddr)
}
lnurl, err := bot.UserGetLNURL(m.Sender)
if err != nil {
dynamicHelpMessage = ""
} else {
dynamicHelpMessage = dynamicHelpMessage + fmt.Sprintf("Your LNURL:\n`%s`", lnurl)
}
}
// this is so stupid:
return fmt.Sprintf(advancedMessage, dynamicHelpMessage, GetUserStrMd(bot.telegram.Me), GetUserStrMd(bot.telegram.Me), GetUserStrMd(bot.telegram.Me))
}
func (bot TipBot) advancedHelpHandler(m *tb.Message) {
// check and print all commands
bot.anyTextHandler(m)
if !m.Private() {
// delete message
NewMessage(m, WithDuration(0, bot.telegram))
}
bot.trySendMessage(m.Sender, bot.makeadvancedHelpMessage(m), tb.NoPreview)
return
}