Compare commits
145
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9edc5c63d7 | ||
|
|
84fe1d7cc2 | ||
|
|
0efc5c4e43 | ||
|
|
9e64dbb2fd | ||
|
|
058278046f | ||
|
|
998967c81e | ||
|
|
1a21a1519f | ||
|
|
c47038fa1c | ||
|
|
2c76764421 | ||
|
|
b0e43f17f0 | ||
|
|
120d7c4419 | ||
|
|
73d87fc4bb | ||
|
|
2f61a96e87 | ||
|
|
3112b79c0d | ||
|
|
b50270fe0a | ||
|
|
8598adb280 | ||
|
|
74e9f7aabf | ||
|
|
8b32e5fda5 | ||
|
|
d264650207 | ||
|
|
c611969feb | ||
|
|
01f4cff348 | ||
|
|
a67ec62054 | ||
|
|
895fd06a14 | ||
|
|
ed5ceeb095 | ||
|
|
bc8c8f952a | ||
|
|
64055db1a5 | ||
|
|
ec679d5e6b | ||
|
|
9e8958ece2 | ||
|
|
7a2aba59ff | ||
|
|
62d7dd965e | ||
|
|
32a5863b25 | ||
|
|
45931c087a | ||
|
|
c561ae24d3 | ||
|
|
d5ff4867c0 | ||
|
|
1f5a6a5a31 | ||
|
|
e8f24d99ee | ||
|
|
b9bf071de9 | ||
|
|
ced9446287 | ||
|
|
94ed7d4692 | ||
|
|
d3c2fe7117 | ||
|
|
5c950ef1be | ||
|
|
51ac159072 | ||
|
|
857649150d | ||
|
|
842a037029 | ||
|
|
5aa76f86da | ||
|
|
e170394eb8 | ||
|
|
65842b056d | ||
|
|
979d3c58a2 | ||
|
|
b4cb695e33 | ||
|
|
89552a73b7 | ||
|
|
d5f18a0d3a | ||
|
|
e24490b05c | ||
|
|
f288bb05f6 | ||
|
|
3055f6d317 | ||
|
|
f19a6dd6cc | ||
|
|
cd55ee075b | ||
|
|
9d3f856d02 | ||
|
|
f2b59140fa | ||
|
|
c21d42d1e8 | ||
|
|
2dd2dde231 | ||
|
|
5e3432fe32 | ||
|
|
c6df59e51b | ||
|
|
b4081df2fa | ||
|
|
9b9ceb8793 | ||
|
|
3069126971 | ||
|
|
b56f5e73b0 | ||
|
|
42efc918c1 | ||
|
|
8c75f2f947 | ||
|
|
7d9c0d0c8a | ||
|
|
b77f92c9b2 | ||
|
|
ec2de611e4 | ||
|
|
1b69313fc5 | ||
|
|
55fc5eaa54 | ||
|
|
6bc6ef215a | ||
|
|
52ac3bfc13 | ||
|
|
fea7281e29 | ||
|
|
d992d5858f | ||
|
|
2569f0d12e | ||
|
|
6bdd24e4a3 | ||
|
|
3c862d59ff | ||
|
|
2c4d499cd9 | ||
|
|
2e4a793c20 | ||
|
|
890448ce81 | ||
|
|
08d6a0e369 | ||
|
|
069029fbb3 | ||
|
|
92f9ba1550 | ||
|
|
98bc70fc7c | ||
|
|
1ee38a2989 | ||
|
|
3353bedc7a | ||
|
|
30c1e3231d | ||
|
|
a3ed8ab931 | ||
|
|
3772f056a8 | ||
|
|
65d933a6d5 | ||
|
|
4038a03184 | ||
|
|
2c8a653c3a | ||
|
|
03509adcd1 | ||
|
|
74655219f3 | ||
|
|
74c057ce8e | ||
|
|
0aeec7e488 | ||
|
|
921395d283 | ||
|
|
9b2c23cab5 | ||
|
|
3c45a80627 | ||
|
|
62c2cbab5f | ||
|
|
ab82b49ff5 | ||
|
|
025261d595 | ||
|
|
ed6ea4d33c | ||
|
|
69559f8aff | ||
|
|
00406553e4 | ||
|
|
c237e55a29 | ||
|
|
24b2c2413c | ||
|
|
cb19e7375a | ||
|
|
55ba146592 | ||
|
|
52230d486e | ||
|
|
c8e45de27d | ||
|
|
6a01936c2e | ||
|
|
48374ad2a1 | ||
|
|
5b5f0ef6a2 | ||
|
|
b618b1aa41 | ||
|
|
c5f106187f | ||
|
|
f35473b010 | ||
|
|
359ae13057 | ||
|
|
8d0bf2cce7 | ||
|
|
f5c3d9fb55 | ||
|
|
56c391b24e | ||
|
|
cbdc8638bd | ||
|
|
046baab3e1 | ||
|
|
f0f3a7c5d0 | ||
|
|
43eb4966bc | ||
|
|
0d112e19de | ||
|
|
649be03c29 | ||
|
|
5e4c045312 | ||
|
|
44f397e2de | ||
|
|
9451032552 | ||
|
|
8180d3cfae | ||
|
|
f11ac3d807 | ||
|
|
cb02fd557f | ||
|
|
ac3ac51d7b | ||
|
|
ac9cc644eb | ||
|
|
545898dbbe | ||
|
|
d98aa26db9 | ||
|
|
13c0f3b70a | ||
|
|
3a4f99314d | ||
|
|
a0f7cf09e6 | ||
|
|
0ff0d889ff | ||
|
|
7009d3dedc |
@@ -18,7 +18,7 @@ To build the bot from source, clone the repository and compile the source code.
|
||||
git clone https://github.com/LightningTipBot/LightningTipBot.git
|
||||
cd LightningTipBot
|
||||
go build .
|
||||
cp config.yaml-example config.yaml
|
||||
cp config.yaml.example config.yaml
|
||||
```
|
||||
|
||||
After the configuration (see below), start it using the command
|
||||
@@ -58,7 +58,7 @@ You can either use your own LNbits instance (recommended) or create an account a
|
||||
- `lnbits_webhook_server`: URL that lnbits can reach the bot with. This is used for creating webhooks from LNbits to receive notifications about payments (optional).
|
||||
- `message_dispose_duration`: Duration in seconds after which `/tip` are deleted from a channel (only if the bot is channel admin).
|
||||
- `http_proxy` uses a proxy for all LNURL-related outbound requests (optional).
|
||||
- `lnurl_public_host_name` is the public URL of your lnbits/LndHub (for BlueWallet/Zap support, optional).
|
||||
- `lnurl_public_host_name` is the public URL of your lnbits/LndHub (for BlueWallet/Zeus support, optional).
|
||||
- `lnurl_server` is the public URL for inbound LNURL payments and your lightning address host (optional).
|
||||
|
||||
## Features
|
||||
@@ -116,7 +116,7 @@ Users can send and receive via . For this to work, you need to set the `lnurl_pu
|
||||
|
||||
Every user has a [Lightning Address](https://lightningaddress.com/) a la `username@host.com` with which they can send to via `/send <amount> <user@domain.com>` and receive from other wallets.
|
||||
|
||||
### Link to BlueWallet or Zap
|
||||
### Link to BlueWallet or Zeus
|
||||
|
||||
Every user can link their wallet to an external app like [Bluewallet](https://bluewallet.io/) or [Zeus](https://zeusln.app/) by using the command `/link`. If you host the bot, you will have to enable the LndHub extension in LNbits. You also need to edit the `lnbits_public_url` entry in `config.yaml` accordingly to an address that can be reached by the user's wallet (Tor should be fine as well).
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ bot:
|
||||
lnurl_public_host_name: "mylnurl.com"
|
||||
lnurl_server: "https://mylnurl.com"
|
||||
lnurl_image: true
|
||||
admin_api_host: localhost:6060
|
||||
telegram:
|
||||
message_dispose_duration: 10
|
||||
api_key: "1234"
|
||||
@@ -24,3 +25,8 @@ database:
|
||||
transactions_path: "data/transactions.db"
|
||||
shop_buntdb_path: "data/shop.db"
|
||||
groupsdb_path: "data/groups.db"
|
||||
generate:
|
||||
open_ai_bearer_token: "token_here"
|
||||
dalle_key: "asd"
|
||||
dalle_price: 1000
|
||||
worker: 2
|
||||
@@ -0,0 +1 @@
|
||||
this is where dalle images are stored
|
||||
@@ -5,9 +5,10 @@ go 1.17
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/PullRequestInc/go-gpt3 v1.1.10
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0
|
||||
github.com/eko/gocache v1.2.0
|
||||
github.com/fiatjaf/go-lnurl v1.11.2
|
||||
github.com/fiatjaf/go-lnurl v1.11.3-0.20220819192234-5c5819dd0aa7
|
||||
github.com/fiatjaf/ln-decodepay v1.1.0
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/imroc/req v0.3.0
|
||||
@@ -17,6 +18,8 @@ require (
|
||||
github.com/nicksnyder/go-i18n/v2 v2.1.2
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/sirupsen/logrus v1.7.0
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/tidwall/buntdb v1.2.7
|
||||
@@ -25,7 +28,7 @@ require (
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
|
||||
golang.org/x/text v0.3.7
|
||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
|
||||
gopkg.in/lightningtipbot/telebot.v3 v3.0.0-20220326213923-f323bb71ac8e
|
||||
gopkg.in/lightningtipbot/telebot.v3 v3.0.0-20220828121412-0dea11ecc6dd
|
||||
gorm.io/driver/sqlite v1.1.4
|
||||
gorm.io/gorm v1.21.12
|
||||
)
|
||||
@@ -72,7 +75,7 @@ require (
|
||||
github.com/miekg/dns v1.1.43 // indirect
|
||||
github.com/nbd-wtf/ln-decodepay v1.5.1 // indirect
|
||||
github.com/pegasus-kv/thrift v0.13.0 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/tidwall/btree v0.6.1 // indirect
|
||||
github.com/tidwall/grect v0.1.3 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
@@ -83,13 +86,15 @@ require (
|
||||
go.opentelemetry.io/otel/metric v0.20.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
|
||||
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect
|
||||
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3 // indirect
|
||||
)
|
||||
|
||||
// replace gopkg.in/lightningtipbot/telebot.v2 => ../telebot
|
||||
// replace gopkg.in/lightningtipbot/telebot.v3 => ../telebot
|
||||
|
||||
@@ -46,6 +46,8 @@ github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0g
|
||||
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
|
||||
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/PullRequestInc/go-gpt3 v1.1.10 h1:Z2fYKq7oGrr4Cs0yDmuq25FYR4hgvCowIR9sENHmSZ0=
|
||||
github.com/PullRequestInc/go-gpt3 v1.1.10/go.mod h1:F9yzAy070LhkqHS2154/IH0HVj5xq5g83gLTj7xzyfw=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
@@ -250,8 +252,8 @@ github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGE
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fergusstrange/embedded-postgres v1.10.0 h1:YnwF6xAQYmKLAXXrrRx4rHDLih47YJwVPvg8jeKfdNg=
|
||||
github.com/fergusstrange/embedded-postgres v1.10.0/go.mod h1:a008U8/Rws5FtIOTGYDYa7beVWsT3qVKyqExqYYjL+c=
|
||||
github.com/fiatjaf/go-lnurl v1.11.2 h1:XyZS6Uuu/2ZbhkZjOm3W+FaFvRzRRTFel3aMoO6eDUE=
|
||||
github.com/fiatjaf/go-lnurl v1.11.2/go.mod h1:9PAgeVpZ5u6olV/dfkoyPSOJs3j4q0JIGLSbBbmMci8=
|
||||
github.com/fiatjaf/go-lnurl v1.11.3-0.20220819192234-5c5819dd0aa7 h1:0m0ph1FcZY7p89OpaXOUs8N44GhP7gE/98l+eWCNSkQ=
|
||||
github.com/fiatjaf/go-lnurl v1.11.3-0.20220819192234-5c5819dd0aa7/go.mod h1:KJfs14iAY3gCgt/3T6fxfBvPhU67OfIp7PSrBg/v/R8=
|
||||
github.com/fiatjaf/ln-decodepay v1.1.0 h1:HigjqNH+ApiO6gm7RV23jXNFuvwq+zgsWl4BJAfPWwE=
|
||||
github.com/fiatjaf/ln-decodepay v1.1.0/go.mod h1:2qdTT95b8Z4dfuxiZxXuJ1M7bQ9CrLieEA1DKC50q6s=
|
||||
github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c=
|
||||
@@ -261,6 +263,8 @@ github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
github.com/frankban/quicktest v1.2.2/go.mod h1:Qh/WofXFeiAFII1aEBu529AtJo6Zg2VHscnEsbBnJ20=
|
||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
@@ -360,8 +364,9 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
@@ -493,6 +498,8 @@ github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
|
||||
github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI=
|
||||
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
@@ -567,8 +574,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
@@ -655,6 +663,7 @@ github.com/mattn/go-sqlite3 v1.14.5 h1:1IdxlwTNazvbKJQSxoJ5/9ECbEeaTTyeU7sEAZ5KK
|
||||
github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.3/go.mod h1:1ftk08SazyElaaNvmqAfZWGwJzshjCfBXDLoQtPAMNk=
|
||||
github.com/mholt/archiver/v3 v3.5.0 h1:nE8gZIrw66cu4osS/U7UW7YDuGMHssxKutU8IfWxwWE=
|
||||
github.com/mholt/archiver/v3 v3.5.0/go.mod h1:qqTTPUK/HZPFgFQ/TJ3BzvTpF/dPtFVJXdQbCmeMxwc=
|
||||
github.com/miekg/dns v0.0.0-20171125082028-79bfde677fa8/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
@@ -706,6 +715,7 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v
|
||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
@@ -716,6 +726,7 @@ github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.5 h1:7n6FEkpFmfCoo2t+YYqXH0evK+a9ICQz0xcAy9dYcaQ=
|
||||
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
||||
@@ -788,18 +799,25 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
|
||||
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc h1:zAsgcP8MhzAbhMnB1QQ2O7ZhWYVGYSR2iVcjzQuPV+o=
|
||||
github.com/r3labs/sse v0.0.0-20210224172625-26fe804710bc/go.mod h1:S8xSOnV3CgpNrWd0GQ/OoQfMtlg2uPRSuTzcSGrzwK8=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
|
||||
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
@@ -823,8 +841,9 @@ github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJ
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
@@ -1064,6 +1083,7 @@ golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191105084925-a882066a44e0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -1104,8 +1124,9 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc=
|
||||
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -1127,6 +1148,7 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -1243,6 +1265,7 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200301222351-066e0c02454c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
@@ -1366,6 +1389,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y=
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -1382,8 +1407,8 @@ gopkg.in/httprequest.v1 v1.1.1/go.mod h1:/CkavNL+g3qLOrpFHVrEx4NKepeqR4XTZWNj4sG
|
||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/lightningtipbot/telebot.v3 v3.0.0-20220326213923-f323bb71ac8e h1:x58PfjVq6dbYSzM4URM9QfKDKVru1CpngxCM5pGqwbk=
|
||||
gopkg.in/lightningtipbot/telebot.v3 v3.0.0-20220326213923-f323bb71ac8e/go.mod h1:kIC/Dlp2OjWhVrOkZDN4iEoCaqoac5w1UjpKY6Ftf+U=
|
||||
gopkg.in/lightningtipbot/telebot.v3 v3.0.0-20220828121412-0dea11ecc6dd h1:LI1Q9RRmTKusLTpLGAHFUVT+wgzc0GHFKd3+34fARE8=
|
||||
gopkg.in/lightningtipbot/telebot.v3 v3.0.0-20220828121412-0dea11ecc6dd/go.mod h1:BefN0q4hcqXE1jXo4mTXZ9+29zl7IGsoSFXEQF455Oc=
|
||||
gopkg.in/macaroon-bakery.v2 v2.0.1/go.mod h1:B4/T17l+ZWGwxFSZQmlBwp25x+og7OkhETfr3S9MbIA=
|
||||
gopkg.in/macaroon.v2 v2.0.0/go.mod h1:+I6LnTMkm/uV5ew/0nsulNjL16SK4+C8yDmRUzHR17I=
|
||||
gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/dalle"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (s Service) DisableDalle(w http.ResponseWriter, r *http.Request) {
|
||||
dalle.Enabled = false
|
||||
}
|
||||
|
||||
func (s Service) EnableDalle(w http.ResponseWriter, r *http.Request) {
|
||||
dalle.Enabled = true
|
||||
}
|
||||
@@ -2,12 +2,15 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/r3labs/sse"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
@@ -119,3 +122,66 @@ func (s Service) InvoiceStatus(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(payment)
|
||||
}
|
||||
|
||||
type InvoiceStream struct {
|
||||
CheckingID string `json:"checking_id"`
|
||||
Pending bool `json:"pending"`
|
||||
Amount int `json:"amount"`
|
||||
Fee int `json:"fee"`
|
||||
Memo string `json:"memo"`
|
||||
Time int `json:"time"`
|
||||
Bolt11 string `json:"bolt11"`
|
||||
Preimage string `json:"preimage"`
|
||||
PaymentHash string `json:"payment_hash"`
|
||||
Extra struct {
|
||||
} `json:"extra"`
|
||||
WalletID string `json:"wallet_id"`
|
||||
Webhook string `json:"webhook"`
|
||||
WebhookStatus interface{} `json:"webhook_status"`
|
||||
}
|
||||
|
||||
func (s Service) InvoiceStream(w http.ResponseWriter, r *http.Request) {
|
||||
user := telegram.LoadUser(r.Context())
|
||||
flusher, ok := w.(http.Flusher)
|
||||
if !ok {
|
||||
http.Error(w, "Streaming unsupported!", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
client := sse.NewClient(fmt.Sprintf("%s/api/v1/payments/sse", internal.Configuration.Lnbits.Url))
|
||||
client.Connection.Transport = &http.Transport{DisableCompression: true}
|
||||
client.Headers = map[string]string{"X-Api-Key": user.Wallet.Inkey}
|
||||
c := make(chan *sse.Event)
|
||||
err := client.SubscribeChan("", c)
|
||||
if err != nil {
|
||||
http.Error(w, "Streaming unsupported!", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
out:
|
||||
for {
|
||||
select {
|
||||
case msg := <-c:
|
||||
select {
|
||||
case <-r.Context().Done():
|
||||
client.Unsubscribe(c)
|
||||
break out
|
||||
default:
|
||||
written, err := fmt.Fprintf(w, "event: %s\n", string(msg.Event))
|
||||
if err != nil || written == 0 {
|
||||
break out
|
||||
}
|
||||
written, err = fmt.Fprintf(w, "data: %s\n", string(msg.Data))
|
||||
if err != nil || written == 0 {
|
||||
break out
|
||||
}
|
||||
written, err = fmt.Fprint(w, "\n")
|
||||
if err != nil || written == 0 {
|
||||
break out
|
||||
}
|
||||
flusher.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
close(c)
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
+36
-18
@@ -30,15 +30,29 @@ type AuthType struct {
|
||||
}
|
||||
|
||||
var AuthTypeBasic = AuthType{Type: "Basic"}
|
||||
var AuthTypeBearerBase64 = AuthType{Type: "Basic", Decoder: base64.StdEncoding.DecodeString}
|
||||
var AuthTypeBearerBase64 = AuthType{Type: "Bearer", Decoder: base64.StdEncoding.DecodeString}
|
||||
var AuthTypeNone = AuthType{}
|
||||
|
||||
func AuthorizationMiddleware(database *gorm.DB, authType AuthType, next http.HandlerFunc) http.HandlerFunc {
|
||||
// invoice key or admin key requirement
|
||||
type AccessKeyType struct {
|
||||
Type string
|
||||
}
|
||||
|
||||
var AccessKeyTypeInvoice = AccessKeyType{Type: "invoice"}
|
||||
var AccessKeyTypeAdmin = AccessKeyType{Type: "admin"}
|
||||
var AccessKeyTypeNone = AccessKeyType{Type: "none"} // no authorization required
|
||||
|
||||
func AuthorizationMiddleware(database *gorm.DB, authType AuthType, accessType AccessKeyType, next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if accessType.Type == "none" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
auth := r.Header.Get("Authorization")
|
||||
// check if the user is banned
|
||||
if auth == "" {
|
||||
w.WriteHeader(401)
|
||||
log.Warn("[AuthorizationMiddleware] no auth")
|
||||
log.Warn("[api] no auth")
|
||||
return
|
||||
}
|
||||
_, password, ok := parseAuth(authType, auth)
|
||||
@@ -49,25 +63,29 @@ func AuthorizationMiddleware(database *gorm.DB, authType AuthType, next http.Han
|
||||
// first we make sure that the password is not already "banned_"
|
||||
if strings.Contains(password, "_") || strings.HasPrefix(password, "banned_") {
|
||||
w.WriteHeader(401)
|
||||
log.Warnf("[AuthorizationMiddleware] Banned user %s. Not forwarding request", password)
|
||||
log.Warnf("[api] Banned user %s. Not forwarding request", password)
|
||||
return
|
||||
}
|
||||
// then we check whether the "normal" password provided is in the database (it should be not if the user is banned)
|
||||
|
||||
user := &lnbits.User{}
|
||||
tx := database.Where("wallet_adminkey = ? COLLATE NOCASE", password).First(user)
|
||||
if tx.Error != nil {
|
||||
tx = database.Where("wallet_inkey = ? COLLATE NOCASE", password).First(user)
|
||||
log.Warnf("[AuthorizationMiddleware] Could not get wallet admin key %s: %v", password, tx.Error)
|
||||
if tx.Error != nil {
|
||||
log.Warnf("[AuthorizationMiddleware] need admin key to pay invoice %s: %v", password, tx.Error)
|
||||
return
|
||||
}
|
||||
if r.URL.Path == "/api/v1/payinvoice" {
|
||||
log.Warnf("[AuthorizationMiddleware] need admin key to pay invoice %s: %v", password, tx.Error)
|
||||
return
|
||||
}
|
||||
var tx *gorm.DB
|
||||
if accessType.Type == "admin" {
|
||||
tx = database.Where("wallet_adminkey = ? COLLATE NOCASE", password).First(user)
|
||||
} else if accessType.Type == "invoice" {
|
||||
tx = database.Where("wallet_inkey = ? OR wallet_adminkey = ? COLLATE NOCASE", password, password).First(user)
|
||||
} else {
|
||||
log.Errorf("[api] route without access type")
|
||||
w.WriteHeader(401)
|
||||
return
|
||||
}
|
||||
log.Debugf("[AuthorizationMiddleware] User: %s", telegram.GetUserStr(user.Telegram))
|
||||
if tx.Error != nil {
|
||||
log.Warnf("[api] could not load access key: %v", tx.Error)
|
||||
w.WriteHeader(401)
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("[api] User: %s Endpoint: %s %s %s", telegram.GetUserStr(user.Telegram), r.Method, r.URL.Path, r.URL.RawQuery)
|
||||
r = r.WithContext(context.WithValue(r.Context(), "user", user))
|
||||
next.ServeHTTP(w, r)
|
||||
}
|
||||
@@ -82,7 +100,7 @@ func parseAuth(authType AuthType, auth string) (username, password string, ok bo
|
||||
return
|
||||
}
|
||||
if authType.Decoder != nil {
|
||||
c, err := base64.StdEncoding.DecodeString(auth[len(prefix):])
|
||||
c, err := authType.Decoder(auth[len(prefix):])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -24,8 +25,8 @@ func NewServer(address string) *Server {
|
||||
srv := &http.Server{
|
||||
Addr: address,
|
||||
// Good practice: enforce timeouts for servers you create!
|
||||
WriteTimeout: 15 * time.Second,
|
||||
ReadTimeout: 15 * time.Second,
|
||||
WriteTimeout: 90 * time.Second,
|
||||
ReadTimeout: 90 * time.Second,
|
||||
}
|
||||
apiServer := &Server{
|
||||
httpServer: srv,
|
||||
@@ -33,7 +34,7 @@ func NewServer(address string) *Server {
|
||||
apiServer.router = mux.NewRouter()
|
||||
apiServer.httpServer.Handler = apiServer.router
|
||||
go apiServer.httpServer.ListenAndServe()
|
||||
log.Infof("[API] Server started at %s", address)
|
||||
log.Infof("[api] Server started at %s", address)
|
||||
return apiServer
|
||||
}
|
||||
|
||||
@@ -43,8 +44,8 @@ func (w *Server) ListenAndServe() {
|
||||
func (w *Server) PathPrefix(path string, handler http.Handler) {
|
||||
w.router.PathPrefix(path).Handler(handler)
|
||||
}
|
||||
func (w *Server) AppendAuthorizedRoute(path string, authType AuthType, database *gorm.DB, handler func(http.ResponseWriter, *http.Request), methods ...string) {
|
||||
r := w.router.HandleFunc(path, LoggingMiddleware("API", AuthorizationMiddleware(database, authType, handler)))
|
||||
func (w *Server) AppendAuthorizedRoute(path string, authType AuthType, accessType AccessKeyType, database *gorm.DB, handler func(http.ResponseWriter, *http.Request), methods ...string) {
|
||||
r := w.router.HandleFunc(path, LoggingMiddleware("API", AuthorizationMiddleware(database, authType, accessType, handler)))
|
||||
if len(methods) > 0 {
|
||||
r.Methods(methods...)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,387 @@
|
||||
<!-- @format -->
|
||||
|
||||
{{define "webapp"}}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="MobileOptimized" content="176" />
|
||||
<meta name="HandheldFriendly" content="True" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
|
||||
<title>@LightningTipBot</title>
|
||||
<script src="https://unpkg.com/kjua@0.6.0/dist/kjua.min.js"></script>
|
||||
<script src="https://telegram.org/js/telegram-web-app.js?1"></script>
|
||||
<script>
|
||||
function setThemeClass() {
|
||||
document.documentElement.className = Telegram.WebApp.colorScheme;
|
||||
}
|
||||
Telegram.WebApp.onEvent('themeChanged', setThemeClass);
|
||||
setThemeClass();
|
||||
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
background-color: var(--tg-theme-bg-color, #ffffff);
|
||||
color: var(--tg-theme-text-color, #222222);
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color-scheme: var(--tg-color-scheme);
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--tg-theme-link-color, #2678b6);
|
||||
}
|
||||
|
||||
button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
border: none;
|
||||
background-color: var(--tg-theme-button-color, #50a8eb);
|
||||
color: var(--tg-theme-button-text-color, #ffffff);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--tg-theme-button-color, #50a8eb);
|
||||
color: var(--tg-theme-button-text-color, #ffffff);
|
||||
}
|
||||
|
||||
button[disabled] {
|
||||
opacity: 0.6;
|
||||
cursor: auto;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
input {
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
border: none;
|
||||
background-color: var(--tg-theme-bg-color, #f5f5f5) !important;
|
||||
color: var(--tg-theme-text-color, #1a1a1a) !important;
|
||||
}
|
||||
|
||||
.input-group-text {
|
||||
background-color: var(--tg-theme-bg-color, #f5f5f5) !important;
|
||||
color: var(--tg-theme-text-color, #1a1a1a) !important;
|
||||
}
|
||||
|
||||
section {
|
||||
padding: 5px 5px 65px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 40px 0 15px;
|
||||
}
|
||||
|
||||
ul {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
li {
|
||||
color: var(--tg-theme-hint-color, #a8a8a8);
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background: rgba(0, 0, 0, .07);
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
margin: 7px 0;
|
||||
word-break: break-all;
|
||||
word-break: break-word;
|
||||
white-space: pre-wrap;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.dark pre {
|
||||
background: rgba(255, 255, 255, .15);
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: .8em;
|
||||
color: var(--tg-theme-hint-color, #a8a8a8);
|
||||
}
|
||||
|
||||
.ok {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.err {
|
||||
color: red;
|
||||
}
|
||||
|
||||
#fixed_wrap {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
transform: translateY(100vh);
|
||||
}
|
||||
|
||||
.viewport_border,
|
||||
.viewport_stable_border {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
height: var(--tg-viewport-height, 100vh);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.viewport_stable_border {
|
||||
height: var(--tg-viewport-stable-height, 100vh);
|
||||
}
|
||||
|
||||
.viewport_border:before,
|
||||
.viewport_stable_border:before {
|
||||
content: attr(text);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
background: gray;
|
||||
right: 0;
|
||||
top: 0;
|
||||
font-size: 7px;
|
||||
padding: 2px 4px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.viewport_stable_border:before {
|
||||
background: green;
|
||||
left: 0;
|
||||
right: auto;
|
||||
}
|
||||
|
||||
.viewport_border:after,
|
||||
.viewport_stable_border:after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
border: 2px dashed gray;
|
||||
}
|
||||
|
||||
.viewport_stable_border:after {
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 120%;
|
||||
word-wrap: break-word;
|
||||
margin: 0.5em;
|
||||
}
|
||||
|
||||
.qr-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.qr {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 0px;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.qr > canvas {
|
||||
max-height: 800px;
|
||||
max-width: 800px;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
display: grid;
|
||||
grid-template-columns: 3fr 2fr;
|
||||
padding: 12px 20px;
|
||||
column-gap: 10px;
|
||||
row-gap: 1em;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<section>
|
||||
<h1 id="greeting"></h1>
|
||||
|
||||
<div class="qr-container">
|
||||
<div class="qr" id="qr">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="buttons">
|
||||
<!-- <button onclick="webviewClose();">Close</button> -->
|
||||
<div class="wrapper">
|
||||
<label class="sr-only" for="inlineFormInputGroup">Username</label>
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control" min="1" inputmode="numeric" pattern="[0-9]*" id="invoiceAmount" placeholder="amount">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text" id="inputCurrency"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-primary" onclick="invoiceButtonClick();" style="display: inline;" id="requestInvoice">Invoice</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script type="application/javascript">
|
||||
Telegram.WebApp.ready();
|
||||
|
||||
// render the LNURL pay QR code
|
||||
var s = "{{.LNURLPay}}";
|
||||
const currencies = ["sat", "USD", "EUR"];
|
||||
var currency_idx = 0;
|
||||
document.getElementById("inputCurrency").innerHTML = currencies[0];
|
||||
|
||||
renderQr(s);
|
||||
|
||||
// data passed form telegram server
|
||||
const initData = Telegram.WebApp.initData || '';
|
||||
const initDataUnsafe = Telegram.WebApp.initDataUnsafe || {};
|
||||
|
||||
document.querySelector('#greeting').innerHTML = "{{.Username}}@ln.tips";
|
||||
// document.querySelector('#initData').innerHTML = JSON.stringify(initData, null, 2);
|
||||
// document.querySelector('#initDataUnsafe').innerHTML = JSON.stringify(initDataUnsafe, null, 2);
|
||||
|
||||
// react to theme changes
|
||||
try {
|
||||
document.querySelector('#themeData').html(JSON.stringify(Telegram.WebApp.themeParams, null, 2));
|
||||
Telegram.WebApp.onEvent('themeChanged', function() {
|
||||
document.querySelector('#themeData').innerHTML = JSON.stringify(Telegram.WebApp.themeParams, null, 2);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
|
||||
// listen for enter in input field
|
||||
var el = document.getElementById("invoiceAmount");
|
||||
el.addEventListener("keydown", function(event) {
|
||||
if (event.key === "Enter") {
|
||||
document.getElementById("requestInvoice").click();
|
||||
}
|
||||
document.getElementById("requestInvoice").innerHTML = "Invoice"
|
||||
// revert color of button
|
||||
$('#requestInvoice').removeClass('btn-danger').addClass('btn-primary');
|
||||
});
|
||||
|
||||
var el = document.getElementById("inputCurrency");
|
||||
el.addEventListener("click", function(event) {
|
||||
currency_idx += 1;
|
||||
$(this).html(currencies[currency_idx%(currencies.length)]);
|
||||
$('#requestInvoice').removeClass('btn-danger').addClass('btn-primary');
|
||||
});
|
||||
|
||||
// ------------------ functions ------------------
|
||||
|
||||
function invoiceButtonClick() {
|
||||
var c = "{{.Callback}}";
|
||||
getInvoice(this, c);
|
||||
// hide keyboard and scroll up
|
||||
document.getElementById("invoiceAmount").blur();
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
function invoiceButtonDisplayError(message) {
|
||||
btn = document.getElementById("requestInvoice")
|
||||
btn.innerHTML = message
|
||||
// update color of button
|
||||
$('#requestInvoice').removeClass('btn-primary').addClass('btn-danger');
|
||||
}
|
||||
|
||||
function webviewClose() {
|
||||
Telegram.WebApp.close();
|
||||
}
|
||||
|
||||
function renderQr(payload) {
|
||||
const qr = document.getElementById('qr');
|
||||
qr.innerHTML = '';
|
||||
if ( qr ) {
|
||||
const qrGfx = kjua({
|
||||
text: payload,
|
||||
rounded: 50,
|
||||
size: 500,
|
||||
render: 'canvas',
|
||||
});
|
||||
qr.appendChild( qrGfx );
|
||||
// var href_link = "lightning:" + payload;
|
||||
// qr.setAttribute('href', "javascript:window.open('"+ href_link+ "');" );
|
||||
}
|
||||
}
|
||||
|
||||
function getInvoice(el, callback) {
|
||||
curr_idx = currency_idx%currencies.length
|
||||
var invoiceAmount = Number(document.getElementById("invoiceAmount").value);
|
||||
if ((currencies[curr_idx] == "sat" && !Number.isInteger(invoiceAmount)) || invoiceAmount < 1) {
|
||||
invoiceButtonDisplayError("Invalid")
|
||||
return false;
|
||||
}
|
||||
var amountQueryParam;
|
||||
if (currencies[curr_idx] == "sat") {
|
||||
amountQueryParam = invoiceAmount * 1000 // sat to msat
|
||||
} else {
|
||||
amountQueryParam = invoiceAmount + currencies[curr_idx]
|
||||
}
|
||||
fetch(callback)
|
||||
.then(data => {
|
||||
return data.json();
|
||||
})
|
||||
.then(r => {
|
||||
console.log(r);
|
||||
console.log("requesting invoice with amount " + amountQueryParam);
|
||||
fetch(r.callback + '?amount='+ amountQueryParam).then(data => {
|
||||
return data.json();
|
||||
})
|
||||
.then(r => {
|
||||
console.log(r);
|
||||
if (r.status == "OK"){
|
||||
// update qr code
|
||||
renderQr(r.pr);
|
||||
document.querySelector('#greeting').innerHTML = "Pay " + invoiceAmount + " " + currencies[curr_idx];
|
||||
} else {
|
||||
invoiceButtonDisplayError("Error")
|
||||
return false;
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
{{end}}
|
||||
@@ -31,7 +31,8 @@ const botImage = "https://avatars.githubusercontent.com/u/88730856?v=7"
|
||||
|
||||
//go:embed static
|
||||
var templates embed.FS
|
||||
var tmpl = template.Must(template.ParseFS(templates, "static/userpage.html"))
|
||||
var userpage_tmpl = template.Must(template.ParseFS(templates, "static/userpage.html"))
|
||||
var qr_tmpl = template.Must(template.ParseFS(templates, "static/webapp.html"))
|
||||
|
||||
var Client = &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
@@ -67,7 +68,7 @@ func (s Service) getTelegramUserPictureURL(username string) (string, error) {
|
||||
}
|
||||
|
||||
func (s Service) UserPageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// https://ln.tips/.well-known/lnurlp/<username>
|
||||
// https://ln.tips/@<username>
|
||||
username := strings.ToLower(mux.Vars(r)["username"])
|
||||
callback := fmt.Sprintf("%s/.well-known/lnurlp/%s", internal.Configuration.Bot.LNURLHostName, username)
|
||||
log.Infof("[UserPage] rendering page of %s", username)
|
||||
@@ -82,7 +83,7 @@ func (s Service) UserPageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
image = botImage
|
||||
}
|
||||
|
||||
if err := tmpl.ExecuteTemplate(w, "userpage", struct {
|
||||
if err := userpage_tmpl.ExecuteTemplate(w, "userpage", struct {
|
||||
Username string
|
||||
Image string
|
||||
LNURLPay string
|
||||
@@ -90,3 +91,22 @@ func (s Service) UserPageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Errorf("failed to render template")
|
||||
}
|
||||
}
|
||||
|
||||
func (s Service) UserWebAppHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// https://ln.tips/app/<username>
|
||||
username := strings.ToLower(mux.Vars(r)["username"])
|
||||
callback := fmt.Sprintf("%s/.well-known/lnurlp/%s", internal.Configuration.Bot.LNURLHostName, username)
|
||||
log.Infof("[UserPage] rendering webapp of %s", username)
|
||||
lnurlEncode, err := lnurl.LNURLEncode(callback)
|
||||
if err != nil {
|
||||
log.Errorln("[UserPage]", err)
|
||||
return
|
||||
}
|
||||
if err := qr_tmpl.ExecuteTemplate(w, "webapp", struct {
|
||||
Username string
|
||||
LNURLPay string
|
||||
Callback string
|
||||
}{username, lnurlEncode, callback}); err != nil {
|
||||
log.Errorf("failed to render template")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,16 @@ var Configuration = struct {
|
||||
Telegram TelegramConfiguration `yaml:"telegram"`
|
||||
Database DatabaseConfiguration `yaml:"database"`
|
||||
Lnbits LnbitsConfiguration `yaml:"lnbits"`
|
||||
Generate GenerateConfiguration `yaml:"generate"`
|
||||
}{}
|
||||
|
||||
type GenerateConfiguration struct {
|
||||
OpenAiBearerToken string `yaml:"open_ai_bearer_token"`
|
||||
DalleKey string `yaml:"dalle_key"`
|
||||
DallePrice int64 `yaml:"dalle_price"`
|
||||
Worker int `yaml:"worker"`
|
||||
}
|
||||
|
||||
type SocksConfiguration struct {
|
||||
Host string `yaml:"host"`
|
||||
Username string `yaml:"username"`
|
||||
@@ -30,6 +38,7 @@ type BotConfiguration struct {
|
||||
LNURLHostName string `yaml:"lnurl_public_host_name"`
|
||||
LNURLHostUrl *url.URL `yaml:"-"`
|
||||
LNURLSendImage bool `yaml:"lnurl_image"`
|
||||
AdminAPIHost string `yaml:"admin_api_host"`
|
||||
}
|
||||
|
||||
type TelegramConfiguration struct {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package dalle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
"io"
|
||||
)
|
||||
|
||||
var Enabled bool
|
||||
|
||||
func init() {
|
||||
if internal.Configuration.Generate.DalleKey != "" {
|
||||
Enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
type Client interface {
|
||||
Generate(ctx context.Context, prompt string) (*Task, error)
|
||||
ListTasks(ctx context.Context, req *ListTasksRequest) (*ListTasksResponse, error)
|
||||
GetTask(ctx context.Context, taskID string) (*Task, error)
|
||||
Download(ctx context.Context, generationID string) (io.ReadCloser, error)
|
||||
Share(ctx context.Context, generationID string) (string, error)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package dalle
|
||||
|
||||
const (
|
||||
StatusPending = "pending"
|
||||
StatusRejected = "rejected"
|
||||
StatusSucceeded = "succeeded"
|
||||
|
||||
TaskTypeText2Im = "text2im"
|
||||
|
||||
defaultBatchSize = 4
|
||||
)
|
||||
@@ -0,0 +1,242 @@
|
||||
package dalle
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
libraryVersion = "1.0.0"
|
||||
defaultUserAgent = "dalle/" + libraryVersion
|
||||
baseURL = "https://labs.openai.com/api/labs"
|
||||
|
||||
defaultHTTPClientTimeout = 15 * time.Second
|
||||
)
|
||||
|
||||
type option func(*HTTPClient) error
|
||||
|
||||
func WithHTTPClient(httpClient *http.Client) option {
|
||||
return func(c *HTTPClient) error {
|
||||
c.httpClient = httpClient
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func WithUserAgent(userAgent string) option {
|
||||
return func(c *HTTPClient) error {
|
||||
c.userAgent = userAgent
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
type HTTPClient struct {
|
||||
httpClient *http.Client
|
||||
userAgent string
|
||||
apiKey string
|
||||
}
|
||||
|
||||
var _ Client = (*HTTPClient)(nil)
|
||||
|
||||
func NewHTTPClient(apiKey string, opts ...option) (*HTTPClient, error) {
|
||||
c := &HTTPClient{
|
||||
httpClient: &http.Client{Timeout: defaultHTTPClientTimeout},
|
||||
userAgent: defaultUserAgent,
|
||||
apiKey: apiKey,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
if err := opt(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
Object string `json:"object"`
|
||||
ID string `json:"id"`
|
||||
Created int64 `json:"created"`
|
||||
TaskType string `json:"task_type"`
|
||||
Status string `json:"status"`
|
||||
PromptID string `json:"prompt_id"`
|
||||
Prompt Prompt `json:"prompt"`
|
||||
Generations Generations `json:"generations"`
|
||||
}
|
||||
type Generations struct {
|
||||
Data []GenerationData `json:"data"`
|
||||
Object string `json:"object"`
|
||||
}
|
||||
type GenerationData struct {
|
||||
Created int64 `json:"created"`
|
||||
Generation Generation `json:"generation"`
|
||||
GenerationType string `json:"generation_type"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
type Generation struct {
|
||||
ImagePath string `json:"image_path"`
|
||||
}
|
||||
|
||||
type Prompt struct {
|
||||
ID string `json:"id"`
|
||||
Object string `json:"object"`
|
||||
Created int64 `json:"created"`
|
||||
PromptType string `json:"prompt_type"`
|
||||
Prompt struct {
|
||||
Caption string `json:"caption"`
|
||||
} `json:"prompt"`
|
||||
ParentGenerationID string `json:"parent_generation_id"`
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
Prompt GenerateRequestPrompt `json:"prompt"`
|
||||
TaskType string `json:"task_type"`
|
||||
}
|
||||
type GenerateRequestPrompt struct {
|
||||
BatchSize int32 `json:"batch_size"`
|
||||
Caption string `json:"caption"`
|
||||
}
|
||||
|
||||
func (c *HTTPClient) Generate(ctx context.Context, caption string) (*Task, error) {
|
||||
task := &Task{}
|
||||
req := &GenerateRequest{
|
||||
Prompt: GenerateRequestPrompt{
|
||||
BatchSize: defaultBatchSize,
|
||||
Caption: caption,
|
||||
},
|
||||
TaskType: TaskTypeText2Im,
|
||||
}
|
||||
return task, c.request(ctx, "POST", "/tasks", nil, req, task)
|
||||
}
|
||||
|
||||
type ListTasksResponse struct {
|
||||
Object string `json:"object"`
|
||||
Data []Task `json:"data"`
|
||||
}
|
||||
|
||||
type ListTasksRequest struct {
|
||||
Limit int32 `json:"limit"`
|
||||
}
|
||||
|
||||
func (c *HTTPClient) ListTasks(ctx context.Context, req *ListTasksRequest) (*ListTasksResponse, error) {
|
||||
res := &ListTasksResponse{}
|
||||
url := "/tasks"
|
||||
if req != nil {
|
||||
if req.Limit != 0 {
|
||||
url += fmt.Sprintf("?limit=%d", req.Limit)
|
||||
}
|
||||
}
|
||||
|
||||
return res, c.request(ctx, "GET", url, nil, nil, res)
|
||||
}
|
||||
|
||||
func (c *HTTPClient) GetTask(ctx context.Context, taskID string) (*Task, error) {
|
||||
task := &Task{}
|
||||
return task, c.request(ctx, "GET", "/tasks/"+taskID, nil, nil, task)
|
||||
}
|
||||
|
||||
func (c *HTTPClient) Download(ctx context.Context, generationID string) (io.ReadCloser, error) {
|
||||
req, err := c.createRequest(ctx, "/generations/"+generationID+"/download", "GET", nil, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("creating request: %w", err)
|
||||
}
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("performing request: %w", err)
|
||||
}
|
||||
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
// Share makes the generation public and returns the public url
|
||||
func (c *HTTPClient) Share(ctx context.Context, generationID string) (string, error) {
|
||||
res := &GenerationData{}
|
||||
|
||||
err := c.request(ctx, "POST", "/generations/"+generationID+"/share", nil, nil, res)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return res.Generation.ImagePath, nil
|
||||
}
|
||||
|
||||
func (c *HTTPClient) createRequest(ctx context.Context, path, method string, values *url.Values, data interface{}) (*http.Request, error) {
|
||||
url := baseURL + path
|
||||
|
||||
if values != nil {
|
||||
url += "?" + values.Encode()
|
||||
}
|
||||
|
||||
var body io.Reader
|
||||
if data != nil {
|
||||
b, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing request data: %w", err)
|
||||
}
|
||||
body = bytes.NewReader(b)
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, method, url, body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("building request: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Add("Authorization", "Bearer "+c.apiKey)
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Set("User-Agent", c.userAgent)
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (c *HTTPClient) request(ctx context.Context, method, path string, values *url.Values, body interface{}, result interface{}) error {
|
||||
req, err := c.createRequest(ctx, path, method, values, body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating request: %w", err)
|
||||
}
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("performing request: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
|
||||
// TODO: improve error handling...
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return Error{
|
||||
Message: "unexpected non 200 status code",
|
||||
StatusCode: resp.StatusCode,
|
||||
Details: string(respBody),
|
||||
}
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(respBody, result); err != nil {
|
||||
return Error{
|
||||
Message: err.Error(),
|
||||
StatusCode: resp.StatusCode,
|
||||
Details: string(respBody),
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
Message string
|
||||
StatusCode int
|
||||
Details string
|
||||
}
|
||||
|
||||
func (e Error) Error() string {
|
||||
return fmt.Sprintf("dalle: %s (status: %d, details: %s)", e.Message, e.StatusCode, e.Details)
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package gpt
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
Message struct {
|
||||
ID string `json:"id"`
|
||||
Role string `json:"role"`
|
||||
User interface{} `json:"user"`
|
||||
CreateTime interface{} `json:"create_time"`
|
||||
UpdateTime interface{} `json:"update_time"`
|
||||
Content struct {
|
||||
ContentType string `json:"content_type"`
|
||||
Parts []string `json:"parts"`
|
||||
} `json:"content"`
|
||||
EndTurn interface{} `json:"end_turn"`
|
||||
Weight float64 `json:"weight"`
|
||||
Metadata struct {
|
||||
} `json:"metadata"`
|
||||
Recipient string `json:"recipient"`
|
||||
} `json:"message"`
|
||||
ConversationID string `json:"conversation_id"`
|
||||
Error interface{} `json:"error"`
|
||||
}
|
||||
type Request struct {
|
||||
Action string `json:"action"`
|
||||
ConversationId string `json:"conversation_id,omitempty"`
|
||||
Messages []Messages `json:"messages"`
|
||||
ParentMessageID string `json:"parent_message_id"`
|
||||
Model string `json:"model"`
|
||||
}
|
||||
type Content struct {
|
||||
ContentType string `json:"content_type"`
|
||||
Parts []string `json:"parts"`
|
||||
}
|
||||
type Messages struct {
|
||||
ID string `json:"id"`
|
||||
Role string `json:"role"`
|
||||
Content Content `json:"content"`
|
||||
}
|
||||
|
||||
var dataPrefix = []byte("data: ")
|
||||
var doneSequence = []byte("[DONE]")
|
||||
|
||||
func GetRawCompletion(ctx intercept.Context, rr Request, cb func(s string)) (*Response, error) {
|
||||
rawClient := http.Client{}
|
||||
r, err := json.Marshal(rr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx.Context, "POST", "https://chat.openai.com/backend-api/conversation", bytes.NewBuffer(r))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", internal.Configuration.Generate.OpenAiBearerToken))
|
||||
req.Header.Set("accept", "text/event-stream")
|
||||
req.Header.Set("authority", "chat.openai.com")
|
||||
req.Header.Set("accept-language", "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7")
|
||||
req.Header.Set("Content-type", "application/json")
|
||||
req.Header.Set("user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36")
|
||||
|
||||
resp, err := rawClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reader := bufio.NewReader(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
output := new(Response)
|
||||
for {
|
||||
line, err := reader.ReadBytes('\n')
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// make sure there isn't any extra whitespace before or after
|
||||
line = bytes.TrimSpace(line)
|
||||
// the completion API only returns data events
|
||||
if !bytes.HasPrefix(line, dataPrefix) {
|
||||
continue
|
||||
}
|
||||
line = bytes.TrimPrefix(line, dataPrefix)
|
||||
|
||||
// the stream is completed when terminated by [DONE]
|
||||
if bytes.HasPrefix(line, doneSequence) {
|
||||
break
|
||||
}
|
||||
if err := json.Unmarshal(line, output); err != nil {
|
||||
return nil, fmt.Errorf("invalid json stream data: %v", err)
|
||||
}
|
||||
if len(output.Message.Content.Parts) > 0 {
|
||||
cb(output.Message.Content.Parts[len(output.Message.Content.Parts)-1])
|
||||
}
|
||||
}
|
||||
return output, nil
|
||||
}
|
||||
@@ -21,9 +21,11 @@ func RegisterLanguages() *i18n.Bundle {
|
||||
bundle.LoadMessageFile("translations/it.toml")
|
||||
bundle.LoadMessageFile("translations/es.toml")
|
||||
bundle.LoadMessageFile("translations/nl.toml")
|
||||
bundle.LoadMessageFile("translations/pl.toml")
|
||||
bundle.LoadMessageFile("translations/fr.toml")
|
||||
bundle.LoadMessageFile("translations/pt-br.toml")
|
||||
bundle.LoadMessageFile("translations/tr.toml")
|
||||
bundle.LoadMessageFile("translations/cs.toml")
|
||||
bundle.LoadMessageFile("translations/id.toml")
|
||||
bundle.LoadMessageFile("translations/ru.toml")
|
||||
return bundle
|
||||
|
||||
@@ -65,6 +65,7 @@ const (
|
||||
UserStateShopItemSendPrice
|
||||
UserStateShopItemSendItemFile
|
||||
UserEnterShopsDescription
|
||||
UserEnterDallePrompt
|
||||
)
|
||||
|
||||
type UserStateKey int
|
||||
|
||||
@@ -113,7 +113,7 @@ func (w *Server) receive(writer http.ResponseWriter, request *http.Request) {
|
||||
log.Errorln(err)
|
||||
return
|
||||
}
|
||||
c.Function(txInvoiceEvent)
|
||||
go c.Function(txInvoiceEvent)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package lndhub
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/api"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -21,48 +17,5 @@ func New(bot *telegram.TipBot) LndHub {
|
||||
return LndHub{database: bot.DB.Users}
|
||||
}
|
||||
func (w LndHub) Handle(writer http.ResponseWriter, request *http.Request) {
|
||||
auth := request.Header.Get("Authorization")
|
||||
|
||||
// check if the user is banned
|
||||
if auth != "" {
|
||||
_, password, ok := parseBearerAuth(auth)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
// first we make sure that the password is not already "banned_"
|
||||
if strings.Contains(password, "_") || strings.HasPrefix(password, "banned_") {
|
||||
log.Warnf("[LNDHUB] Banned user %s. Not forwarding request", password)
|
||||
return
|
||||
}
|
||||
// then we check whether the "normal" password provided is in the database (it should be not if the user is banned)
|
||||
user := &lnbits.User{}
|
||||
tx := w.database.Where("wallet_adminkey = ? COLLATE NOCASE", password).First(user)
|
||||
if tx.Error != nil {
|
||||
log.Warnf("[LNDHUB] Could not get wallet admin key %s: %v", password, tx.Error)
|
||||
return
|
||||
}
|
||||
log.Debugf("[LNDHUB] User: %s", telegram.GetUserStr(user.Telegram))
|
||||
}
|
||||
// if not, proxy the request
|
||||
api.Proxy(writer, request, internal.Configuration.Lnbits.Url)
|
||||
}
|
||||
|
||||
// parseBearerAuth parses an HTTP Basic Authentication string.
|
||||
// "Bearer QWxhZGRpbjpvcGVuIHNlc2FtZQ==" returns ("Aladdin", "open sesame", true).
|
||||
func parseBearerAuth(auth string) (username, password string, ok bool) {
|
||||
const prefix = "Bearer "
|
||||
// Case insensitive prefix match. See Issue 22736.
|
||||
if len(auth) < len(prefix) || !strings.EqualFold(auth[:len(prefix)], prefix) {
|
||||
return
|
||||
}
|
||||
c, err := base64.StdEncoding.DecodeString(auth[len(prefix):])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cs := string(c)
|
||||
s := strings.IndexByte(cs, ':')
|
||||
if s < 0 {
|
||||
return
|
||||
}
|
||||
return cs[:s], cs[s+1:], true
|
||||
}
|
||||
|
||||
+16
-8
@@ -81,11 +81,19 @@ func (w Lnurl) Handle(writer http.ResponseWriter, request *http.Request) {
|
||||
api.NotFoundHandler(writer, fmt.Errorf("[handleLnUrl] Form value 'amount' is not set"))
|
||||
return
|
||||
}
|
||||
amount, parseError := strconv.Atoi(stringAmount)
|
||||
if parseError != nil {
|
||||
api.NotFoundHandler(writer, fmt.Errorf("[handleLnUrl] Couldn't cast amount to int %v", parseError))
|
||||
return
|
||||
|
||||
var amount int64
|
||||
if amount, err = strconv.ParseInt(stringAmount, 10, 64); err != nil {
|
||||
// if the value wasn't a clean msat denomination, parse it
|
||||
amount, err = telegram.GetAmount(stringAmount)
|
||||
if err != nil {
|
||||
api.NotFoundHandler(writer, fmt.Errorf("[handleLnUrl] Couldn't cast amount to int: %v", err))
|
||||
return
|
||||
}
|
||||
// GetAmount returns sat, we need msat
|
||||
amount *= 1000
|
||||
}
|
||||
|
||||
comment := request.FormValue("comment")
|
||||
if len(comment) > CommentAllowed {
|
||||
api.NotFoundHandler(writer, fmt.Errorf("[handleLnUrl] Comment is too long"))
|
||||
@@ -95,11 +103,11 @@ func (w Lnurl) Handle(writer http.ResponseWriter, request *http.Request) {
|
||||
// payer data
|
||||
payerdata := request.FormValue("payerdata")
|
||||
var payerData lnurl.PayerDataValues
|
||||
err := json.Unmarshal([]byte(payerdata), &payerData)
|
||||
err = json.Unmarshal([]byte(payerdata), &payerData)
|
||||
if err != nil {
|
||||
// api.NotFoundHandler(writer, fmt.Errorf("[handleLnUrl] Couldn't parse payerdata: %v", err))
|
||||
fmt.Errorf("[handleLnUrl] Couldn't parse payerdata: %v", err)
|
||||
fmt.Errorf("[handleLnUrl] payerdata: %v", payerdata)
|
||||
log.Errorf("[handleLnUrl] Couldn't parse payerdata: %v", err)
|
||||
// log.Errorf("[handleLnUrl] payerdata: %v", payerdata)
|
||||
}
|
||||
|
||||
response, err = w.serveLNURLpSecond(username, int64(amount), comment, payerData)
|
||||
@@ -184,7 +192,7 @@ func (w Lnurl) serveLNURLpSecond(username string, amount_msat int64, comment str
|
||||
return &lnurl.LNURLPayValues{
|
||||
LNURLResponse: lnurl.LNURLResponse{
|
||||
Status: api.StatusError,
|
||||
Reason: fmt.Sprintf("Amount out of bounds (min: %d mSat, max: %d mSat).", MinSendable, MinSendable)},
|
||||
Reason: fmt.Sprintf("Amount out of bounds (min: %d sat, max: %d sat).", MinSendable/1000, MaxSendable/1000)},
|
||||
}, fmt.Errorf("amount out of bounds")
|
||||
}
|
||||
// check comment length
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
@@ -20,6 +21,23 @@ const (
|
||||
ClientTypeTor = "tor"
|
||||
)
|
||||
|
||||
// checks if strings contains http(s)://*.onion
|
||||
var isOnion = regexp.MustCompile("^https?\\:\\/\\/[\\w\\-\\.]+\\.onion")
|
||||
|
||||
// GetClientForScheme returns correct client for url scheme.
|
||||
// if tld is .onion, function will also return an onion client.
|
||||
func GetClientForScheme(url *url.URL) (*http.Client, error) {
|
||||
if isOnion.FindString(url.String()) != "" {
|
||||
return GetClient(ClientTypeTor)
|
||||
}
|
||||
switch url.Scheme {
|
||||
case "onion":
|
||||
return GetClient(ClientTypeTor)
|
||||
default:
|
||||
return GetClient(ClientTypeClearNet)
|
||||
}
|
||||
}
|
||||
|
||||
func GetClient(clientType ClientType) (*http.Client, error) {
|
||||
client := http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
@@ -36,6 +54,9 @@ func GetClient(clientType ClientType) (*http.Client, error) {
|
||||
if cfg == nil {
|
||||
return &client, nil
|
||||
}
|
||||
if cfg.Host == "" {
|
||||
return &client, nil
|
||||
}
|
||||
proxyURL, _ := url.Parse(cfg.Host)
|
||||
specialTransport := &http.Transport{}
|
||||
specialTransport.Proxy = http.ProxyURL(proxyURL)
|
||||
|
||||
@@ -2,10 +2,11 @@ package rate
|
||||
|
||||
import (
|
||||
"context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
tb "gopkg.in/lightningtipbot/telebot.v3"
|
||||
)
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/errors"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/runtime/mutex"
|
||||
@@ -34,11 +35,13 @@ func decodeAmountFromCommand(input string) (amount int64, err error) {
|
||||
// log.Errorln(errmsg)
|
||||
return 0, fmt.Errorf(errmsg)
|
||||
}
|
||||
amount, err = getAmount(strings.Split(input, " ")[1])
|
||||
amount, err = GetAmount(strings.Split(input, " ")[1])
|
||||
return amount, err
|
||||
}
|
||||
|
||||
func getAmount(input string) (amount int64, err error) {
|
||||
// GetAmount parses an amount from a string like 1.2k or 3.50€
|
||||
// and returns the value in satoshis
|
||||
func GetAmount(input string) (amount int64, err error) {
|
||||
// convert something like 1.2k into 1200
|
||||
if strings.HasSuffix(strings.ToLower(input), "k") {
|
||||
fmount, err := strconv.ParseFloat(strings.TrimSpace(input[:len(input)-1]), 64)
|
||||
@@ -140,7 +143,7 @@ func (bot *TipBot) enterAmountHandler(ctx intercept.Context) (intercept.Context,
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
amount, err := getAmount(ctx.Message().Text)
|
||||
amount, err := GetAmount(ctx.Message().Text)
|
||||
if err != nil {
|
||||
log.Warnf("[enterAmountHandler] %s", err.Error())
|
||||
bot.trySendMessage(ctx.Message().Sender, Translate(ctx, "lnurlInvalidAmountMessage"))
|
||||
|
||||
@@ -2,6 +2,7 @@ package telegram
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/errors"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ func newTelegramBot() *tb.Bot {
|
||||
Token: internal.Configuration.Telegram.ApiKey,
|
||||
Poller: &tb.LongPoller{Timeout: 60 * time.Second},
|
||||
ParseMode: tb.ModeMarkdown,
|
||||
Verbose: false,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -3,7 +3,9 @@ package telegram
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
|
||||
log "github.com/sirupsen/logrus"
|
||||
tb "gopkg.in/lightningtipbot/telebot.v3"
|
||||
@@ -11,16 +13,24 @@ import (
|
||||
|
||||
// we can't use space in the label of buttons, because string splitting will mess everything up.
|
||||
const (
|
||||
MainMenuCommandSend = "💸 Send"
|
||||
// MainMenuCommandWebApp = "⤵️ Recv"
|
||||
// MainMenuCommandBalance = "Balance"
|
||||
// MainMenuCommandInvoice = "⚡️ Invoice"
|
||||
// MainMenuCommandHelp = "📖 Help"
|
||||
// MainMenuCommandSend = "⤴️ Send"
|
||||
// SendMenuCommandEnter = "👤 Enter"
|
||||
MainMenuCommandWebApp = "🗳️ App"
|
||||
MainMenuCommandBalance = "Balance"
|
||||
MainMenuCommandInvoice = "⚡️ Invoice"
|
||||
MainMenuCommandHelp = "📖 Help"
|
||||
MainMenuCommandSend = "⤴️"
|
||||
SendMenuCommandEnter = "👤 Enter"
|
||||
)
|
||||
|
||||
var (
|
||||
mainMenu = &tb.ReplyMarkup{ResizeKeyboard: true}
|
||||
btnHelpMainMenu = mainMenu.Text(MainMenuCommandHelp)
|
||||
btnWebAppMainMenu = mainMenu.Text(MainMenuCommandWebApp)
|
||||
btnSendMainMenu = mainMenu.Text(MainMenuCommandSend)
|
||||
btnBalanceMainMenu = mainMenu.Text(MainMenuCommandBalance)
|
||||
btnInvoiceMainMenu = mainMenu.Text(MainMenuCommandInvoice)
|
||||
@@ -31,9 +41,11 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
btnBalanceMainMenu = mainMenu.Text(MainMenuCommandBalance)
|
||||
mainMenu.Reply(
|
||||
mainMenu.Row(btnBalanceMainMenu),
|
||||
mainMenu.Row(btnInvoiceMainMenu, btnSendMainMenu, btnHelpMainMenu),
|
||||
// mainMenu.Row(btnInvoiceMainMenu, btnWebAppMainMenu, btnSendMainMenu, btnHelpMainMenu), // TODO: fix btnSendMainMenu
|
||||
mainMenu.Row(btnInvoiceMainMenu, btnWebAppMainMenu, btnHelpMainMenu),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -58,6 +70,21 @@ func buttonWrapper(buttons []tb.Btn, markup *tb.ReplyMarkup, length int) []tb.Ro
|
||||
return rows
|
||||
}
|
||||
|
||||
// appendWebAppLinkToButton adds a WebApp object to a Button with the user's webapp page
|
||||
func (bot *TipBot) appendWebAppLinkToButton(btn *tb.Btn, user *lnbits.User) {
|
||||
var url string
|
||||
if len(user.Telegram.Username) > 0 {
|
||||
url = fmt.Sprintf("%s/app/@%s", internal.Configuration.Bot.LNURLHostName, user.Telegram.Username)
|
||||
} else {
|
||||
url = fmt.Sprintf("%s/app/@%s", internal.Configuration.Bot.LNURLHostName, user.AnonIDSha256)
|
||||
}
|
||||
if strings.HasPrefix(url, "https://") {
|
||||
// prevent adding a link if not https is used, otherwise
|
||||
// Telegram returns an error and does not show the keyboard
|
||||
btn.WebApp = &tb.WebAppInfo{Url: url}
|
||||
}
|
||||
}
|
||||
|
||||
// mainMenuBalanceButtonUpdate updates the balance button in the mainMenu
|
||||
func (bot *TipBot) mainMenuBalanceButtonUpdate(to int64) {
|
||||
var user *lnbits.User
|
||||
@@ -75,11 +102,14 @@ func (bot *TipBot) mainMenuBalanceButtonUpdate(to int64) {
|
||||
log.Tracef("[appendMainMenu] user %s balance %d sat", GetUserStr(user.Telegram), amount)
|
||||
MainMenuCommandBalance := fmt.Sprintf("%s %d sat", MainMenuCommandBalance, amount)
|
||||
btnBalanceMainMenu = mainMenu.Text(MainMenuCommandBalance)
|
||||
mainMenu.Reply(
|
||||
mainMenu.Row(btnBalanceMainMenu),
|
||||
mainMenu.Row(btnInvoiceMainMenu, btnSendMainMenu, btnHelpMainMenu),
|
||||
)
|
||||
}
|
||||
|
||||
bot.appendWebAppLinkToButton(&btnWebAppMainMenu, user)
|
||||
mainMenu.Reply(
|
||||
mainMenu.Row(btnBalanceMainMenu),
|
||||
// mainMenu.Row(btnInvoiceMainMenu, btnWebAppMainMenu, btnSendMainMenu, btnHelpMainMenu), // TODO: fix btnSendMainMenu
|
||||
mainMenu.Row(btnInvoiceMainMenu, btnWebAppMainMenu, btnHelpMainMenu),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +128,7 @@ func (bot *TipBot) makeContactsButtons(ctx context.Context) []tb.Btn {
|
||||
// get all contacts and add them to the buttons
|
||||
for i, r := range records {
|
||||
log.Tracef("[makeContactsButtons] toNames[%d] = %s (id=%d)", i, r.ToUser, r.ID)
|
||||
sendToButtons = append(sendToButtons, tb.Btn{Text: fmt.Sprintf("%s", r.ToUser)})
|
||||
sendToButtons = append(sendToButtons, tb.Btn{Text: r.ToUser})
|
||||
}
|
||||
|
||||
// add the "enter a username" button to the end
|
||||
|
||||
@@ -3,12 +3,13 @@ package telegram
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/errors"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/str"
|
||||
|
||||
@@ -62,7 +62,7 @@ func (bot TipBot) createFaucet(ctx context.Context, text string, sender *tb.User
|
||||
if err != nil {
|
||||
return nil, errors.New(errors.DecodePerUserAmountError, err)
|
||||
}
|
||||
perUserAmount, err := getAmount(peruserStr)
|
||||
perUserAmount, err := GetAmount(peruserStr)
|
||||
if err != nil {
|
||||
return nil, errors.New(errors.InvalidAmountError, err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/dalle"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/runtime"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/skip2/go-qrcode"
|
||||
tb "gopkg.in/lightningtipbot/telebot.v3"
|
||||
)
|
||||
|
||||
// generateImages is called when the user enters /generate or /generate <prompt>
|
||||
// asks the user for a prompt if not given
|
||||
func (bot *TipBot) generateImages(ctx intercept.Context) (intercept.Context, error) {
|
||||
if !dalle.Enabled {
|
||||
bot.trySendMessage(ctx.Message().Sender, "🤖💤 Dalle image generation is currently not available. Please try again later.")
|
||||
return ctx, nil
|
||||
}
|
||||
bot.anyTextHandler(ctx)
|
||||
user := LoadUser(ctx)
|
||||
if user.Wallet == nil {
|
||||
return ctx, fmt.Errorf("user has no wallet")
|
||||
}
|
||||
|
||||
if len(strings.Split(ctx.Message().Text, " ")) < 2 {
|
||||
// We need to save the pay state in the user state so we can load the payment in the next handler
|
||||
SetUserState(user, bot, lnbits.UserEnterDallePrompt, "")
|
||||
bot.trySendMessage(ctx.Message().Sender, "⌨️ Enter image prompt.", tb.ForceReply)
|
||||
return ctx, nil
|
||||
}
|
||||
// write the prompt into the command and call confirm
|
||||
m := ctx.Message()
|
||||
m.Text = GetMemoFromCommand(m.Text, 1)
|
||||
return bot.confirmGenerateImages(ctx)
|
||||
}
|
||||
|
||||
// confirmGenerateImages is called when the user has entered a prompt through /generate <prompt>
|
||||
// or because he answered to the request to enter it in generateImages()
|
||||
// confirmGenerateImages will create an invoice that the user can pay and if they pay
|
||||
// generateDalleImages will fetch the images and send it to the user
|
||||
func (bot *TipBot) confirmGenerateImages(ctx intercept.Context) (intercept.Context, error) {
|
||||
user := LoadUser(ctx)
|
||||
|
||||
ResetUserState(user, bot)
|
||||
m := ctx.Message()
|
||||
prompt := m.Text
|
||||
if len(prompt) == 0 {
|
||||
return ctx, fmt.Errorf("prompt not given")
|
||||
}
|
||||
|
||||
if user.Wallet == nil {
|
||||
return ctx, fmt.Errorf("user has no wallet")
|
||||
}
|
||||
me, err := GetUser(bot.Telegram.Me, *bot)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
invoice, err := bot.createInvoiceWithEvent(ctx, me, internal.Configuration.Generate.DallePrice, fmt.Sprintf("DALLE2 %s", GetUserStr(user.Telegram)), InvoiceCallbackGenerateDalle, prompt)
|
||||
invoice.Payer = user
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
runtime.IgnoreError(bot.Bunt.Set(invoice))
|
||||
|
||||
balance, err := bot.GetUserBalance(user)
|
||||
if err != nil {
|
||||
errmsg := fmt.Sprintf("[inlineReceive] Error: Could not get user balance: %s", err.Error())
|
||||
log.Warnln(errmsg)
|
||||
}
|
||||
|
||||
bot.trySendMessage(ctx.Message().Sender, Translate(ctx, "generateDallePayInvoiceMessage"))
|
||||
|
||||
// invoke internal pay if enough balance
|
||||
if balance >= internal.Configuration.Generate.DallePrice {
|
||||
m.Text = fmt.Sprintf("/pay %s", invoice.PaymentRequest)
|
||||
return bot.payHandler(ctx)
|
||||
}
|
||||
|
||||
// create qr code
|
||||
qr, err := qrcode.Encode(invoice.PaymentRequest, qrcode.Medium, 256)
|
||||
if err != nil {
|
||||
bot.tryEditMessage(invoice.Message, Translate(ctx, "errorTryLaterMessage"))
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
// send the invoice data to user
|
||||
msg := bot.trySendMessage(ctx.Message().Sender, &tb.Photo{File: tb.File{FileReader: bytes.NewReader(qr)}, Caption: fmt.Sprintf("`%s`", invoice.PaymentRequest)})
|
||||
invoice.InvoiceMessage = msg
|
||||
runtime.IgnoreError(bot.Bunt.Set(invoice))
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
var jobChan chan func(workerId int)
|
||||
var workers = internal.Configuration.Generate.Worker
|
||||
|
||||
func init() {
|
||||
if workers == 0 {
|
||||
log.Printf("Dalle is disabled. No worker started.")
|
||||
return
|
||||
}
|
||||
log.Printf("Starting Dalle image generation. Worker: %d, Price: %d sat", workers, internal.Configuration.Generate.DallePrice)
|
||||
jobChan = make(chan func(workerId int), workers)
|
||||
for i := 0; i < workers; i++ {
|
||||
go worker(jobChan, i)
|
||||
}
|
||||
}
|
||||
func worker(linkChan chan func(workerId int), workerId int) {
|
||||
for generatePrompt := range linkChan {
|
||||
generatePrompt(workerId)
|
||||
}
|
||||
}
|
||||
|
||||
// generateDalleImages is called by the invoice event when the user has paid
|
||||
func (bot *TipBot) generateDalleImages(event Event) {
|
||||
invoiceEvent := event.(*InvoiceEvent)
|
||||
user := invoiceEvent.Payer
|
||||
if user == nil || user.Wallet == nil {
|
||||
log.Errorf("[generateDalleImages] invalid user")
|
||||
return
|
||||
}
|
||||
bot.trySendMessage(user.Telegram, "🔄 Your images are being generated. Please wait a few moments.")
|
||||
var job = func(workerId int) {
|
||||
// create the client with the bearer token api key
|
||||
dalleClient, err := dalle.NewHTTPClient(internal.Configuration.Generate.DalleKey)
|
||||
// handle err
|
||||
if err != nil {
|
||||
log.Errorf("[NewHTTPClient-%d] %v", workerId, err.Error())
|
||||
bot.dalleRefundUser(user, "")
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*15)
|
||||
defer cancel()
|
||||
// generate a task to create an image with a prompt
|
||||
task, err := dalleClient.Generate(ctx, invoiceEvent.CallbackData)
|
||||
if err != nil {
|
||||
log.Errorf("[Generate-%d] %v", workerId, err.Error())
|
||||
bot.dalleRefundUser(user, "")
|
||||
return
|
||||
}
|
||||
// poll the task.ID until status is succeeded
|
||||
var t *dalle.Task
|
||||
timeout := time.After(10 * time.Minute)
|
||||
ticker := time.Tick(5 * time.Second)
|
||||
// Keep trying until we're timed out or get a result/error
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
bot.dalleRefundUser(user, "")
|
||||
log.Errorf("[DALLE-%d] ctx done. Task %s", workerId, task.ID)
|
||||
return
|
||||
// Got a timeout! fail with a timeout error
|
||||
case <-timeout:
|
||||
bot.dalleRefundUser(user, "Timeout. Please try again later.")
|
||||
log.Errorf("[DALLE-%d] timeout. Task: %s", workerId, task.ID)
|
||||
return
|
||||
// Got a tick, we should check on checkSomething()
|
||||
case <-ticker:
|
||||
t, err = dalleClient.GetTask(ctx, task.ID)
|
||||
// handle err
|
||||
if err != nil {
|
||||
log.Errorf("[GetTask-%d] Task: %s. Error: %v", workerId, task.ID, err.Error())
|
||||
//bot.dalleRefundUser(user, "")
|
||||
continue
|
||||
}
|
||||
if t.Status == dalle.StatusSucceeded {
|
||||
log.Printf("[DALLE-%d] 🎆 task succeeded for user %s", workerId, GetUserStr(user.Telegram))
|
||||
// download the first generated image
|
||||
for _, data := range t.Generations.Data {
|
||||
err = bot.downloadAndSendImages(ctx, dalleClient, data, invoiceEvent)
|
||||
if err != nil {
|
||||
log.Errorf("[downloadAndSendImages-%d] Id: %s. Error: %v", workerId, data.ID, err.Error())
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
} else if t.Status == dalle.StatusRejected {
|
||||
log.Errorf("[DALLE-%d] rejected: %s", workerId, t.ID)
|
||||
bot.dalleRefundUser(user, "Your prompt has been rejected by OpenAI. Do not use celebrity names, sexual expressions, or any other harmful content as prompt.")
|
||||
return
|
||||
}
|
||||
log.Debugf("[DALLE-%d] pending for user %s", workerId, GetUserStr(user.Telegram))
|
||||
}
|
||||
}
|
||||
}
|
||||
jobChan <- job
|
||||
}
|
||||
|
||||
// downloadAndSendImages will download dalle images and send them to the payer.
|
||||
func (bot *TipBot) downloadAndSendImages(ctx context.Context, dalleClient dalle.Client, data dalle.GenerationData, event *InvoiceEvent) error {
|
||||
reader, err := dalleClient.Download(ctx, data.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer reader.Close()
|
||||
image := "data/dalle/" + data.ID + ".png"
|
||||
file, err := os.Create(image)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
_, err = io.Copy(file, reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := os.OpenFile(image, 0, os.ModePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
bot.trySendMessage(event.Payer.Telegram, &tb.Photo{File: tb.File{FileReader: f}})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bot *TipBot) dalleRefundUser(user *lnbits.User, message string) error {
|
||||
if user.Wallet == nil {
|
||||
return fmt.Errorf("user has no wallet")
|
||||
}
|
||||
me, err := GetUser(bot.Telegram.Me, *bot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create invioce for user
|
||||
invoice, err := user.Wallet.Invoice(
|
||||
lnbits.InvoiceParams{
|
||||
Out: false,
|
||||
Amount: int64(internal.Configuration.Generate.DallePrice),
|
||||
Memo: fmt.Sprintf("Refund DALLE2 %s", GetUserStr(user.Telegram)),
|
||||
Webhook: internal.Configuration.Lnbits.WebhookServer},
|
||||
bot.Client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// pay invoice
|
||||
_, err = me.Wallet.Pay(lnbits.PaymentParams{Out: true, Bolt11: invoice.PaymentRequest}, bot.Client)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return err
|
||||
}
|
||||
log.Warnf("[DALLE] refunding user %s with %d sat", GetUserStr(user.Telegram), internal.Configuration.Generate.DallePrice)
|
||||
|
||||
var err_reason string
|
||||
if len(message) > 0 {
|
||||
err_reason = message
|
||||
} else {
|
||||
err_reason = "Something went wrong."
|
||||
}
|
||||
bot.trySendMessage(user.Telegram, fmt.Sprintf("🚫 %s You have been refunded.", err_reason))
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/gpt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/lightningtipbot/telebot.v3"
|
||||
)
|
||||
|
||||
func (bot *TipBot) gptHandler(ctx intercept.Context) (intercept.Context, error) {
|
||||
question := GetMemoFromCommand(ctx.Text(), 1)
|
||||
req := gpt.Request{
|
||||
Action: "next",
|
||||
Model: "text-davinci-002-render",
|
||||
Messages: []gpt.Messages{{
|
||||
ID: uuid.NewV4().String(),
|
||||
Role: "user",
|
||||
Content: gpt.Content{
|
||||
ContentType: "text",
|
||||
Parts: []string{question},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
conversationIdCacheKey := fmt.Sprintf("conversation_%d", ctx.Chat().ID)
|
||||
parentIdCacheKey := fmt.Sprintf("conversation_parent_%d", ctx.Chat().ID)
|
||||
conversationId, _ := bot.Cache.Get(conversationIdCacheKey)
|
||||
|
||||
if parentId, _ := bot.Cache.Get(parentIdCacheKey); parentId != nil {
|
||||
req.ParentMessageID = parentId.(string)
|
||||
}
|
||||
if conversationId != nil {
|
||||
req.ConversationId = conversationId.(string)
|
||||
}
|
||||
cbc := 0
|
||||
var msg *telebot.Message
|
||||
completion, err := gpt.GetRawCompletion(ctx, req, func(s string) {
|
||||
cbc++
|
||||
if ctx.Chat().Type == telebot.ChatPrivate {
|
||||
if cbc == 20 {
|
||||
msg = bot.trySendMessageEditable(ctx.Sender(), s)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if cbc == 20 {
|
||||
msg = bot.tryReplyMessage(ctx.Message(), s)
|
||||
return
|
||||
}
|
||||
}
|
||||
if cbc%20 == 0 {
|
||||
bot.tryEditMessage(msg, s)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
bot.tryEditMessage(ctx.Message(), fmt.Sprintf(Translate(ctx, "errorReasonMessage"), "Could not create completion."))
|
||||
return ctx, err
|
||||
}
|
||||
answer := completion.Message.Content.Parts[len(completion.Message.Content.Parts)-1]
|
||||
bot.tryEditMessage(msg, answer)
|
||||
err = bot.Cache.Set(conversationIdCacheKey, completion.ConversationID, nil)
|
||||
if err != nil {
|
||||
log.Errorf("[/gpt] error setting conversation id %s: %v", conversationIdCacheKey, err)
|
||||
}
|
||||
err = bot.Cache.Set(parentIdCacheKey, completion.Message.ID, nil)
|
||||
if err != nil {
|
||||
log.Errorf("[/gpt] error setting parent message id %s: %v", parentIdCacheKey, err)
|
||||
}
|
||||
log.Infof("[/gpt] \"%s\" => \"%s\"", question, answer)
|
||||
return ctx, nil
|
||||
}
|
||||
@@ -31,13 +31,22 @@ type Ticket struct {
|
||||
CutCheap int64 `json:"cut_cheap"` // Percent to cut from ticket price
|
||||
BaseFeeCheap int64 `json:"base_fee_cheap"`
|
||||
}
|
||||
|
||||
type GroupFeatures struct {
|
||||
Silent bool `json:"silent"` // do not respond with feedback to commands
|
||||
DeleteTip bool `json:"deletetip"` // delete /tip messages after a time
|
||||
Ticket bool `json:"ticket"` // enable group tickets
|
||||
Tipjar bool `json:"tipjar"` // enable tipjars to be created
|
||||
Faucet bool `json:"faucet"` // enable faucets to be create
|
||||
}
|
||||
type Group struct {
|
||||
Name string `json:"name"`
|
||||
Title string `json:"title"`
|
||||
ID int64 `json:"id" gorm:"primaryKey"`
|
||||
Owner *tb.User `gorm:"embedded;embeddedPrefix:owner_"`
|
||||
// Chat *tb.Chat `gorm:"embedded;embeddedPrefix:chat_"`
|
||||
Ticket *Ticket `gorm:"embedded;embeddedPrefix:ticket_"`
|
||||
Ticket *Ticket `gorm:"embedded;embeddedPrefix:ticket_"`
|
||||
Features *GroupFeatures `gorm:"embedded;embeddedPrefix:features_"`
|
||||
}
|
||||
type CreateChatInviteLink struct {
|
||||
ChatID int64 `json:"chat_id"`
|
||||
@@ -106,17 +115,45 @@ func (bot TipBot) groupHandler(ctx intercept.Context) (intercept.Context, error)
|
||||
if splits[1] == "join" {
|
||||
return bot.groupRequestJoinHandler(ctx)
|
||||
}
|
||||
if splits[1] == "add" {
|
||||
if splits[1] == "add" || splits[1] == "ticket" {
|
||||
// create ticket for this group
|
||||
// we check inside addGroupHandler whether the user is the owner of the group
|
||||
return bot.addGroupHandler(ctx)
|
||||
}
|
||||
if splits[1] == "remove" {
|
||||
// todo -- implement this
|
||||
// return bot.addGroupHandler(ctx, m)
|
||||
}
|
||||
if splits[1] == "enable" {
|
||||
// enable features for this group
|
||||
if !bot.isAdmin(ctx.Message().Chat, user.Telegram) {
|
||||
bot.trySendMessage(ctx.Message().Chat, Translate(ctx, "groupBotIsNotAdminMessage"))
|
||||
return ctx, fmt.Errorf("user is not admin")
|
||||
}
|
||||
return bot.groupEnableFeature(ctx, splits[2])
|
||||
}
|
||||
if splits[1] == "disable" {
|
||||
// disable features for this group
|
||||
if !bot.isAdmin(ctx.Message().Chat, user.Telegram) {
|
||||
bot.trySendMessage(ctx.Message().Chat, Translate(ctx, "groupBotIsNotAdminMessage"))
|
||||
return ctx, fmt.Errorf("user is not admin")
|
||||
}
|
||||
return bot.groupDisableFeature(ctx, splits[2])
|
||||
}
|
||||
}
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
// groupEnableFeature enables a feature for a group
|
||||
func (bot TipBot) groupEnableFeature(ctx intercept.Context, feature string) (intercept.Context, error) {
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
// groupDisableFeature disables a feature for a group
|
||||
func (bot TipBot) groupDisableFeature(ctx intercept.Context, feature string) (intercept.Context, error) {
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
// groupRequestJoinHandler sends a payment request to the user who wants to join a group
|
||||
func (bot TipBot) groupRequestJoinHandler(ctx intercept.Context) (intercept.Context, error) {
|
||||
user := LoadUser(ctx)
|
||||
@@ -412,7 +449,7 @@ func (bot TipBot) addGroupHandler(ctx intercept.Context) (intercept.Context, err
|
||||
|
||||
amount := int64(0) // default amount is zero
|
||||
if amount_str, err := getArgumentFromCommand(m.Text, 3); err == nil {
|
||||
amount, err = getAmount(amount_str)
|
||||
amount, err = GetAmount(amount_str)
|
||||
if err != nil {
|
||||
bot.trySendMessage(m.Sender, Translate(ctx, "lnurlInvalidAmountMessage"))
|
||||
return ctx, err
|
||||
|
||||
@@ -99,6 +99,22 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Endpoints: []interface{}{"/generate"},
|
||||
Handler: bot.generateImages,
|
||||
Interceptor: &Interceptor{
|
||||
Before: []intercept.Func{
|
||||
bot.requirePrivateChatInterceptor,
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
bot.unlockInterceptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Endpoints: []interface{}{"/tip", "/t", "/honk"},
|
||||
Handler: bot.tipHandler,
|
||||
@@ -172,6 +188,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -210,6 +227,22 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
bot.unlockInterceptor,
|
||||
}},
|
||||
},
|
||||
// {
|
||||
// Endpoints: []interface{}{"/gpt", "/chat"},
|
||||
// Handler: bot.gptHandler,
|
||||
// Interceptor: &Interceptor{
|
||||
|
||||
// Before: []intercept.Func{
|
||||
// bot.localizerInterceptor,
|
||||
// bot.logMessageInterceptor,
|
||||
// bot.requireUserInterceptor,
|
||||
// bot.lockInterceptor,
|
||||
// },
|
||||
// OnDefer: []intercept.Func{
|
||||
// bot.unlockInterceptor,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
{
|
||||
Endpoints: []interface{}{"/balance", &btnBalanceMainMenu},
|
||||
Handler: bot.balanceHandler,
|
||||
@@ -261,6 +294,25 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
},
|
||||
},
|
||||
},
|
||||
// previously, this was the send menu but it
|
||||
// was replaced with the webapp
|
||||
// {
|
||||
// Endpoints: []interface{}{&btnWebAppMainMenu},
|
||||
// Handler: bot.keyboardSendHandler,
|
||||
// Interceptor: &Interceptor{
|
||||
|
||||
// Before: []intercept.Func{
|
||||
// bot.localizerInterceptor,
|
||||
// bot.logMessageInterceptor,
|
||||
// bot.requireUserInterceptor,
|
||||
// bot.loadReplyToInterceptor,
|
||||
// bot.lockInterceptor,
|
||||
// },
|
||||
// OnDefer: []intercept.Func{
|
||||
// bot.unlockInterceptor,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
{
|
||||
Endpoints: []interface{}{"/transactions"},
|
||||
Handler: bot.transactionsHandler,
|
||||
@@ -280,6 +332,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -295,6 +348,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -321,7 +375,6 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Endpoints: []interface{}{"/tipjar", "/spendendose"},
|
||||
Handler: bot.tipjarHandler,
|
||||
Interceptor: &Interceptor{
|
||||
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
@@ -337,7 +390,6 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Endpoints: []interface{}{"/help", &btnHelpMainMenu},
|
||||
Handler: bot.helpHandler,
|
||||
Interceptor: &Interceptor{
|
||||
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
@@ -385,8 +437,8 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Endpoints: []interface{}{"/advanced"},
|
||||
Handler: bot.advancedHelpHandler,
|
||||
Interceptor: &Interceptor{
|
||||
|
||||
Before: []intercept.Func{
|
||||
bot.requirePrivateChatInterceptor,
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
@@ -401,8 +453,24 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Endpoints: []interface{}{"/link"},
|
||||
Handler: bot.lndhubHandler,
|
||||
Interceptor: &Interceptor{
|
||||
|
||||
Before: []intercept.Func{
|
||||
bot.requirePrivateChatInterceptor,
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
bot.unlockInterceptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Endpoints: []interface{}{"/api"},
|
||||
Handler: bot.apiHandler,
|
||||
Interceptor: &Interceptor{
|
||||
Before: []intercept.Func{
|
||||
bot.requirePrivateChatInterceptor,
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
@@ -417,8 +485,8 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Endpoints: []interface{}{"/lnurl"},
|
||||
Handler: bot.lnurlHandler,
|
||||
Interceptor: &Interceptor{
|
||||
|
||||
Before: []intercept.Func{
|
||||
bot.requirePrivateChatInterceptor,
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
@@ -434,7 +502,6 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Endpoints: []interface{}{"/group"},
|
||||
Handler: bot.groupHandler,
|
||||
Interceptor: &Interceptor{
|
||||
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.logMessageInterceptor,
|
||||
@@ -471,6 +538,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -548,6 +616,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -563,6 +632,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -578,6 +648,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -593,6 +664,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -608,6 +680,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -623,6 +696,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -638,6 +712,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -653,6 +728,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -669,10 +745,12 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
bot.singletonCallbackInterceptor,
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
bot.unlockInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -684,6 +762,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -699,6 +778,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -714,6 +794,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -729,6 +810,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -744,6 +826,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -759,6 +842,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -774,6 +858,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.requireUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -789,6 +874,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -803,6 +889,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -817,6 +904,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -831,6 +919,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -845,6 +934,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -859,6 +949,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -874,6 +965,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -889,6 +981,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -904,6 +997,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -919,6 +1013,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -934,6 +1029,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -949,6 +1045,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -964,6 +1061,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -979,6 +1077,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -994,6 +1093,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1008,6 +1108,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1022,6 +1123,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1036,6 +1138,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1051,6 +1154,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1065,6 +1169,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1079,6 +1184,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1093,6 +1199,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1107,6 +1214,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1121,6 +1229,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1135,6 +1244,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
@@ -1149,6 +1259,7 @@ func (bot TipBot) getHandler() []InterceptionWrapper {
|
||||
Before: []intercept.Func{
|
||||
bot.localizerInterceptor,
|
||||
bot.loadUserInterceptor,
|
||||
bot.answerCallbackInterceptor,
|
||||
bot.lockInterceptor,
|
||||
},
|
||||
OnDefer: []intercept.Func{
|
||||
|
||||
@@ -59,10 +59,9 @@ func (bot TipBot) idInterceptor(ctx intercept.Context) (intercept.Context, error
|
||||
}
|
||||
|
||||
// answerCallbackInterceptor will answer the callback with the given text in the context
|
||||
func (bot TipBot) answerCallbackInterceptor(ctx context.Context, i interface{}) (context.Context, error) {
|
||||
switch i.(type) {
|
||||
case *tb.Callback:
|
||||
c := i.(*tb.Callback)
|
||||
func (bot TipBot) answerCallbackInterceptor(ctx intercept.Context) (intercept.Context, error) {
|
||||
c := ctx.Callback()
|
||||
if c != nil {
|
||||
ctxcr := ctx.Value("callback_response")
|
||||
var res []*tb.CallbackResponse
|
||||
if ctxcr != nil {
|
||||
|
||||
@@ -40,6 +40,7 @@ func initInvoiceEventCallbacks(bot *TipBot) {
|
||||
InvoiceCallbackLNURLPayReceive: EventHandler{Function: bot.lnurlReceiveEvent, Type: EventTypeInvoice},
|
||||
InvoiceCallbackGroupTicket: EventHandler{Function: bot.groupGetInviteLinkHandler, Type: EventTypeInvoice},
|
||||
InvoiceCallbackSatdressProxy: EventHandler{Function: bot.satdressProxyRelayPaymentHandler, Type: EventTypeInvoice},
|
||||
InvoiceCallbackGenerateDalle: EventHandler{Function: bot.generateDalleImages, Type: EventTypeInvoice},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +52,7 @@ const (
|
||||
InvoiceCallbackLNURLPayReceive
|
||||
InvoiceCallbackGroupTicket
|
||||
InvoiceCallbackSatdressProxy
|
||||
InvoiceCallbackGenerateDalle
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+17
-20
@@ -20,22 +20,9 @@ func (bot *TipBot) lndhubHandler(ctx intercept.Context) (intercept.Context, erro
|
||||
bot.trySendMessage(m.Sender, Translate(ctx, "couldNotLinkMessage"))
|
||||
return ctx, fmt.Errorf("invalid configuration")
|
||||
}
|
||||
// check and print all commands
|
||||
bot.anyTextHandler(ctx)
|
||||
// reply only in private message
|
||||
if m.Chat.Type != tb.ChatPrivate {
|
||||
// delete message
|
||||
bot.tryDeleteMessage(m)
|
||||
}
|
||||
// first check whether the user is initialized
|
||||
fromUser := LoadUser(ctx)
|
||||
bot.trySendMessage(m.Sender, Translate(ctx, "walletConnectMessage"))
|
||||
|
||||
// do not respond to banned users
|
||||
if bot.UserIsBanned(fromUser) {
|
||||
log.Warnln("[lndhubHandler] user is banned. not responding.")
|
||||
return ctx, fmt.Errorf("user is banned")
|
||||
}
|
||||
linkmsg := bot.trySendMessageEditable(m.Sender, Translate(ctx, "walletConnectMessage"))
|
||||
|
||||
lndhubUrl := fmt.Sprintf("lndhub://admin:%s@%slndhub/ext/", fromUser.Wallet.Adminkey, internal.Configuration.Lnbits.LnbitsPublicUrl)
|
||||
|
||||
@@ -48,14 +35,24 @@ func (bot *TipBot) lndhubHandler(ctx intercept.Context) (intercept.Context, erro
|
||||
}
|
||||
|
||||
// send the link to the user
|
||||
linkmsg := bot.trySendMessage(m.Sender, &tb.Photo{File: tb.File{FileReader: bytes.NewReader(qr)}, Caption: fmt.Sprintf("`%s`", lndhubUrl)})
|
||||
|
||||
qrmsg := bot.trySendMessage(m.Sender, &tb.Photo{File: tb.File{FileReader: bytes.NewReader(qr)}, Caption: fmt.Sprintf("`%s`", lndhubUrl)})
|
||||
// auto delete
|
||||
go func() {
|
||||
time.Sleep(time.Second * 60)
|
||||
bot.tryDeleteMessage(linkmsg)
|
||||
bot.trySendMessage(m.Sender, Translate(ctx, "linkHiddenMessage"), tb.Silent)
|
||||
bot.tryDeleteMessage(qrmsg)
|
||||
bot.tryEditMessage(linkmsg, Translate(ctx, "linkHiddenMessage"), tb.Silent)
|
||||
}()
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
func (bot *TipBot) apiHandler(ctx intercept.Context) (intercept.Context, error) {
|
||||
m := ctx.Message()
|
||||
fromUser := LoadUser(ctx)
|
||||
apimesg := bot.trySendMessageEditable(m.Sender, fmt.Sprintf(Translate(ctx, "apiConnectMessage"), fromUser.Wallet.Adminkey, fromUser.Wallet.Inkey))
|
||||
// auto delete
|
||||
go func() {
|
||||
time.Sleep(time.Second * 60)
|
||||
bot.tryEditMessage(apimesg, Translate(ctx, "apiHiddenMessage"))
|
||||
}()
|
||||
// auto delete the message
|
||||
// NewMessage(linkmsg, WithDuration(time.Second*time.Duration(internal.Configuration.Telegram.MessageDisposeDuration), bot))
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func (bot *TipBot) confirmLnurlAuthHandler(ctx intercept.Context) (intercept.Con
|
||||
// statusMsg := bot.trySendMessageEditable(c.Sender,
|
||||
// Translate(ctx, "lnurlResolvingUrlMessage"),
|
||||
// )
|
||||
bot.editSingleButton(ctx, c.Message, lnurlAuthState.Message.Text, Translate(ctx, "lnurlResolvingUrlMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlAuthState.Message.Text, ButtonText: Translate(ctx, "lnurlResolvingUrlMessage")})
|
||||
|
||||
// from fiatjaf/go-lnurl
|
||||
p := lnurlAuthState.LNURLAuthParams
|
||||
@@ -107,7 +107,7 @@ func (bot *TipBot) confirmLnurlAuthHandler(ctx intercept.Context) (intercept.Con
|
||||
}
|
||||
|
||||
var sentsigres lnurl.LNURLResponse
|
||||
client, err := network.GetClient(network.ClientTypeClearNet)
|
||||
client, err := network.GetClientForScheme(p.CallbackURL)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
@@ -125,7 +125,11 @@ func (bot *TipBot) confirmLnurlAuthHandler(ctx intercept.Context) (intercept.Con
|
||||
bot.tryEditMessage(c, fmt.Sprintf(Translate(ctx, "errorReasonMessage"), sentsigres.Reason))
|
||||
return ctx, err
|
||||
}
|
||||
bot.editSingleButton(ctx, c.Message, lnurlAuthState.Message.Text, Translate(ctx, "lnurlSuccessfulLogin"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{
|
||||
Message: lnurlAuthState.Message.Text,
|
||||
ButtonText: Translate(ctx, "lnurlSuccessfulLogin"),
|
||||
URL: fmt.Sprintf("https://%s", lnurlAuthState.LNURLAuthParams.Host),
|
||||
})
|
||||
return ctx, lnurlAuthState.Inactivate(lnurlAuthState, bot.Bunt)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ type LnurlPayState struct {
|
||||
}
|
||||
|
||||
// lnurlPayHandler is invoked when the first lnurl response was a lnurlpay response
|
||||
// at this point, the user hans't necessarily entered an amount yet
|
||||
// at this point, the user hasn't necessarily entered an amount yet
|
||||
func (bot *TipBot) lnurlPayHandler(ctx intercept.Context, payParams *LnurlPayState) (context.Context, error) {
|
||||
m := ctx.Message()
|
||||
user := LoadUser(ctx)
|
||||
@@ -154,13 +154,13 @@ func (bot *TipBot) lnurlPayHandlerSend(ctx intercept.Context) (intercept.Context
|
||||
|
||||
// LnurlPayState loaded
|
||||
|
||||
client, err := network.GetClient(network.ClientTypeClearNet)
|
||||
callbackUrl, err := url.Parse(lnurlPayState.LNURLPayParams.Callback)
|
||||
if err != nil {
|
||||
log.Errorf("[lnurlPayHandlerSend] Error: %s", err.Error())
|
||||
bot.tryEditMessage(statusMsg, Translate(ctx, "errorTryLaterMessage"))
|
||||
return ctx, err
|
||||
}
|
||||
callbackUrl, err := url.Parse(lnurlPayState.LNURLPayParams.Callback)
|
||||
client, err := network.GetClientForScheme(callbackUrl)
|
||||
if err != nil {
|
||||
log.Errorf("[lnurlPayHandlerSend] Error: %s", err.Error())
|
||||
bot.tryEditMessage(statusMsg, Translate(ctx, "errorTryLaterMessage"))
|
||||
@@ -201,27 +201,15 @@ func (bot *TipBot) lnurlPayHandlerSend(ctx intercept.Context) (intercept.Context
|
||||
return ctx, fmt.Errorf("error in LNURLPayValues: %s", error_reason)
|
||||
}
|
||||
|
||||
// todo: doesn't work with lnurls from lnbits??
|
||||
// check whether description hash matches with expected hash
|
||||
// decode invoice
|
||||
// bolt11, err := decodepay.Decodepay(response2.PR)
|
||||
// if err != nil {
|
||||
// bot.trySendMessage(ctx.Sender(), helpPayInvoiceUsage(ctx, Translate(ctx, "invalidInvoiceHelpMessage")))
|
||||
// errmsg := fmt.Sprintf("[/pay] Error: Could not decode invoice: %s", err.Error())
|
||||
// log.Errorln(errmsg)
|
||||
// return ctx, errors.New(errors.InvalidSyntaxError, err)
|
||||
// }
|
||||
// if bolt11.DescriptionHash != lnurlPayState.DescriptionHash {
|
||||
// log.Errorf("[lnurlPayHandlerSend] Error: description hash doesn't match")
|
||||
// bot.tryEditMessage(statusMsg, fmt.Sprintf(Translate(ctx, "errorReasonMessage"), "description hash doesn't match.\nExpected: `"+lnurlPayState.DescriptionHash+"` Received: `"+bolt11.DescriptionHash+"`"))
|
||||
// return ctx, fmt.Errorf("description hash doesn't match")
|
||||
// }
|
||||
|
||||
// all good
|
||||
lnurlPayState.LNURLPayValues = response2
|
||||
// add result to persistent struct
|
||||
runtime.IgnoreError(lnurlPayState.Set(lnurlPayState, bot.Bunt))
|
||||
bot.Telegram.Delete(statusMsg)
|
||||
|
||||
// store success action in context for printing after the payHandler
|
||||
ctx.Context = context.WithValue(ctx, "SuccessAction", lnurlPayState.LNURLPayValues.SuccessAction)
|
||||
|
||||
m.Text = fmt.Sprintf("/pay %s", response2.PR)
|
||||
return bot.payHandler(ctx)
|
||||
}
|
||||
|
||||
@@ -46,17 +46,31 @@ type LnurlWithdrawState struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type EditSingleButtonParams struct {
|
||||
Message string
|
||||
ButtonText string
|
||||
Data string
|
||||
URL string
|
||||
}
|
||||
|
||||
// editSingleButton edits a message to display a single button (for something like a progress indicator)
|
||||
func (bot *TipBot) editSingleButton(ctx context.Context, m *tb.Message, message string, button string) {
|
||||
bot.tryEditMessage(
|
||||
func (bot *TipBot) editSingleButton(ctx context.Context, m *tb.Message, params EditSingleButtonParams) (*tb.Message, error) {
|
||||
if len(params.URL) > 0 && len(params.Data) > 0 {
|
||||
return &tb.Message{}, fmt.Errorf("URL and Data cannot be set at the same time.")
|
||||
}
|
||||
if len(params.URL) == 0 && len(params.Data) == 0 {
|
||||
params.Data = "placeholder"
|
||||
}
|
||||
return bot.tryEditMessage(
|
||||
m,
|
||||
message,
|
||||
params.Message,
|
||||
&tb.ReplyMarkup{
|
||||
InlineKeyboard: [][]tb.InlineButton{
|
||||
{tb.InlineButton{Text: button}},
|
||||
{tb.InlineButton{Text: params.ButtonText, Data: params.Data, URL: params.URL}},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
// lnurlWithdrawHandler is invoked when the first lnurl response was a lnurl-withdraw response
|
||||
@@ -232,13 +246,13 @@ func (bot *TipBot) confirmWithdrawHandler(ctx intercept.Context) (intercept.Cont
|
||||
ResetUserState(user, bot)
|
||||
|
||||
// update button text
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "lnurlPreparingWithdraw"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "lnurlPreparingWithdraw")})
|
||||
|
||||
callbackUrl, err := url.Parse(lnurlWithdrawState.LNURLWithdrawResponse.Callback)
|
||||
if err != nil {
|
||||
log.Errorf("[lnurlWithdrawHandlerWithdraw] Error: %s", err.Error())
|
||||
// bot.trySendMessage(c.Sender, Translate(handler.Ctx, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage")})
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
@@ -254,7 +268,7 @@ func (bot *TipBot) confirmWithdrawHandler(ctx intercept.Context) (intercept.Cont
|
||||
if err != nil {
|
||||
errmsg := fmt.Sprintf("[lnurlWithdrawHandlerWithdraw] Could not create an invoice: %s", err.Error())
|
||||
log.Errorln(errmsg)
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage")})
|
||||
return ctx, err
|
||||
}
|
||||
lnurlWithdrawState.Invoice = invoice
|
||||
@@ -266,25 +280,25 @@ func (bot *TipBot) confirmWithdrawHandler(ctx intercept.Context) (intercept.Cont
|
||||
callbackUrl.RawQuery = qs.Encode()
|
||||
|
||||
// lnurlWithdrawState loaded
|
||||
client, err := network.GetClient(network.ClientTypeClearNet)
|
||||
client, err := network.GetClientForScheme(callbackUrl)
|
||||
if err != nil {
|
||||
log.Errorf("[lnurlWithdrawHandlerWithdraw] Error: %s", err.Error())
|
||||
// bot.trySendMessage(c.Sender, Translate(ctx, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage")})
|
||||
return ctx, err
|
||||
}
|
||||
res, err := client.Get(callbackUrl.String())
|
||||
if err != nil || res.StatusCode >= 300 {
|
||||
log.Errorf("[lnurlWithdrawHandlerWithdraw] Failed.")
|
||||
// bot.trySendMessage(c.Sender, Translate(handler.Ctx, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage")})
|
||||
return ctx, errors.New(errors.UnknownError, err)
|
||||
}
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
log.Errorf("[lnurlWithdrawHandlerWithdraw] Error: %s", err.Error())
|
||||
// bot.trySendMessage(c.Sender, Translate(handler.Ctx, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "errorTryLaterMessage")})
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
@@ -293,12 +307,12 @@ func (bot *TipBot) confirmWithdrawHandler(ctx intercept.Context) (intercept.Cont
|
||||
json.Unmarshal(body, &response2)
|
||||
if response2.Status == "OK" {
|
||||
// update button text
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "lnurlWithdrawSuccess"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "lnurlWithdrawSuccess")})
|
||||
|
||||
} else {
|
||||
log.Errorf("[lnurlWithdrawHandlerWithdraw] LNURLWithdraw failed.")
|
||||
// update button text
|
||||
bot.editSingleButton(ctx, c.Message, lnurlWithdrawState.Message, i18n.Translate(lnurlWithdrawState.LanguageCode, "lnurlWithdrawFailed"))
|
||||
bot.editSingleButton(ctx, c.Message, EditSingleButtonParams{Message: lnurlWithdrawState.Message, ButtonText: i18n.Translate(lnurlWithdrawState.LanguageCode, "lnurlWithdrawFailed")})
|
||||
return ctx, errors.New(errors.UnknownError, fmt.Errorf("LNURLWithdraw failed"))
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ func UserGetLNURL(user *lnbits.User) (string, error) {
|
||||
}
|
||||
|
||||
func UserGetAnonLNURL(user *lnbits.User) (string, error) {
|
||||
callback := fmt.Sprintf("%s/.well-known/lnurlp/%s", internal.Configuration.Bot.LNURLHostName, fmt.Sprint(user.AnonIDSha256))
|
||||
callback := fmt.Sprintf("%s/.well-known/lnurlp/%s", internal.Configuration.Bot.LNURLHostName, user.AnonIDSha256)
|
||||
lnurlEncode, err := lnurl.LNURLEncode(callback)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -209,12 +209,7 @@ func (bot *TipBot) HandleLNURL(rawlnurl string) (string, lnurl.LNURLParams, erro
|
||||
return "", nil,
|
||||
fmt.Errorf("invalid bech32-encoded lnurl: " + rawlnurl)
|
||||
}
|
||||
rawurl, err = lnurl.LNURLDecode(lnurl_str)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
// rerun LNURLDecode to convert lnurlp/keyauth schemes to https://
|
||||
rawurl, err = lnurl.LNURLDecode(rawurl)
|
||||
rawurl, err = lnurl.LNURLDecodeStrict(lnurl_str)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
@@ -243,7 +238,7 @@ func (bot *TipBot) HandleLNURL(rawlnurl string) (string, lnurl.LNURLParams, erro
|
||||
// return rawurl, nil, err
|
||||
// }
|
||||
|
||||
client, err := network.GetClient(network.ClientTypeClearNet)
|
||||
client, err := network.GetClientForScheme(parsed)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
+34
-14
@@ -3,9 +3,10 @@ package telegram
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/errors"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/runtime/mutex"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/runtime"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/str"
|
||||
lnurl "github.com/fiatjaf/go-lnurl"
|
||||
decodepay "github.com/fiatjaf/ln-decodepay"
|
||||
log "github.com/sirupsen/logrus"
|
||||
tb "gopkg.in/lightningtipbot/telebot.v3"
|
||||
@@ -37,15 +39,16 @@ func helpPayInvoiceUsage(ctx context.Context, errormsg string) string {
|
||||
|
||||
type PayData struct {
|
||||
*storage.Base
|
||||
From *lnbits.User `json:"from"`
|
||||
Invoice string `json:"invoice"`
|
||||
Hash string `json:"hash"`
|
||||
Proof string `json:"proof"`
|
||||
Memo string `json:"memo"`
|
||||
Message string `json:"message"`
|
||||
Amount int64 `json:"amount"`
|
||||
LanguageCode string `json:"languagecode"`
|
||||
TelegramMessage *tb.Message `json:"telegrammessage"`
|
||||
From *lnbits.User `json:"from"`
|
||||
Invoice string `json:"invoice"`
|
||||
Hash string `json:"hash"`
|
||||
Proof string `json:"proof"`
|
||||
Memo string `json:"memo"`
|
||||
Message string `json:"message"`
|
||||
Amount int64 `json:"amount"`
|
||||
LanguageCode string `json:"languagecode"`
|
||||
SuccessAction *lnurl.SuccessAction `json:"successAction"`
|
||||
TelegramMessage *tb.Message `json:"telegrammessage"`
|
||||
}
|
||||
|
||||
// payHandler invoked on "/pay lnbc..." command
|
||||
@@ -131,6 +134,12 @@ func (bot *TipBot) payHandler(ctx intercept.Context) (intercept.Context, error)
|
||||
cancelButton),
|
||||
)
|
||||
payMessage := bot.trySendMessageEditable(ctx.Chat(), confirmText, paymentConfirmationMenu)
|
||||
// read successaction
|
||||
sa, ok := ctx.Value("SuccessAction").(*lnurl.SuccessAction)
|
||||
if !ok {
|
||||
sa = &lnurl.SuccessAction{}
|
||||
}
|
||||
|
||||
payData := &PayData{
|
||||
Base: storage.New(storage.ID(id)),
|
||||
From: user,
|
||||
@@ -139,6 +148,7 @@ func (bot *TipBot) payHandler(ctx intercept.Context) (intercept.Context, error)
|
||||
Memo: bolt11.Description,
|
||||
Message: confirmText,
|
||||
LanguageCode: ctx.Value("publicLanguageCode").(string),
|
||||
SuccessAction: sa,
|
||||
TelegramMessage: payMessage,
|
||||
}
|
||||
// add result to persistent struct
|
||||
@@ -182,8 +192,6 @@ func (bot *TipBot) confirmPayHandler(ctx intercept.Context) (intercept.Context,
|
||||
return ctx, errors.Create(errors.UserNoWalletError)
|
||||
}
|
||||
|
||||
invoiceString := payData.Invoice
|
||||
|
||||
// reset state immediately
|
||||
ResetUserState(user, bot)
|
||||
|
||||
@@ -195,14 +203,14 @@ func (bot *TipBot) confirmPayHandler(ctx intercept.Context) (intercept.Context,
|
||||
payData.Message,
|
||||
&tb.ReplyMarkup{
|
||||
InlineKeyboard: [][]tb.InlineButton{
|
||||
{tb.InlineButton{Text: i18n.Translate(payData.LanguageCode, "lnurlGettingUserMessage")}},
|
||||
{tb.InlineButton{Unique: "attempt_payment", Text: i18n.Translate(payData.LanguageCode, "lnurlGettingUserMessage")}},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
log.Infof("[/pay] Attempting %s's invoice %s (%d sat)", userStr, payData.ID, payData.Amount)
|
||||
// pay invoice
|
||||
invoice, err := user.Wallet.Pay(lnbits.PaymentParams{Out: true, Bolt11: invoiceString}, bot.Client)
|
||||
invoice, err := user.Wallet.Pay(lnbits.PaymentParams{Out: true, Bolt11: payData.Invoice}, bot.Client)
|
||||
if err != nil {
|
||||
errmsg := fmt.Sprintf("[/pay] Could not pay invoice of %s: %s", userStr, err)
|
||||
err = fmt.Errorf(i18n.Translate(payData.LanguageCode, "invoiceUndefinedErrorMessage"))
|
||||
@@ -235,6 +243,18 @@ func (bot *TipBot) confirmPayHandler(ctx intercept.Context) (intercept.Context,
|
||||
bot.trySendMessage(ctx.Sender(), i18n.Translate(payData.LanguageCode, "invoicePaidMessage"))
|
||||
bot.tryEditMessage(ctx.Message(), fmt.Sprintf(i18n.Translate(payData.LanguageCode, "invoicePublicPaidMessage"), userStr), &tb.ReplyMarkup{})
|
||||
}
|
||||
|
||||
// display LNURL success action if present
|
||||
sa := payData.SuccessAction
|
||||
if sa.Tag == "message" && len(sa.Message) > 0 {
|
||||
bot.trySendMessage(ctx.Sender(), fmt.Sprintf("✉️: `%s`", sa.Message))
|
||||
} else if sa.Tag == "url" && len(sa.URL) > 0 {
|
||||
bot.trySendMessage(ctx.Sender(), fmt.Sprintf("🔗: %s", str.MarkdownEscape(sa.URL)), tb.NoPreview)
|
||||
if len(sa.Description) > 0 {
|
||||
bot.trySendMessage(ctx.Sender(), fmt.Sprintf("✉️: %s", sa.Description))
|
||||
}
|
||||
}
|
||||
|
||||
log.Infof("[⚡️ pay] User %s paid invoice %s (%d sat)", userStr, payData.ID, payData.Amount)
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/errors"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/pkg/lightning"
|
||||
|
||||
@@ -250,7 +250,7 @@ func (bot *TipBot) invHandler(ctx intercept.Context) (intercept.Context, error)
|
||||
|
||||
var amount int64
|
||||
if amount_str, err := getArgumentFromCommand(m.Text, 2); err == nil {
|
||||
amount, err = getAmount(amount_str)
|
||||
amount, err = GetAmount(amount_str)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
@@ -424,7 +424,7 @@ func (bot *TipBot) satdressProxyHandler(ctx intercept.Context) (intercept.Contex
|
||||
|
||||
var amount int64
|
||||
if amount_str, err := getArgumentFromCommand(m.Text, 2); err == nil {
|
||||
amount, err = getAmount(amount_str)
|
||||
amount, err = GetAmount(amount_str)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -166,7 +166,7 @@ func (bot *TipBot) enterShopItemPriceHandler(ctx intercept.Context) (intercept.C
|
||||
if m.Text == "0" {
|
||||
amount = 0
|
||||
} else {
|
||||
amount, err = getAmount(m.Text)
|
||||
amount, err = GetAmount(m.Text)
|
||||
if err != nil {
|
||||
log.Warnf("[enterShopItemPriceHandler] %s", err.Error())
|
||||
bot.trySendMessage(m.Sender, Translate(ctx, "lnurlInvalidAmountMessage"))
|
||||
@@ -175,10 +175,6 @@ func (bot *TipBot) enterShopItemPriceHandler(ctx intercept.Context) (intercept.C
|
||||
}
|
||||
}
|
||||
|
||||
if amount > 2000 {
|
||||
bot.sendStatusMessageAndDelete(ctx, m.Sender, "ℹ️ During testing, price can be max 2000 sat.")
|
||||
amount = 2000
|
||||
}
|
||||
item.Price = amount
|
||||
shop.Items[item.ID] = item
|
||||
runtime.IgnoreError(shop.Set(shop, bot.ShopBunt))
|
||||
@@ -951,7 +947,6 @@ func (bot *TipBot) sendFileByID(ctx context.Context, to tb.Recipient, fileId str
|
||||
var ShopsText = ""
|
||||
var ShopsTextWelcome = "*You are browsing %s shop.*"
|
||||
var ShopsTextShopCount = "*Browse %d shops:*"
|
||||
var ShopsTextHelp = "⚠️ Shops are still in beta. Expect bugs."
|
||||
var ShopsNoShopsText = "*There are no shops here yet.*"
|
||||
|
||||
// shopsHandlerCallback is a warpper for shopsHandler for callbacks
|
||||
@@ -1061,7 +1056,6 @@ func (bot *TipBot) shopsHandler(ctx intercept.Context) (intercept.Context, error
|
||||
if len(shops.Shops) > 0 {
|
||||
ShopsText += fmt.Sprintf("%s\n", shopTitles)
|
||||
}
|
||||
ShopsText += fmt.Sprintf("\n%s", ShopsTextHelp)
|
||||
|
||||
// fmt.Sprintf(ShopsText, shopOwnerText, len(shops.Shops), shopTitles)
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package telegram
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/runtime"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/runtime/mutex"
|
||||
@@ -10,7 +12,6 @@ import (
|
||||
"github.com/eko/gocache/store"
|
||||
log "github.com/sirupsen/logrus"
|
||||
tb "gopkg.in/lightningtipbot/telebot.v3"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (bot TipBot) shopsMainMenu(ctx intercept.Context, shops *Shops) *tb.ReplyMarkup {
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"context"
|
||||
stderrors "errors"
|
||||
"fmt"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/errors"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal"
|
||||
|
||||
@@ -20,5 +20,6 @@ func initializeStateCallbackMessage(bot *TipBot) {
|
||||
lnbits.UserStateShopItemSendTitle: bot.enterShopItemTitleHandler,
|
||||
lnbits.UserStateShopItemSendItemFile: bot.addItemFileHandler,
|
||||
lnbits.UserEnterShopsDescription: bot.enterShopsDescriptionHandler,
|
||||
lnbits.UserEnterDallePrompt: bot.confirmGenerateImages,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/errors"
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/telegram/intercept"
|
||||
"strings"
|
||||
|
||||
"github.com/LightningTipBot/LightningTipBot/internal/lnbits"
|
||||
"github.com/LightningTipBot/LightningTipBot/pkg/lightning"
|
||||
|
||||
@@ -58,7 +58,7 @@ func (bot TipBot) createTipjar(ctx context.Context, text string, sender *tb.User
|
||||
if err != nil {
|
||||
return nil, errors.New(errors.DecodePerUserAmountError, err)
|
||||
}
|
||||
perUserAmount, err := getAmount(peruserStr)
|
||||
perUserAmount, err := GetAmount(peruserStr)
|
||||
if err != nil {
|
||||
return nil, errors.New(errors.InvalidAmountError, err)
|
||||
}
|
||||
|
||||
@@ -57,36 +57,36 @@ func startApiServer(bot *telegram.TipBot) {
|
||||
// userpage server
|
||||
userpage := userpage.New(bot)
|
||||
s.AppendRoute("/@{username}", userpage.UserPageHandler, http.MethodGet)
|
||||
s.AppendRoute("/app/@{username}", userpage.UserWebAppHandler, http.MethodGet)
|
||||
|
||||
// append lndhub ctx functions
|
||||
hub := lndhub.New(bot)
|
||||
s.AppendRoute(`/lndhub/ext/{.*}`, hub.Handle)
|
||||
s.AppendRoute(`/lndhub/ext`, hub.Handle)
|
||||
//s.AppendAuthorizedRoute(`/lndhub/ext/{.*}`, api.AuthTypeBearer, bot.DB.Users, hub.Handle)
|
||||
//s.AppendAuthorizedRoute(`/lndhub/ext`, api.AuthTypeBearer, bot.DB.Users, hub.Handle)
|
||||
s.AppendAuthorizedRoute(`/lndhub/ext/auth`, api.AuthTypeNone, api.AccessKeyTypeNone, bot.DB.Users, hub.Handle)
|
||||
s.AppendAuthorizedRoute(`/lndhub/ext/{.*}`, api.AuthTypeBearerBase64, api.AccessKeyTypeAdmin, bot.DB.Users, hub.Handle)
|
||||
s.AppendAuthorizedRoute(`/lndhub/ext`, api.AuthTypeBearerBase64, api.AccessKeyTypeAdmin, bot.DB.Users, hub.Handle)
|
||||
|
||||
// starting api service
|
||||
apiService := api.Service{Bot: bot}
|
||||
s.AppendAuthorizedRoute(`/api/v1/paymentstatus/{payment_hash}`, api.AuthTypeBasic, bot.DB.Users, apiService.PaymentStatus, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/invoicestatus/{payment_hash}`, api.AuthTypeBasic, bot.DB.Users, apiService.InvoiceStatus, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/payinvoice`, api.AuthTypeBasic, bot.DB.Users, apiService.PayInvoice, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/createinvoice`, api.AuthTypeBasic, bot.DB.Users, apiService.CreateInvoice, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/balance`, api.AuthTypeBasic, bot.DB.Users, apiService.Balance, http.MethodGet)
|
||||
s.AppendAuthorizedRoute(`/api/v1/paymentstatus/{payment_hash}`, api.AuthTypeBasic, api.AccessKeyTypeInvoice, bot.DB.Users, apiService.PaymentStatus, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/invoicestatus/{payment_hash}`, api.AuthTypeBasic, api.AccessKeyTypeInvoice, bot.DB.Users, apiService.InvoiceStatus, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/payinvoice`, api.AuthTypeBasic, api.AccessKeyTypeAdmin, bot.DB.Users, apiService.PayInvoice, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/invoicestream`, api.AuthTypeBasic, api.AccessKeyTypeInvoice, bot.DB.Users, apiService.InvoiceStream, http.MethodGet)
|
||||
s.AppendAuthorizedRoute(`/api/v1/createinvoice`, api.AuthTypeBasic, api.AccessKeyTypeInvoice, bot.DB.Users, apiService.CreateInvoice, http.MethodPost)
|
||||
s.AppendAuthorizedRoute(`/api/v1/balance`, api.AuthTypeBasic, api.AccessKeyTypeInvoice, bot.DB.Users, apiService.Balance, http.MethodGet)
|
||||
|
||||
// start internal admin server
|
||||
adminService := admin.New(bot)
|
||||
internalAdminServer := api.NewServer("0.0.0.0:6060")
|
||||
internalAdminServer := api.NewServer(internal.Configuration.Bot.AdminAPIHost)
|
||||
internalAdminServer.AppendRoute("/mutex", mutex.ServeHTTP)
|
||||
internalAdminServer.AppendRoute("/mutex/unlock/{id}", mutex.UnlockHTTP)
|
||||
internalAdminServer.AppendRoute("/admin/ban/{id}", adminService.BanUser)
|
||||
internalAdminServer.AppendRoute("/admin/unban/{id}", adminService.UnbanUser)
|
||||
internalAdminServer.AppendRoute("/admin/dalle/enable", adminService.EnableDalle)
|
||||
internalAdminServer.AppendRoute("/admin/dalle/disable", adminService.DisableDalle)
|
||||
internalAdminServer.PathPrefix("/debug/pprof/", http.DefaultServeMux)
|
||||
|
||||
}
|
||||
|
||||
func withMiddleware(mw func(w http.ResponseWriter, r *http.Request)) http.HandlerFunc {
|
||||
return mw
|
||||
}
|
||||
func withRecovery() {
|
||||
if r := recover(); r != nil {
|
||||
log.Errorln("Recovered panic: ", r)
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
# COMMANDS
|
||||
|
||||
helpCommandStr = """pomoc"""
|
||||
basicsCommandStr = """základy"""
|
||||
tipCommandStr = """tip"""
|
||||
balanceCommandStr = """zůstatek"""
|
||||
sendCommandStr = """poslat"""
|
||||
invoiceCommandStr = """invoice"""
|
||||
payCommandStr = """zaplatit"""
|
||||
donateCommandStr = """podpořit"""
|
||||
advancedCommandStr = """pokročilé"""
|
||||
transactionsCommandStr = """transakce"""
|
||||
logCommandStr = """log"""
|
||||
listCommandStr = """list"""
|
||||
|
||||
linkCommandStr = """odkaz"""
|
||||
lnurlCommandStr = """LNURL"""
|
||||
faucetCommandStr = """faucet"""
|
||||
|
||||
tipjarCommandStr = """tipjar"""
|
||||
receiveCommandStr = """přijmout"""
|
||||
hideCommandStr = """skrýt"""
|
||||
volcanoCommandStr = """sopka"""
|
||||
showCommandStr = """ukázat"""
|
||||
optionsCommandStr = """možnosti"""
|
||||
settingsCommandStr = """nastavení"""
|
||||
saveCommandStr = """uložit"""
|
||||
deleteCommandStr = """smazat"""
|
||||
infoCommandStr = """info"""
|
||||
|
||||
# NOTIFICATIONS
|
||||
|
||||
cantDoThatMessage = """To nelze udělat."""
|
||||
cantClickMessage = """Toto tlačítko nejde zmáčkout."""
|
||||
balanceTooLowMessage = """Tvůj zůstatek je příliš malý."""
|
||||
|
||||
# BUTTONS
|
||||
|
||||
sendButtonMessage = """✅ Odeslat"""
|
||||
payButtonMessage = """✅ Zaplatit"""
|
||||
payReceiveButtonMessage = """💸 Zaplatit"""
|
||||
receiveButtonMessage = """✅ Přijmout"""
|
||||
withdrawButtonMessage = """✅ Vybrat"""
|
||||
cancelButtonMessage = """🚫 Zrušit"""
|
||||
collectButtonMessage = """✅ Vybrat"""
|
||||
nextButtonMessage = """Dále"""
|
||||
backButtonMessage = """Zpět"""
|
||||
acceptButtonMessage = """Potvrdit"""
|
||||
denyButtonMessage = """Odmítnout"""
|
||||
tipButtonMessage = """Platba"""
|
||||
revealButtonMessage = """Odhalit"""
|
||||
showButtonMessage = """Ukázat"""
|
||||
hideButtonMessage = """Skrýt"""
|
||||
joinButtonMessage = """Připojit se"""
|
||||
optionsButtonMessage = """Možnosti"""
|
||||
settingsButtonMessage = """Nastavení"""
|
||||
saveButtonMessage = """Uložit"""
|
||||
deleteButtonMessage = """Smazat"""
|
||||
infoButtonMessage = """Info"""
|
||||
|
||||
cancelButtonEmoji = """🚫"""
|
||||
payButtonEmoji = """💸"""
|
||||
|
||||
# HELP
|
||||
|
||||
helpMessage = """⚡️ *Peněženka*
|
||||
_Tento bot je bitcoinová lightning peněženka, která umožňuje posílat platby na Telegramu. Pro použití přidejte bota do chatu. Základní jednotkou je 1 sat. 100 000 000 sats = 1 bitcoin. Napiš 📚 /basics pro víc info._
|
||||
|
||||
❤️ *Podpořit*
|
||||
_Tento bot si neúčtuje žádné poplatky, ale jeho provoz stojí nějaké sats. Pokud se Ti líbí, zvaž prosím podporu tohoto projektu. Pro podporu napiš_ `/donate 1000`
|
||||
|
||||
%s
|
||||
|
||||
⚙️ *Příkazy*
|
||||
*/tip* 🏅 Odpověz na zprávu, abys poslal tip: `/tip <částka> [<zpráva>]`
|
||||
*/balance* 👑 Zkontroluj svůj zůstatek: `/balance`
|
||||
*/send* 💸 Poslat platbu uživateli: `/send <částka> @uživatel nebo uživatel@ln.tips [<zpráva>]`
|
||||
*/invoice* ⚡️ Vytvořit lightning (invoice): `/invoice <částka> [<zpráva>]`
|
||||
*/pay* ⚡️ Zaplatit lightning invoice: `/pay <invoice>`
|
||||
*/donate* ❤️ Podpořit projekt: `/donate 1000`
|
||||
*/advanced* 🤖 Pokročilé funkce.
|
||||
*/help* 📖 Tato nápověda."""
|
||||
|
||||
infoHelpMessage = """ℹ️ *Info*"""
|
||||
infoYourLightningAddress = """Tvoje lightning adresa je `%s`"""
|
||||
|
||||
basicsMessage = """🧡 *Bitcoin*
|
||||
_Bitcoin jsou internetové peníze. Jsou decentralizované, k jejich použití nepotřebuješ povolení a nemají žádnou centrální autoritu, která by je řídila. Bitcoin jsou zdravé peníze, které jsou na rozdíl od starého finančního systému rychlejší, bezpečnější a pro každého._
|
||||
|
||||
🧮 *Ekonomnika*
|
||||
_Nejmenší jednotkou bitcoinu je 1 sat. 100 000 000 sats = 1 bitcoin. Nikdy nebude existovat víc než 21 milionů bitcoinů. Kurz bitcoinu vůči státním měnám se může často a náhle měnit. Nicméně, pokud žijete na bitcoinovém standardu, 1 sat se bude pořád rovnat 1 satu._
|
||||
|
||||
⚡️ *Lightning Network*
|
||||
_Lightningová síť je platební protokol který umožňuje rychlé a levné bitcoinové platby nevyžadující téměř žádnou energii. Tato síť škáluje bitcoin pro miliardy lidí na celém světě._
|
||||
|
||||
📲 *Lightning peněženky*
|
||||
_Tvoje prostředky z této lightning peněženky můžeš poslat na jakoukoliv jinou a naopak. Doporučené lightning peněženky pro mobil jsou_ [Phoenix](https://phoenix.acinq.co/)_,_ [Breez](https://breez.technology/)_,_ [Muun](https://muun.com/)_ (držíte své klíče), nebo_ [Wallet of Satoshi](https://www.walletofsatoshi.com/) _(jednoduchá, ale klíče od sats nedržíte)_.
|
||||
|
||||
📄 *Open Source*
|
||||
_Tento bot je volný a otevřený_ [open source](https://github.com/LightningTipBot/LightningTipBot) _software. Můžeš ho běžet na vlastním počítači a používat jej ve vlastní komunitě._
|
||||
|
||||
✈️ *Telegram*
|
||||
_Přidej tohoto bota do své skupiny na Telegramu a můžeš posílat /tip za zprávy. Pokud uděláš bota adminem skupiny, bude odstraňovat příkazy, aby zůstal chat přehlednější._
|
||||
|
||||
🏛 *Podmínky*
|
||||
_Nejsme správci Tvých prostředků. Budeme konat v Tvém nejlepším zájmu, ale také jsme si vědomi nejisté situace bez KYC, dokud nepřijdeme na něco jiného. Jakákoli částka, kterou si pošleš do peněženky, je proto považována za příspěvek podpory. Neposílej nám všechny svoje peníze. Vezmi v potaz, že bot je v beta fázi vývoje. Používáš ho na vlastní riziko._
|
||||
|
||||
❤️ *Podpora*
|
||||
_Tento bot si neúčtuje žádné poplatky, ale jeho provoz stojí nějaké sats. Pokud se Ti líbí, zvaž prosím podporu tohoto projektu. Pro podporu napiš_ `/donate 1000`"""
|
||||
|
||||
helpNoUsernameMessage = """👋 Prosím, nastav si uživatelské jméno na Telegramu."""
|
||||
|
||||
advancedMessage = """%s
|
||||
|
||||
👉 *Inline příkazy*
|
||||
*send* 💸 Poslat sats do chatu: `%s send <částka> [<uživatel>] [<zpráva>]`
|
||||
*receive* 🏅 Vyžádat platbu: `... receive <částka> [<uživatel>] [<zpráva>]`
|
||||
*faucet* 🚰 Vytvořit faucet: `... faucet <kapacita> <částka_na_uživatele> [<zpráva>]`
|
||||
*tipjar* 🍯 Vytvořit tipjar: `... tipjar <kapacita> <částka_na_uživatele> [<zpráva>]`
|
||||
|
||||
📖 V každém chatu můžeš používat inline příkazy, dokonce i v soukromých konverzacích. Po zadání inline příkazu chvilku vyčkej a *klikni* na výsledek, nemačkej enter.
|
||||
|
||||
⚙️ *Pokročilé příkazy*
|
||||
*/transactions* 📊 Seznam transakcí
|
||||
*/link* 🔗 Propojit peněženku s [BlueWallet](https://bluewallet.io/) nebo [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ LNURL obdržet nebo zaplatit: `/lnurl` nebo `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Vytvořit faucet: `/faucet <kapacita> <částka_na_uživatele>`
|
||||
*/tipjar* 🍯 Vytvořit tipjar: `/tipjar <kapacita> <částka_na_uživatele>`
|
||||
*/group* 🎟 Vytvořit vstupenky do skupiny: `/group add <název_skupiny> [<cena_vstupenky>]`
|
||||
*/shop* 🛍 Prohlížet obchody: `/shop` nebo `/shop <uživatel/id_obchodu>`
|
||||
*/generate* 🎆 Vytvořit obrázky od DALLE 2: `/generate <prompt>`"""
|
||||
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Zadej částku mezi %d a %d sats."""
|
||||
enterAmountMessage = """💯 Zadej částku."""
|
||||
enterUserMessage = """👤 Zadej uživatele."""
|
||||
enterTextMessage = """⌨️ Zadej text."""
|
||||
errorReasonMessage = """🚫 Chyba: %s"""
|
||||
|
||||
# START
|
||||
|
||||
startSettingWalletMessage = """🧮 Nastavování peněženky..."""
|
||||
startWalletCreatedMessage = """🧮 Peněženka vytvořena."""
|
||||
startWalletReadyMessage = """✅ *Tvá peněženka je připravena.*"""
|
||||
startWalletErrorMessage = """🚫 Chyba při vytváření peněženky. Zkus to později znovu."""
|
||||
startNoUsernameMessage = """☝️ Vypadá to, že na Telegramu nemáš ještě uživatelské jméno (@username). Nevadí, pro používání tohoto bota ho nepotřebuješ. Nicméně, pro snazší používání peněženky si nastav uživatelské jméno v nastavení Telegramu. Poté zadej příkaz /balance a bot si zaktualizuje své záznamy."""
|
||||
|
||||
# BALANCE
|
||||
|
||||
balanceMessage = """👑 *Tvůj zůstatek:* %d sat"""
|
||||
balanceErrorMessage = """🚫 Nepodařilo se získat info o zůstatku. Zkus to později znovu."""
|
||||
|
||||
# TIP
|
||||
|
||||
tipDidYouReplyMessage = """Odpověděl jsi na zprávu kvůli platbě? Pro odpověď na jakoukoli zprávu na PC klikni pravým myšítkem a vyber ´Odpovědět´ nebo na mobilu přes zprávu přejeď do strany. Pokud chceš poslat platbu jinému uživateli přímo, použij příkaz /send"""
|
||||
tipInviteGroupMessage = """ℹ️ Tohoto bota můžeš přizvat do jakékoli skupiny a posílat v ní platby."""
|
||||
tipEnterAmountMessage = """Zadal jsi částku?"""
|
||||
tipValidAmountMessage = """Zadal jsi platnou částku?"""
|
||||
tipYourselfMessage = """📖 Nemůžeš poslat platbu sobě."""
|
||||
tipSentMessage = """💸 %d sats posláno pro %s."""
|
||||
tipReceivedMessage = """🏅 %s ti poslal %d sats."""
|
||||
tipErrorMessage = """🚫 Platba selhala."""
|
||||
tipUndefinedErrorMsg = """Prosím, zkus to později znovu."""
|
||||
tipHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/tip <částka> [<zpráva>]`
|
||||
*Příklad:* `/tip 1000 Díky moc!`"""
|
||||
|
||||
# SEND
|
||||
|
||||
sendValidAmountMessage = """Zadal jsi platnou částku?"""
|
||||
sendUserHasNoWalletMessage = """🚫 Uživatel %s si ještě nevytvořil peněženku."""
|
||||
sendSentMessage = """💸 %d sats posláno uživateli %s."""
|
||||
sendPublicSentMessage = """💸 %d sats posláno od %s uživateli %s."""
|
||||
sendReceivedMessage = """🏅 %s ti poslal %d sats."""
|
||||
sendErrorMessage = """🚫 Odeslání selhalo."""
|
||||
confirmSendMessage = """Chceš zaplatit uživateli %s?\n\n💸 Částka: %d sats"""
|
||||
confirmSendAppendMemo = """\n✉️ %s"""
|
||||
sendCancelledMessage = """🚫 Odeslání zrušeno."""
|
||||
errorTryLaterMessage = """🚫 Chyba. Prosím, zkus to později znovu."""
|
||||
sendSyntaxErrorMessage = """Zadal jsi částku a příjemce? Můžeš použít příkaz /send k poslání platby buď uživateli Telegramu jako %s nebo na lightning adresu jako LightningTipBot@ln.tips."""
|
||||
sendHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/send <částka> <uživatel> [<zpráva>]`
|
||||
*Příklad:* `/send 1000 @LightningTipBot Všichni jsme Satoshi ❤️`
|
||||
*Příklad:* `/send 1234 LightningTipBot@ln.tips`"""
|
||||
|
||||
# INVOICE
|
||||
|
||||
invoiceReceivedMessage = """⚡️ Obdržel jsi %d sats."""
|
||||
invoiceEnterAmountMessage = """Zadal jsi částku?"""
|
||||
invoiceValidAmountMessage = """Zadal jsi platnou částku?"""
|
||||
invoiceHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/invoice <částka> [<zpráva>]`
|
||||
*Příklad:* `/invoice 1000 Děkuji!`"""
|
||||
invoicePaidText = """✅ Invoice zaplacena."""
|
||||
|
||||
# PAY
|
||||
|
||||
paymentCancelledMessage = """🚫 Platba zrušena."""
|
||||
invoicePaidMessage = """⚡️ Platba odeslána."""
|
||||
invoicePublicPaidMessage = """⚡️ Platba od %s odeslána."""
|
||||
invalidInvoiceHelpMessage = """Máš platnou lightning invoice? Zkus příkaz /send k poslání platby uživateli Telegramu nebo na lightning adresu."""
|
||||
invoiceNoAmountMessage = """🚫 Nemůžu zaplatit invoice bez částky."""
|
||||
insufficientFundsMessage = """🚫 Nedostatek prostředků. Máš %d sats, ale potřebuješ alespoň %d sats."""
|
||||
feeReserveMessage = """⚠️ Odeslání celého zůstatku se nemusí zdařit kvůli poplatkům v síti. Nechej rezervu aspoň 1% na poplatky."""
|
||||
invoicePaymentFailedMessage = """🚫 Platba selhala: %s"""
|
||||
invoiceUndefinedErrorMessage = """Nemohl jsem zaplatit invoice."""
|
||||
confirmPayInvoiceMessage = """Chceš poslat tuto platbu?\n\n💸 Částka: %d sats"""
|
||||
confirmPayAppendMemo = """\n✉️ %s"""
|
||||
payHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/pay <invoice>`
|
||||
*Příklad:* `/pay lnbc20n1psscehd...`"""
|
||||
|
||||
# DONATE
|
||||
|
||||
donationSuccess = """🙏 Díky za tvůj příspěvek."""
|
||||
donationErrorMessage = """🚫 Ale ne, odeslání přspěvku selhalo."""
|
||||
donationProgressMessage = """🧮 Příprava odeslání příspěvku..."""
|
||||
donationFailedMessage = """🚫 Příspěvek selhal: %s"""
|
||||
donateEnterAmountMessage = """Zadal jsi částku?"""
|
||||
donateValidAmountMessage = """Zadal jsi platnou částku?"""
|
||||
donateHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/donate <částka>`
|
||||
*Příklad:* `/donate 1000`"""
|
||||
|
||||
# PHOTO
|
||||
|
||||
photoQrNotRecognizedMessage = """🚫 Lightning invoice nebo LNURL nešlo rozpoznat. Pokus se QR kód vycentrovat, oříznout, nebo ho více přiblížit."""
|
||||
photoQrRecognizedMessage = """✅ QR kód:
|
||||
`%s`"""
|
||||
|
||||
# LNURL
|
||||
|
||||
lnurlReceiveInfoText = """👇 Pro příjem plateb můžeš používat tuto statickou LNURL."""
|
||||
lnurlResolvingUrlMessage = """🧮 Zpracovávám adresu..."""
|
||||
lnurlGettingUserMessage = """🧮 Připravuji platbu..."""
|
||||
lnurlPaymentFailed = """🚫 Platba selhala: %s"""
|
||||
lnurlInvalidAmountMessage = """🚫 Neplatná částka."""
|
||||
lnurlInvalidAmountRangeMessage = """🚫 Částka musí být mezi %d a %d sats."""
|
||||
lnurlNoUsernameMessage = """🚫 Pro příjem plateb pomocí LNURL potřebuješ na Telegramu uživatelské jméno."""
|
||||
lnurlHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/lnurl [částka] <lnurl>`
|
||||
*Příklad:* `/lnurl LNURL1DP68GUR...`"""
|
||||
|
||||
# LNURL LOGIN
|
||||
|
||||
confirmLnurlAuthMessager = """Chceš se přihlásit do %s?"""
|
||||
lnurlSuccessfulLogin = """✅ Přihlášení úspěšné."""
|
||||
loginButtonMessage = """✅ Přihlásit"""
|
||||
loginCancelledMessage = """🚫 Přihlášení zrušeno."""
|
||||
|
||||
# LNURL WITHDRAW
|
||||
|
||||
confirmLnurlWithdrawMessage = """Chceš provést tento výběr?\n\n💸 Částka: %d sats"""
|
||||
lnurlPreparingWithdraw = """🧮 Příprava výběru..."""
|
||||
lnurlWithdrawFailed = """🚫 Výběr selhal."""
|
||||
lnurlWithdrawCancelled = """🚫 Výběr zrušen."""
|
||||
lnurlWithdrawSuccess = """✅ Výběr vyžádán."""
|
||||
|
||||
# LINK
|
||||
|
||||
walletConnectMessage = """🔗 *Propojit vlastní peněženku*
|
||||
|
||||
⚠️ Nikdy s nikým nesdílej URL nebo QR kód, jinak bude mít přístup k tvým prostředkům. Použij příkaz /api pro své API klíče.
|
||||
|
||||
- *BlueWallet:* Vyber *Nová peněženka*, *Importovat peněženku*, *Scanovat nebo importovat ze souboru* a nascanuj QR kód.
|
||||
- *Zeus:* Zkopíruj URL níže, vyber *Add a new node/Přidat novou nodu*, zvol *LNDHub* jako Node interface/Rozhraní nody, vlož URL a ulož nastavení *Save Node Config*."""
|
||||
couldNotLinkMessage = """🚫 Propojení s peněženkou se nezdařilo. Prosím, zkus to později znovu."""
|
||||
linkHiddenMessage = """🔍 Propojení je skryto. Abys ho znovu viděl, zadej /link příkaz."""
|
||||
|
||||
# API
|
||||
|
||||
apiConnectMessage = """🔗 *Tvé API klíče*
|
||||
|
||||
⚠️ Nikdy s nikým tyto klíče nesdílej, jinak bude mít přístup k tvým prostředkům. Použij příkaz /link k propojení své peněženky.
|
||||
|
||||
- *Admin klíč:* `%s`
|
||||
- *Invoice klíč:* `%s`"""
|
||||
apiHiddenMessage = """🔍 Klíče jsou skryty. Abys je znovu viděl, zadej /api příkaz."""
|
||||
|
||||
# FAUCET
|
||||
|
||||
inlineQueryFaucetTitle = """🚰 Vytvořit faucet."""
|
||||
inlineQueryFaucetDescription = """Použití: @%s faucet <kapacita> <částka_na_uživatele>"""
|
||||
inlineResultFaucetTitle = """🚰 Vytvořit faucet s %d sats."""
|
||||
inlineResultFaucetDescription = """👉 Klikni zde pro vytvoření faucetu v tomto chatu."""
|
||||
|
||||
inlineFaucetMessage = """Zmáčkni ✅ pro výběr %d sats z faucetu od %s.
|
||||
|
||||
🚰 Zbývá: %d/%d sats (rozdáno %d/%d uživatelům)
|
||||
%s"""
|
||||
inlineFaucetEndedMessage = """🚰 Faucet je prázdný 🍺\n\n🏅 %d sats rozdáno %d uživatelům."""
|
||||
inlineFaucetAppendMemo = """\n✉️ %s"""
|
||||
inlineFaucetCreateWalletMessage = """Komunikuj s %s 👈 pro správu své peněženky."""
|
||||
inlineFaucetCancelledMessage = """🚫 Faucet zrušen."""
|
||||
inlineFaucetInvalidPeruserAmountMessage = """🚫 Částka na uživatele musí dělit kapacitu faucetu beze zbytku nebo je příliš malá (min 5 sats)."""
|
||||
inlineFaucetInvalidAmountMessage = """🚫 Neplatná částka."""
|
||||
inlineFaucetSentMessage = """🚰 %d sats posláno %s."""
|
||||
inlineFaucetReceivedMessage = """🚰 %s ti poslal %d sats."""
|
||||
inlineFaucetHelpFaucetInGroup = """Vytvoř faucet ve skupině s botem nebo použij 👉 inline příkaz (napiš /advanced pro víc info)."""
|
||||
inlineFaucetAlreadyTookMessage = """🚫 Z tohoto faucetu už jsi čerpal."""
|
||||
inlineFaucetHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/faucet <kapacita> <částka_na_uživatele>`
|
||||
*Příklad:* `/faucet 210 21`"""
|
||||
|
||||
# INLINE SEND
|
||||
|
||||
inlineQuerySendTitle = """💸 Poslat platbu do chatu."""
|
||||
inlineQuerySendDescription = """Použití: @%s send <částka> [<uživatel>] [<zpráva>]"""
|
||||
inlineResultSendTitle = """💸 Poslat %d sats."""
|
||||
inlineResultSendDescription = """👉 Klikni pro poslání %d sats do tohoto chatu."""
|
||||
|
||||
inlineSendMessage = """Zmáčkni ✅ pro obdržení platby od %s.\n\n💸 Částka: %d sats"""
|
||||
inlineSendAppendMemo = """\n✉️ %s"""
|
||||
inlineSendUpdateMessageAccept = """💸 %d sats posláno od %s uživateli %s."""
|
||||
inlineSendCreateWalletMessage = """Chatuj s %s 👈 pro správu své peněženky."""
|
||||
sendYourselfMessage = """📖 Nemůžeš platit sám sobě."""
|
||||
inlineSendFailedMessage = """🚫 Platba selhala."""
|
||||
inlineSendInvalidAmountMessage = """🚫 Částka musí být větší než 0."""
|
||||
inlineSendBalanceLowMessage = """🚫 Tvůj zůstatek je příliš malý."""
|
||||
|
||||
# INLINE RECEIVE
|
||||
|
||||
inlineQueryReceiveTitle = """🏅 Vyžádat platbu v chatu."""
|
||||
inlineQueryReceiveDescription = """Použití: @%s receive <částka> [<uživatel>] [<zpráva>]"""
|
||||
inlineResultReceiveTitle = """🏅 Dostat %d sats."""
|
||||
inlineResultReceiveDescription = """👉 Klikni pro vyžádání platby %d sats."""
|
||||
|
||||
inlineReceiveMessage = """Zmáčkni 💸 pro zaplacení uživateli %s.\n\n💸 Částka: %d sats"""
|
||||
inlineReceiveAppendMemo = """\n✉️ %s"""
|
||||
inlineReceiveUpdateMessageAccept = """💸 %d sats posláno od %s uživateli %s."""
|
||||
inlineReceiveCreateWalletMessage = """Chatuj s %s 👈 pro správu své peněženky."""
|
||||
inlineReceiveYourselfMessage = """📖 Nemůžeš platit sám sobě."""
|
||||
inlineReceiveFailedMessage = """🚫 Platba selhala."""
|
||||
inlineReceiveCancelledMessage = """🚫 Platba zrušena."""
|
||||
|
||||
# TIPJAR
|
||||
|
||||
inlineQueryTipjarTitle = """🍯 Vytvořit tipjar."""
|
||||
inlineQueryTipjarDescription = """Použití: @%s tipjar <kapacita> <částka_od_uživatele>"""
|
||||
inlineResultTipjarTitle = """🍯 Vytvořit tipjar na %d sats."""
|
||||
inlineResultTipjarDescription = """👉 Klikni zde pro vytvoření tipjar v tomto chatu."""
|
||||
|
||||
inlineTipjarMessage = """Zmáčkni 💸 pro *platbu %d sats* do tohoto tipjar od %s.
|
||||
|
||||
🙏 Věnováno: *%d*/%d sats (od %d uživatelů)
|
||||
%s"""
|
||||
inlineTipjarEndedMessage = """🍯 Tipjar od %s je plný ⭐️\n\n🏅 Věnováno %d sats od %d uživatelů."""
|
||||
inlineTipjarAppendMemo = """\n✉️ %s"""
|
||||
inlineTipjarCancelledMessage = """🚫 Tipjar zrušen."""
|
||||
inlineTipjarInvalidPeruserAmountMessage = """🚫 Částka od jednoho uživatele musí dělit kapacitu tipjar beze zbytku."""
|
||||
inlineTipjarInvalidAmountMessage = """🚫 Neplatná částka."""
|
||||
inlineTipjarSentMessage = """🍯 %d sats posláno pro %s."""
|
||||
inlineTipjarReceivedMessage = """🍯 %s ti poslal %d sats."""
|
||||
inlineTipjarHelpTipjarInGroup = """Vytvoř tipjar ve skupině s botem nebo použij 👉 inline příkaz (/advanced pro víc info)."""
|
||||
inlineTipjarHelpText = """📖 Ou, tohle se nezdařilo. %s
|
||||
|
||||
*Použití:* `/tipjar <kapacita> <částka_od_uživatele>`
|
||||
*Příklad:* `/tipjar 210 21`"""
|
||||
|
||||
# GROUP TICKETS
|
||||
groupAddGroupHelpMessage = """📖 Ou, tohle se nezdařilo. Tento příkaz funguje pouze ve skupinovém chatu. Mohou ho použít pouze vlastníci skupin.\nPoužití: `/group add <název_skupiny> [<částka>]`\nPříklad: `/group add NejvícHustáSkupina 1000`"""
|
||||
groupJoinGroupHelpMessage = """📖 Ou, tohle se nezdařilo. Prosím, zkus to znovu.\nPoužití: `/join <název_skupiny>`\nPříklad: `/join NejvícHustáSkupina`"""
|
||||
groupClickToJoinMessage = """🎟 [Klikni zde](%s) 👈 pro připojení `%s`."""
|
||||
groupTicketIssuedGroupMessage = """🎟 Uživatel %s obdržel vstupenku do této skupiny."""
|
||||
groupPayInvoiceMessage = """🎟 Pro připojení se ke skupině %s, zaplať výše uvedenou invoice."""
|
||||
groupBotIsNotAdminMessage = """🚫 Ou, tohle se nezdařilo. Musíš mě jmenovat adminem a dát mi práva zvát uživatele."""
|
||||
groupNameExists = """🚫 Skupina s tímto názvem už existuje. Prosím, vyber jiný název."""
|
||||
groupAddedMessage = """🎟 Vstupenky pro skupinu `%s` přidány.\nAlias: `%s` Cena: %d sats\n\nPro vyžádání vstupenky do této skupiny začni soukromý chat s %s a napiš `/join %s`."""
|
||||
groupNotFoundMessage = """🚫 Skupinu s tímto názvem se nepodařilo najít."""
|
||||
groupReceiveTicketInvoiceCommission = """🎟 Obdržel jsi *%d sats* (bez provize %d sats) za vstupenku do skupiny `%s` od uživatele %s."""
|
||||
groupReceiveTicketInvoice = """🎟 Obdržel jsi *%d sats* za vstupenku do skupiny `%s` od uživatele %s."""
|
||||
commandPrivateMessage = """Prosím, použij tento příkaz v soukromém chatu s %s."""
|
||||
groupHelpMessage = """🎟 Vstupenky do soukromých skupin 🎟
|
||||
|
||||
Prodej vstupenky do své _soukromé skupiny_ a zbavíš se spam botů.
|
||||
|
||||
*Pokyny pro skupinové adminy:*
|
||||
|
||||
1) Pozvi %s do své skupiny a udělej ho adminem.
|
||||
2) Skupinu změň na soukromou.
|
||||
3) Ve své skupině, jako její majitel, napiš `/group add <název_skupiny> [<cena_vstupenky>]`.
|
||||
|
||||
_Poplatky: Bot si bere provizi 10%% +10 sats za levné vstupenky. Je-li cena vstupenky >= 1000 sats, je provize 2%% + 100 sats._
|
||||
|
||||
*Pokyny pro členy skupin:*
|
||||
|
||||
Pro připojení ke skupině si promluv s %s a v soukromé zprávě napiš `/join <název_skupiny>`.
|
||||
|
||||
📖 *Použití:*
|
||||
*Pro adminy (ve skupinovém chatu):* `/group add <název_skupiny> [<cena_vstupenky>]`\nPříklad: `/group add NejvícHustáSkupina 1000`
|
||||
*Pro uživatele (v soukromém chatu):* `/join <název_skupiny>`\nPříklad: `/join NejvícHustáSkupina`"""
|
||||
|
||||
# DALLE GENERATE
|
||||
generateDalleHelpMessage = """Vytvořit obrázky pomocí OpenAI DALLE 2.\nPoužití: `/generate <prompt>`\nCena: 1000 sat"""
|
||||
generateDallePayInvoiceMessage = """Zaplať tuto invoice pro vytvoření 4 obrázků 👇"""
|
||||
generateDalleGeneratingMessage = """Tvé obrázky se generují. Chvilku strpení..."""
|
||||
+16
-3
@@ -120,11 +120,13 @@ advancedMessage = """%s
|
||||
⚙️ *Fortgeschrittene Befehle*
|
||||
*/transactions* 📊 Liste der Transaktionen
|
||||
*/link* 🔗 Verbinde dein Wallet mit [BlueWallet](https://bluewallet.io/) oder [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Lnurl empfangen oder senden: `/lnurl` oder `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Lnurl empfangen oder senden: `/lnurl` oder `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Erzeuge einen Zapfhahn: `/faucet <gesamt> <pro_user>`
|
||||
*/tipjar* 🍯 Erzeuge eine Spendendose: `/tipjar <gesamt> <pro_user>`
|
||||
*/group* 🎟 Tickets für Gruppenchats: `/group add <meine_gruppe> [<ticket_preis>]`
|
||||
*/shop* 🛍 Durchsuche shops: `/shop` oder `/shop <user/shop_id>`"""
|
||||
*/shop* 🛍 Durchsuche Shops: `/shop` oder `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generiere Bilder mit DALLE-2: `/generate <beschreibung>`
|
||||
*/chat* 💬 Chatte mit GPT: `/chat <nachricht>`"""
|
||||
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Gebe Betrag zwuschen %d und %d sat ein."""
|
||||
@@ -260,11 +262,22 @@ lnurlWithdrawSuccess = """✅ Abhebung angefordert."""
|
||||
|
||||
walletConnectMessage = """🔗 *Verbinde dein Wallet*
|
||||
|
||||
⚠️ Teile diese URL und den QR code mit niemandem! Jeder, der darauf Zugriff hat, hat auch Zugriff auf dein Konto.
|
||||
⚠️ Teile diese URL und den QR code mit niemandem! Jeder, der darauf Zugriff hat, hat auch Zugriff auf dein Konto. Nutze /api für deine API keys.
|
||||
|
||||
- *BlueWallet:* Drücke *New wallet*, *Import wallet*, *Scan or import a file*, und scanne den QR Code.
|
||||
- *Zeus:* Kopiere die URL unten, drücke *Add a new node*, *Import* (die URL), *Save Node Config*."""
|
||||
couldNotLinkMessage = """🚫 Konnte dein Wallet nicht verbinden. Bitte versuche es später noch einmal."""
|
||||
linkHiddenMessage = """🔍 Link versteckt. Gebe /link ein um ihn wieder zu sehen."""
|
||||
|
||||
# API
|
||||
|
||||
walletConnectMessage = """🔗 *Deine API Keys*
|
||||
|
||||
⚠️ Teile diese Key mit niemandem! Jeder, der darauf Zugriff hat, hat auch Zugriff auf dein Konto. Nutze /link um dein Wallet zu verbinden.
|
||||
|
||||
- *Admin key:* `%s`
|
||||
- *Invoice key:* `%s`"""
|
||||
apiHiddenMessage = """🔍 Keys versteckt. Gebe /api ein um sie wieder zu sehen."""
|
||||
|
||||
# FAUCET
|
||||
|
||||
|
||||
+21
-4
@@ -123,16 +123,18 @@ advancedMessage = """%s
|
||||
⚙️ *Advanced commands*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Link your wallet to [BlueWallet](https://bluewallet.io/) or [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Lnurl receive or pay: `/lnurl` or `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Lnurl receive or pay: `/lnurl` or `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Create a faucet: `/faucet <capacity> <per_user>`
|
||||
*/tipjar* 🍯 Create a tipjar: `/tipjar <capacity> <per_user>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`"""
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generate DALLE-2 images: `/generate <prompt>`"""
|
||||
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Enter an amount between %d and %d sat."""
|
||||
enterAmountMessage = """💯 Enter an amount."""
|
||||
enterUserMessage = """👤 Enter a user."""
|
||||
enterTextMessage = """⌨️ Enter text."""
|
||||
errorReasonMessage = """🚫 Error: %s"""
|
||||
|
||||
# START
|
||||
@@ -264,13 +266,23 @@ lnurlWithdrawSuccess = """✅ Withdrawal requested."""
|
||||
|
||||
walletConnectMessage = """🔗 *Link your wallet*
|
||||
|
||||
⚠️ Never share the URL or the QR code with anyone or they will be able to access your funds.
|
||||
⚠️ Never share the URL or the QR code with anyone or they will be able to access your funds. Use /api for your API keys.
|
||||
|
||||
- *BlueWallet:* Press *New wallet*, *Import wallet*, *Scan or import a file*, and scan the QR code.
|
||||
- *Zeus:* Copy the URL below, press *Add a new node*, select *LNDHub* as Node interface, enter the URL, *Save Node Config*."""
|
||||
couldNotLinkMessage = """🚫 Couldn't link your wallet. Please try again later."""
|
||||
linkHiddenMessage = """🔍 Link hidden. Enter /link to see it again."""
|
||||
|
||||
# API
|
||||
|
||||
apiConnectMessage = """🔗 *Your API keys*
|
||||
|
||||
⚠️ Never share these keys with anyone or they will be able to access your funds. Use /link to link your wallet.
|
||||
|
||||
- *Admin key:* `%s`
|
||||
- *Invoice key:* `%s`"""
|
||||
apiHiddenMessage = """🔍 Keys hidden. Enter /api to see them again."""
|
||||
|
||||
# FAUCET
|
||||
|
||||
inlineQueryFaucetTitle = """🚰 Create a faucet."""
|
||||
@@ -383,4 +395,9 @@ To join a group, talk to %s and write in a private message `/join <mygroup>`.
|
||||
|
||||
📖 *Usage:*
|
||||
*For admins (in group chat):* `/group add <group_name> [<ticket_price>]`\nExample: `/group add TheBestBitcoinGroup 1000`
|
||||
*For users (in private chat):* `/join <group_name>`\nExample: `/join TheBestBitcoinGroup`"""
|
||||
*For users (in private chat):* `/join <group_name>`\nExample: `/join TheBestBitcoinGroup`"""
|
||||
|
||||
# DALLE GENERATE
|
||||
generateDalleHelpMessage = """Generate images using OpenAI DALLE 2.\nUsage: `/generate <prompt>`\nPrice: 1000 sat"""
|
||||
generateDallePayInvoiceMessage = """Pay this invoice to generate four images 👇"""
|
||||
generateDalleGeneratingMessage = """Your images are being generated. Please wait..."""
|
||||
@@ -119,12 +119,12 @@ advancedMessage = """%s
|
||||
⚙️ *Comandos avanzados*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Enlaza tu monedero a [ BlueWallet ](https://bluewallet.io/) o [ Zeus ](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Lnurl recibir o pagar: `/lnurl` o `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Lnurl recibir o pagar: `/lnurl` o `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Crear un grifo: `/faucet <capacidad> <por_usuario>`
|
||||
*/tipjar* 🍯 Crear un tipjar: `/tipjar <capacidad> <por_usuario>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`"""
|
||||
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generate DALLE-2 images: `/generate <prompt>`"""
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Introduce un monto entre %d y %d sat."""
|
||||
enterAmountMessage = """💯 Introduce un monto."""
|
||||
|
||||
@@ -119,12 +119,12 @@ advancedMessage = """%s
|
||||
⚙️ *Commandes avancées*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Lier votre wallet à [BlueWallet](https://bluewallet.io/) ou [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Lnurl recevoir ou payer: `/lnurl` ou `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Lnurl recevoir ou payer: `/lnurl` ou `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Créer un faucet: `/faucet <capacité> <par_utilisateur>`
|
||||
*/tipjar* 🍯 Créer un tipjar: `/tipjar <capacité> <par_utilisateur>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`"""
|
||||
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generate DALLE-2 images: `/generate <prompt>`"""
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Choisissez un montant entre %d et %d sat."""
|
||||
enterAmountMessage = """💯 Choisissez un montant."""
|
||||
@@ -228,7 +228,7 @@ photoQrRecognizedMessage = """✅ QR code:
|
||||
|
||||
# LNURL
|
||||
|
||||
lnurlReceiveInfoText = """👇 Vous ne pouvez pas utiliser cet LNURL pour recevoir des paiements."""
|
||||
lnurlReceiveInfoText = """👇 Vous pouvez utiliser cet LNURL pour recevoir des paiements."""
|
||||
lnurlResolvingUrlMessage = """🧮 Recherche de l'adresse..."""
|
||||
lnurlGettingUserMessage = """🧮 Préparation du paiement..."""
|
||||
lnurlPaymentFailed = """🚫 Echec du paiement : %s"""
|
||||
|
||||
@@ -119,12 +119,12 @@ advancedMessage = """%s
|
||||
⚙️ *Perintah lanjutan*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Menghubungkan dompet mu ke [BlueWallet](https://bluewallet.io/) atau [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Lnurl menerima atau membayar: `/lnurl` atau `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Lnurl menerima atau membayar: `/lnurl` atau `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Membuat sebuah keran `/faucet <kapasitas> <per_pengguna>`
|
||||
*/tipjar* 🍯 Create a tipjar: `/tipjar <capacity> <per_user>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`"""
|
||||
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generate DALLE-2 images: `/generate <prompt>`"""
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Masukkan jumlah diantara %d dan %d sat."""
|
||||
enterAmountMessage = """💯 Masukkan jumlah."""
|
||||
|
||||
@@ -119,12 +119,12 @@ advancedMessage = """%s
|
||||
⚙️ *Comandi avanzati*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Crea un collegamento al tuo wallet [BlueWallet](https://bluewallet.io/) o [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Ricevi o paga un Lnurl: `/lnurl` or `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Ricevi o paga un Lnurl: `/lnurl` or `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Crea una distribuzione: `/faucet <totale> <per_utente>`
|
||||
*/tipjar* 🍯 Crea un tipjar: `/tipjar <totale> <per_utente>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`"""
|
||||
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generate DALLE-2 images: `/generate <prompt>`"""
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Imposta un ammontare tra %d e %d sat."""
|
||||
enterAmountMessage = """💯 Imposta un ammontare."""
|
||||
|
||||
@@ -119,12 +119,12 @@ advancedMessage = """%s
|
||||
⚙️ *Geavanceerde opdrachten*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Koppel uw wallet aan [BlueWallet](https://bluewallet.io/) of [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Lnurl ontvangen of betalen: `/lnurl` of `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Lnurl ontvangen of betalen: `/lnurl` of `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Maak een kraan: `/faucet <capacity> <per_user>`
|
||||
*/tipjar* 🍯 Maak een tipjar: `/tipjar <capacity> <per_user>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`"""
|
||||
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generate DALLE-2 images: `/generate <prompt>`"""
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Voer een bedrag in tussen %d en %d sat."""
|
||||
enterAmountMessage = """💯 Voer een bedrag."""
|
||||
|
||||
@@ -0,0 +1,404 @@
|
||||
# COMMANDS
|
||||
|
||||
helpCommandStr = """pomoc"""
|
||||
basicsCommandStr = """podstawy"""
|
||||
tipCommandStr = """tip"""
|
||||
balanceCommandStr = """saldo"""
|
||||
sendCommandStr = """wyślij"""
|
||||
invoiceCommandStr = """faktura"""
|
||||
payCommandStr = """pay"""
|
||||
donateCommandStr = """donate"""
|
||||
advancedCommandStr = """advanced"""
|
||||
transactionsCommandStr = """transactions"""
|
||||
logCommandStr = """log"""
|
||||
listCommandStr = """list"""
|
||||
|
||||
linkCommandStr = """link"""
|
||||
lnurlCommandStr = """lnurl"""
|
||||
faucetCommandStr = """faucet"""
|
||||
|
||||
tipjarCommandStr = """tipjar"""
|
||||
receiveCommandStr = """receive"""
|
||||
hideCommandStr = """hide"""
|
||||
volcanoCommandStr = """volcano"""
|
||||
showCommandStr = """show"""
|
||||
optionsCommandStr = """options"""
|
||||
settingsCommandStr = """settings"""
|
||||
saveCommandStr = """save"""
|
||||
deleteCommandStr = """delete"""
|
||||
infoCommandStr = """info"""
|
||||
|
||||
# NOTIFICATIONS
|
||||
|
||||
cantDoThatMessage = """Nie możesz tego zrobić."""
|
||||
cantClickMessage = """Nie możesz kliknąć tego przycisku."""
|
||||
balanceTooLowMessage = """Twoje saldo jest za niskie."""
|
||||
|
||||
# BUTTONS
|
||||
|
||||
sendButtonMessage = """✅ Wyślij"""
|
||||
payButtonMessage = """✅ Zapłać"""
|
||||
payReceiveButtonMessage = """💸 Zapłać"""
|
||||
receiveButtonMessage = """✅ Otrzymaj"""
|
||||
withdrawButtonMessage = """✅ Wypłać"""
|
||||
cancelButtonMessage = """🚫 Anuluj"""
|
||||
collectButtonMessage = """✅ Odbierz"""
|
||||
nextButtonMessage = """Dalej"""
|
||||
backButtonMessage = """Cofnij"""
|
||||
acceptButtonMessage = """Potwierdź"""
|
||||
denyButtonMessage = """Odmów"""
|
||||
tipButtonMessage = """Tip"""
|
||||
revealButtonMessage = """Ujawnij"""
|
||||
showButtonMessage = """Pokaż"""
|
||||
hideButtonMessage = """Ukryj"""
|
||||
joinButtonMessage = """Dołącz"""
|
||||
optionsButtonMessage = """Opcje"""
|
||||
settingsButtonMessage = """Ustawienia"""
|
||||
saveButtonMessage = """Zapisz"""
|
||||
deleteButtonMessage = """Skasuj"""
|
||||
infoButtonMessage = """Informacje"""
|
||||
|
||||
cancelButtonEmoji = """🚫"""
|
||||
payButtonEmoji = """💸"""
|
||||
|
||||
# HELP
|
||||
|
||||
helpMessage = """⚡️ *Portfel*
|
||||
_Ten bot jest portfelem Bitcoin Lightning, który potrafi wysyłać napiwki na Telegramie. Aby zacząć dodaj tego bota do chatu grupowego. Podstawową jednostką dla napiwków są Satoshi (sat). 100 000 000 sat = 1 Bitcoin. Napisz 📚 /basics aby uzyskać więcej informacji._
|
||||
|
||||
❤️ *Wsparcie*
|
||||
_Ten bot nie pobiera opłat, ale jego funkcjonowanie kosztuje. Jeśli podoba Ci się, rozważ proszę wsparcie tego projektu darowizną. Aby to zrobić użyj_ `/donate 1000`
|
||||
|
||||
%s
|
||||
|
||||
⚙️ *Komendy*
|
||||
*/tip* 🏅 Odpowiedz na wiadomość aby dać napiwek: `/tip <kwota> [<notatka>]`
|
||||
*/balance* 👑 Sprawdź swoje saldo: `/balance`
|
||||
*/send* 💸 Wyślij środki do użytkownika: `/send <kwota> @użytkownik lub użytkownik@ln.tips [<notatka>]`
|
||||
*/invoice* ⚡️ Otrzymaj przy pomocy Lightning: `/invoice <kwota> [<notatka>]`
|
||||
*/pay* ⚡️ Zapłać przy pomocy Lightning: `/pay <faktura>`
|
||||
*/donate* ❤️ Wesprzyj projekt darowizną: `/donate 1000`
|
||||
*/advanced* 🤖 Funkcje zaawansowane.
|
||||
*/help* 📖 Przeczytaj tę stronę o pomocy."""
|
||||
|
||||
infoHelpMessage = """ℹ️ *Informacje*"""
|
||||
infoYourLightningAddress = """Twój adres Lightning to `%s`"""
|
||||
|
||||
basicsMessage = """🧡 *Bitcoin*
|
||||
_Bitcoin jest walutą internetu. Nie wymaga pozwolenia, jest zdecentralizowany i nie ma władców ani kontrolujących go instytucji. Bitcoin jest twardym pieniądzem, który jest szybszy, bezpieczniejszy i inkluzywny niż dotychczasowy system finansowy._
|
||||
|
||||
🧮 *Ekonomia*
|
||||
_Najmniejszą jednostką Bitcoina są Satoshi (sat) a 100 00 00 sat = 1 Bitcoin. Zawsze będzie tylko 21 milionów Bitcoinów. Ich cena w walucie fiducjarnego może zmieniać się codziennie. Jednak jeśli żyjesz na standardziej Bitcoina 1 sat zawsze będzie równy 1 sat._
|
||||
|
||||
⚡️ *Sieć Lightning*
|
||||
_Sieć Lightning jest protokołem, który umożliwia szybkie i tanie płatności w Bitcoinie, nie potrzebujące do tego prawie żadnej energii. Dzięki temu umożliwia dotarcie do miliardów ludzi na całym świecie._
|
||||
|
||||
📲 *Portfele Lightning*
|
||||
_Twoje środki na tym bocie mogą być wysłane na inne portfele Lightning i vice versa. Rekomendowane portfele dla Twojego telefonu to_ [Phoenix](https://phoenix.acinq.co/)_,_ [Breez](https://breez.technology/)_,_ [Muun](https://muun.com/)_ (niepowierniczy), lub_ [Wallet of Satoshi](https://www.walletofsatoshi.com/) _(łatwy)_.
|
||||
|
||||
📄 *Open Source*
|
||||
_Ten bot to wolne oprogramowanie [open source](https://github.com/LightningTipBot/LightningTipBot)_. Możesz go uruchomić na własnym komputerze i używać we własnej społeczności._
|
||||
|
||||
✈️ *Telegram*
|
||||
_Dodaj tego bota do swojego chatu grupowego na Telegramie aby dawać napiwki za wiadomości. Jeśli uczynisz bota adminem grupy będzie czyścił komendy aby chat był uporządkowany._
|
||||
|
||||
🏛 *Warunki*
|
||||
_Nie jesteśmy powiernikiem Twoich środków. Będziemy działać w Twoim najlepszym interesie ale jesteśmy świadomi tego, że sytuacja bez KYC jest trudna dopóki czegoś nie wymyślimy.
|
||||
Jakakolwiek kwota, którą załadujesz na portfel będzie traktowana jako darowizna. Nie dawaj nam wszystkich swoich pieniędzy. Wiedz, że ten bota jest w fazie rozwoju beta. Używaj go na własne ryzko._
|
||||
|
||||
❤️ *Wesprzyj darowizną*
|
||||
_Ten bot nie pobiera opłat, ale jego funkcjonowanie kosztuje. Jeśli podoba Ci się, rozważ proszę wsparcie tego projektu darowizną. Aby to zrobić użyj `/donate 1000`"""
|
||||
|
||||
helpNoUsernameMessage = """👋 Podaj proszę nazwę swojego użytkownika w Telegramie."""
|
||||
|
||||
advancedMessage = """%s
|
||||
|
||||
👉 *Komendy inline*
|
||||
*send* 💸 Wysyła sats na chat: `%s send <kwota> [<użytkownik>] [<notatka>]`
|
||||
*receive* 🏅 Prosi o płatność: `... receive <kwota> [<użytkownik>] [<notatka>]`
|
||||
*faucet* 🚰 Tworzy kranik (_faucet_): `... faucet <pojemność> <na_użytkownika> [<notatka>]`
|
||||
*tipjar* 🍯 Tworzy słoik na napiwki (_tipjar_): `... tipjar <pojemność> <na_użytkownika> [<notatka>]`
|
||||
|
||||
📖 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.
|
||||
|
||||
⚙️ *Komendy zaawansowane*
|
||||
*/transactions* 📊 Lista transakcji
|
||||
*/link* 🔗 Połączenie Twojego portfela z [BlueWallet](https://bluewallet.io/) lub [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Przyjmij płatność lub zapłać za pomocą Lnurl: `/lnurl` lub `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Stwórz kranik (_faucet_): `/faucet <pojemność> <na_użytkownika>`
|
||||
*/tipjar* 🍯 Stwórz słoik na napiwki (_tipjar_): `/tipjar <pojemność> <na_użytkownika>`
|
||||
*/group* 🎟 Stwórz bilety na wejście do grupy: `/group add <mojagrupa> [<cena_biletu>]`
|
||||
*/shop* 🛍 Przeglądaj sklepy: `/shop` lub `/shop <użytkownik/id_sklepu>`
|
||||
*/generate* 🎆 Generuj obrazy przy użyciu DALLE-2: `/generate <podpowiedź>`"""
|
||||
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Wprowadź kwotę między %d a %d sat."""
|
||||
enterAmountMessage = """💯 Wprowadź kwotę."""
|
||||
enterUserMessage = """👤 Podaj użytkownika."""
|
||||
enterTextMessage = """⌨️ Wprowadź tekst."""
|
||||
errorReasonMessage = """🚫 Błąd: %s"""
|
||||
|
||||
# START
|
||||
|
||||
startSettingWalletMessage = """🧮 Tworzę Twój portfel..."""
|
||||
startWalletCreatedMessage = """🧮 Portfel utworzony."""
|
||||
startWalletReadyMessage = """✅ *Twój portfel jest gotowy.*"""
|
||||
startWalletErrorMessage = """🚫 Błąd przy inicjowaniu Twojego portfela. Spróbuj ponownie później."""
|
||||
startNoUsernameMessage = """☝️ Wygląda na to, że nie masz jeszcze nazwy @użytkownika w Telegramie. Nic nie szkodzi, nie potrzebujesz jej by używać tego bota. Jednak aby lepiej go wykorzystać, ustaw nazwę w ustawieniach aplikacji Telegram. Następnie napisz /balance aby bot mógł zaktualizować swoje dane o Tobie."""
|
||||
|
||||
# BALANCE
|
||||
|
||||
balanceMessage = """👑 *Twoje saldo:* %d sat"""
|
||||
balanceErrorMessage = """🚫 Pobranie Twojego salda nie powiodło się. Spróbuj ponownie później."""
|
||||
|
||||
# TIP
|
||||
|
||||
tipDidYouReplyMessage = """Czy odpowiadasz na wiadomość aby dać napiwek? Aby odpowiedzieć na jakąkolwiek wiadomość na komputerze, naciśnij prawy przycisk myszy i wybierz Odpowiedz, a na telefonie przesuń palcem. Jeśli chcesz wysłać bezpośrednio do innego użytkownika użyj komendy /send."""
|
||||
tipInviteGroupMessage = """ℹ️ Przy okazji, możesz zaprosić tego bota do dowolnej grupy aby zacząć dawać napiwki tam."""
|
||||
tipEnterAmountMessage = """Czy wprowadzono kwotę?"""
|
||||
tipValidAmountMessage = """Czy wprowadzono poprawną kwotę?"""
|
||||
tipYourselfMessage = """📖 Nie możesz dać sobie napiwku."""
|
||||
tipSentMessage = """💸 %d sat wysłano do %s."""
|
||||
tipReceivedMessage = """🏅 %s daje Ci napiwek w wysokości %d sat."""
|
||||
tipErrorMessage = """🚫 Napiwek się nie powiódł."""
|
||||
tipUndefinedErrorMsg = """spróbuj proszę później."""
|
||||
tipHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/tip <kwota> [<notatka>]`
|
||||
*Przykład:* `/tip 1000 pojechany mem!`"""
|
||||
|
||||
# SEND
|
||||
|
||||
sendValidAmountMessage = """Czy podano poprawną kwotę?"""
|
||||
sendUserHasNoWalletMessage = """🚫 Użytkownik %s jeszcze nie utworzył portfela."""
|
||||
sendSentMessage = """💸 %d sat wysłano do %s."""
|
||||
sendPublicSentMessage = """💸 %d sat wysłano od %s do %s."""
|
||||
sendReceivedMessage = """🏅 %s przysyła Ci %d sat."""
|
||||
sendErrorMessage = """🚫 Wysłanie nie powiodło się."""
|
||||
confirmSendMessage = """Czy chcesz zapłacić %s?\n\n💸 Kwota: %d sat"""
|
||||
confirmSendAppendMemo = """\n✉️ %s"""
|
||||
sendCancelledMessage = """🚫 Wysłanie anulowane."""
|
||||
errorTryLaterMessage = """🚫 Błąd. Spróbuj ponownie później."""
|
||||
sendSyntaxErrorMessage = """Czy wpropwadzono kwotę i odbiorcę? Możesz użyć komendy /send albo żeby wysłać do użytkownika takiego jak %s lub pod adres Lightning taki jak LightningTipBot@ln.tips."""
|
||||
sendHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/send <kwota> <użytkownik> [<notatka>]`
|
||||
*Przykład:* `/send 1000 @LightningTipBot Po prostu lubię tego bota ❤️`
|
||||
*Przykład:* `/send 1234 LightningTipBot@ln.tips`"""
|
||||
|
||||
# INVOICE
|
||||
|
||||
invoiceReceivedMessage = """⚡️ Otrzymujesz %d sat."""
|
||||
invoiceEnterAmountMessage = """Czy wprowadzono kwotę?"""
|
||||
invoiceValidAmountMessage = """Czy wprowadzono poprawną kwotę?"""
|
||||
invoiceHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/invoice <kwota> [<notatka>]`
|
||||
*Przykład:* `/invoice 1000 Dziękuję!`"""
|
||||
invoicePaidText = """✅ Faktura załacona."""
|
||||
|
||||
# PAY
|
||||
|
||||
paymentCancelledMessage = """🚫 Płatność anulowana."""
|
||||
invoicePaidMessage = """⚡️ Płatność wysłana."""
|
||||
invoicePublicPaidMessage = """⚡️ Płatność wysłana przez %s."""
|
||||
invalidInvoiceHelpMessage = """Czy podajesz poprawną fakturę Lightning? Spróbuj /send jeśli chcesz wysłać do użytkownika na Telegramie lub pod adres Lightning."""
|
||||
invoiceNoAmountMessage = """🚫 Nie można opłacić faktury bez kwoty."""
|
||||
insufficientFundsMessage = """🚫 Niewystarczające środki. Masz %d sat a potrzebujesz conajmniej %d sat."""
|
||||
feeReserveMessage = """⚠️ Wysyłanie swojego całkowitego salda może się nie powieść z powodu opłat sieciowych. Zarezerwuj conajmniej 1% na opłaty."""
|
||||
invoicePaymentFailedMessage = """🚫 Płatność nie powiodła się: %s"""
|
||||
invoiceUndefinedErrorMessage = """Nie można było zapłacić faktury."""
|
||||
confirmPayInvoiceMessage = """Czy chcesz wysłać tę płatność?\n\n💸 Kwota: %d sat"""
|
||||
confirmPayAppendMemo = """\n✉️ %s"""
|
||||
payHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/pay <faktura>`
|
||||
*Przykład:* `/pay lnbc20n1psscehd...`"""
|
||||
|
||||
# DONATE
|
||||
|
||||
donationSuccess = """🙏 Dziękuję za twoją darowiznę."""
|
||||
donationErrorMessage = """🚫 O nie! Darowizna nie powiodła się."""
|
||||
donationProgressMessage = """🧮 Przygotowuję Twoją darowiznę..."""
|
||||
donationFailedMessage = """🚫 Darowizna nie powiodła się: %s"""
|
||||
donateEnterAmountMessage = """Czy podano kwotę?"""
|
||||
donateValidAmountMessage = """Czy podano poprawną kwotę?"""
|
||||
donateHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/donate <kwota>`
|
||||
*Przykład:* `/donate 1000`"""
|
||||
|
||||
# PHOTO
|
||||
|
||||
photoQrNotRecognizedMessage = """🚫 Nie udało się rozpoznać faktury Lightning ani LNURL. Wypośrodkuj kod QR, przytnij zdjęcie lub powiększ."""
|
||||
photoQrRecognizedMessage = """✅ Kod QR:
|
||||
`%s`"""
|
||||
|
||||
# LNURL
|
||||
|
||||
lnurlReceiveInfoText = """👇 Możesz użyć teego statycznego kodu LNRUL aby otrzymywać płatności."""
|
||||
lnurlResolvingUrlMessage = """🧮 Rozwiązuje adres..."""
|
||||
lnurlGettingUserMessage = """🧮 Przygotowuję płatność..."""
|
||||
lnurlPaymentFailed = """🚫 Płatność się nie powiodła: %s"""
|
||||
lnurlInvalidAmountMessage = """🚫 Nieprawidłowa kwota."""
|
||||
lnurlInvalidAmountRangeMessage = """🚫 Kwota musi być między %d a %d sat."""
|
||||
lnurlNoUsernameMessage = """🚫 Musisz ustawić nazwę użytkownika na Telegramie aby otrzymywać płatności poprzez LNURL."""
|
||||
lnurlHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/lnurl [kwota] <lnurl>`
|
||||
*Przykład:* `/lnurl LNURL1DP68GUR...`"""
|
||||
|
||||
# LNURL LOGIN
|
||||
|
||||
confirmLnurlAuthMessager = """Czy chcesz się zalogować do %s?"""
|
||||
lnurlSuccessfulLogin = """✅ Logowanie udało się."""
|
||||
loginButtonMessage = """✅ Zaloguj się"""
|
||||
loginCancelledMessage = """🚫 Logowanie anulowane."""
|
||||
|
||||
# LNURL WITHDRAW
|
||||
|
||||
confirmLnurlWithdrawMessage = """Czy chcesz dokonąć tej wypłaty?\n\n💸 Kwota: %d sat"""
|
||||
lnurlPreparingWithdraw = """🧮 Przygotowywanie wypłaty..."""
|
||||
lnurlWithdrawFailed = """🚫 Wypłata nie powiodła się."""
|
||||
lnurlWithdrawCancelled = """🚫 Wypłata anulowana."""
|
||||
lnurlWithdrawSuccess = """✅ Zażądano wypłaty."""
|
||||
|
||||
# LINK
|
||||
|
||||
walletConnectMessage = """🔗 *Połącz swój portfel*
|
||||
|
||||
⚠️ Nigdy nie ujawniaj adresu URL lub kodu QR nikomu, gdyż będą w stanie uzyskać dostęp do Twoich środków. Użyj /api aby uzyskać dostęp do swoich kluczy API.
|
||||
|
||||
- *BlueWallet:* Naciśnij *Dodaj porfel*, *Import portfela*, *Skanuj lub importuj plik*, i przeskanuj kod QR.
|
||||
- *Zeus:* Skopiuj poniższy adres URL, naciśnij *Dodaj nowy węzeł*, wybierz *LNDHub* jako interfejs węzła, wprowadź adres URL, *Zapisz konfigurację węzła*."""
|
||||
couldNotLinkMessage = """🚫 Nie udało się połączyć Twojego portfela. Spróbuj ponownie później."""
|
||||
linkHiddenMessage = """🔍 Połączenie ukryto. Napisz /link aby zobaczyć je ponownie."""
|
||||
|
||||
# API
|
||||
|
||||
apiConnectMessage = """🔗 *Twoje klucze API*
|
||||
|
||||
⚠️ Nigdy nie ujawniaj tych kluczy nikomu, gdyż będą w stanie uzyskać dostęp do Twoich środków. Użyj /link aby połączyć swój portfel.
|
||||
|
||||
- *Klucz Admin:* `%s`
|
||||
- *Klucz Invoice:* `%s`"""
|
||||
apiHiddenMessage = """🔍 Klucze ukryte. Napisz /api aby zobaczyć je ponownie."""
|
||||
|
||||
# FAUCET
|
||||
|
||||
inlineQueryFaucetTitle = """🚰 Utwórz kranik (_faucet_)."""
|
||||
inlineQueryFaucetDescription = """Użycie: @%s faucet <pojemność> <na_użytkownika>"""
|
||||
inlineResultFaucetTitle = """🚰 Tworzenie kranika o pojemności %d sat."""
|
||||
inlineResultFaucetDescription = """👉 Kliknij tu aby utworzyć kranik w tym chacie."""
|
||||
|
||||
inlineFaucetMessage = """Naciśnij ✅ aby zebrać %d sat z kranika %s.
|
||||
|
||||
🚰 Pozostało: %d/%d sat (rozdanych %d użytkownikom z %d)
|
||||
%s"""
|
||||
inlineFaucetEndedMessage = """🚰 Kranik pusty 🍺\n\n🏅 %d sat rozdano do %d użytkowników."""
|
||||
inlineFaucetAppendMemo = """\n✉️ %s"""
|
||||
inlineFaucetCreateWalletMessage = """Chatuj z %s 👈 aby zarządzać swoim portfelem."""
|
||||
inlineFaucetCancelledMessage = """🚫 Kranik anulowany."""
|
||||
inlineFaucetInvalidPeruserAmountMessage = """🚫 Wartość na_użytkownika nie jest dzielnikiem pojemności lub jest za mała (min 5 sat)."""
|
||||
inlineFaucetInvalidAmountMessage = """🚫 Nieprawidłowa kwota."""
|
||||
inlineFaucetSentMessage = """🚰 %d sat wysłano do %s."""
|
||||
inlineFaucetReceivedMessage = """🚰 %s wysyła Ci %d sat."""
|
||||
inlineFaucetHelpFaucetInGroup = """Utwórz w grupie z botem kranik (_facuet_) lub użyj 👉 komendy inline (zobacz /advanced aby uzyskać więcej informacji)."""
|
||||
inlineFaucetAlreadyTookMessage = """🚫 Już brałeś z tego kranika."""
|
||||
inlineFaucetHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/faucet <pojemność> <na_użytkownika>`
|
||||
*Przykład:* `/faucet 210 21`"""
|
||||
|
||||
# INLINE SEND
|
||||
|
||||
inlineQuerySendTitle = """💸 Wyślij płatność do tego chatu."""
|
||||
inlineQuerySendDescription = """Użycie: @%s send <kwota> [<użytkownik>] [<notatka>]"""
|
||||
inlineResultSendTitle = """💸 Wysłano %d sat."""
|
||||
inlineResultSendDescription = """👉 Kliknij aby wysłać %d sat do tego chatu."""
|
||||
|
||||
inlineSendMessage = """Naciśnij ✅ aby otrzymać płatność od %s.\n\n💸 Kwota: %d sat"""
|
||||
inlineSendAppendMemo = """\n✉️ %s"""
|
||||
inlineSendUpdateMessageAccept = """💸 %d sat wysłano od %s do %s."""
|
||||
inlineSendCreateWalletMessage = """Chatuj z %s 👈 aby zarządzać swoim portfelem."""
|
||||
sendYourselfMessage = """📖 Nie możesz zapłacić sobie."""
|
||||
inlineSendFailedMessage = """🚫 Wysłanie nie powiodło się."""
|
||||
inlineSendInvalidAmountMessage = """🚫 Kwota musi być większa niż 0."""
|
||||
inlineSendBalanceLowMessage = """🚫 Twoje saldo jest za niskie."""
|
||||
|
||||
# INLINE RECEIVE
|
||||
|
||||
inlineQueryReceiveTitle = """🏅 Poproś o płatność na chacie."""
|
||||
inlineQueryReceiveDescription = """Użycie: @%s receive <kwota> [<użytkownik>] [<notatka>]"""
|
||||
inlineResultReceiveTitle = """🏅 Otrzymaj %d sat."""
|
||||
inlineResultReceiveDescription = """👉 Kliknij aby poprosić o płatność %d sat."""
|
||||
|
||||
inlineReceiveMessage = """Naciśnij 💸 aby zapłacić %s.\n\n💸 Kwota: %d sat"""
|
||||
inlineReceiveAppendMemo = """\n✉️ %s"""
|
||||
inlineReceiveUpdateMessageAccept = """💸 %d sat wysłano od %s do %s."""
|
||||
inlineReceiveCreateWalletMessage = """Chatuj z %s 👈 aby zarządzać swoim portfelem."""
|
||||
inlineReceiveYourselfMessage = """📖 Nie możesz zapłacić sobie."""
|
||||
inlineReceiveFailedMessage = """🚫 Przyjmowanie środków nie powiodło się."""
|
||||
inlineReceiveCancelledMessage = """🚫 Przyjmowanie środków anulowane."""
|
||||
|
||||
# TIPJAR
|
||||
|
||||
inlineQueryTipjarTitle = """🍯 Utwórz słoik na napiwki (_tipjar_)."""
|
||||
inlineQueryTipjarDescription = """Użycie: @%s tipjar <pojemność> <na_użytkownika>"""
|
||||
inlineResultTipjarTitle = """🍯 Tworzenie słoika na napiwki (_tipjar_) o pojemności %d sat."""
|
||||
inlineResultTipjarDescription = """👉 Kliknij tu aby utworzyć w tym chacie słoik na napiwki (_tipjar_)."""
|
||||
|
||||
inlineTipjarMessage = """Naciśnij 💸 aby *wpłacić %d sat* do tego słoika na napiwki (_tipjar_) przez %s.
|
||||
|
||||
🙏 Przekazano: *%d*/%d sat (przez %d użytkowników)
|
||||
%s"""
|
||||
inlineTipjarEndedMessage = """🍯 Słoik na napiwki %s jest pełen ⭐️\n\n🏅 %d sat przekazanych przez %d użytkowników."""
|
||||
inlineTipjarAppendMemo = """\n✉️ %s"""
|
||||
inlineTipjarCancelledMessage = """🚫 Słoik na napiwki anulowany."""
|
||||
inlineTipjarInvalidPeruserAmountMessage = """🚫 Kwota na_użytkownika nie jest dzielnikiem pojemności."""
|
||||
inlineTipjarInvalidAmountMessage = """🚫 Nieprawidłowa kwota."""
|
||||
inlineTipjarSentMessage = """🍯 %d sat wysłano do %s."""
|
||||
inlineTipjarReceivedMessage = """🍯 %s wysyła Ci %d sat."""
|
||||
inlineTipjarHelpTipjarInGroup = """Stwórz w grupie z tym botem słoik na napiwki (_tipjar_) lub użyj 👉 komendy inline (zobacz /advanced aby uzyskać więcej informacji)."""
|
||||
inlineTipjarHelpText = """📖 Ojej, to nie zadziałało. %s
|
||||
|
||||
*Użycie:* `/tipjar <capacity> <na_użytkownika>`
|
||||
*Przykład:* `/tipjar 210 21`"""
|
||||
|
||||
# GROUP TICKETS
|
||||
groupAddGroupHelpMessage = """📖 Ojej, to nie zadziałało. Ta komenda działa tylko w chacie grupowym. Tylko właściciele grupy mogą użyć tej komendy.\nUżycie: `/group add <nazwa_grupy> [<kwota>]`\nPrzykład: `/group add NajlepszaGrupaBitcoinowa 1000`"""
|
||||
groupJoinGroupHelpMessage = """📖 Ojej, to nie zadziałało. Spróbuj ponownie później.\nUżycie: `/join <nazwa_grupy>`\nPrzykład: `/join NajlepszaGrupaBitcoinowa`"""
|
||||
groupClickToJoinMessage = """🎟 [Kliknij tu](%s) 👈 aby dołączyć do `%s`."""
|
||||
groupTicketIssuedGroupMessage = """🎟 Użytkownik %s otrzymuje bilet do tej grupy."""
|
||||
groupPayInvoiceMessage = """🎟 Aby dołączyć do grupy %s, opłać powyższą fakturę."""
|
||||
groupBotIsNotAdminMessage = """🚫 Ojej, to nie zadziałało. Musisz uczynić mnie administratorem i nadać prawo do zapraszania użytkowników."""
|
||||
groupNameExists = """🚫 Grupa o tej nazwie już istnieje. Wybierz inną nazwę."""
|
||||
groupAddedMessage = """🎟 Bilety dla grupy `%s` dodane.\nAlias: `%s` Cena: %d sat\n\nAby poprosić o bilet na tę grupę, rozpocznij prywatny czat z %s i napisz `/join %s`."""
|
||||
groupNotFoundMessage = """🚫 Nie znaleziono grupy o tej nazwie."""
|
||||
groupReceiveTicketInvoiceCommission = """🎟 Otrzymujesz *%d sat* (wyłączając. %d sat prowizji) za bilet na grupę `%s` zapłacony przez %s."""
|
||||
groupReceiveTicketInvoice = """🎟 Otrzymujesz *%d sat* za bilet na grupę `%s` zapłacony przez %s."""
|
||||
commandPrivateMessage = """Użyj proszę tej komendy na czacie prywatnym z %s."""
|
||||
groupHelpMessage = """🎟 Bilety na prywatne grupy 🎟
|
||||
|
||||
Sprzedawaj bilety na swoją _prywatną grupę_ i pozbądź się spamujących botów.
|
||||
|
||||
*Instrukcje dla administratorów grup:*
|
||||
|
||||
1) Zaproś %s do swojej grupy i nadaj uprawnienia administratora.
|
||||
2) Uczyń swoją grupę prywatną.
|
||||
3) W grupie, napisz (będąc właścicielem grupy) napisz `/group add <mojagrupa> [<cena_biletu>]`.
|
||||
|
||||
_Opłaty: Bot bierze prowizję w wysokości 10%% + 10 sat za tanie bilety. Jeśli cena bilety >= 1000 sat, prowizja wynosi 2%% + 100 sat._
|
||||
|
||||
*Instrukcje dla członków grupy:*
|
||||
|
||||
Aby dołączyć do grupy, napisz do %s i napisz w prywatnej wiadomości `/join <mojagrupa>`.
|
||||
|
||||
📖 *Użycie:*
|
||||
*Dla adminów (w czacie grupowym):* `/group add <nazwa_grupy> [<cena_biletu>]`\nPrzykład: `/group add NajlepszaGrupaBitcoinowa 1000`
|
||||
*Dla użytkowników (w czacie prywatnym):* `/join <nazwa_grupy>`\nPrzykład: `/join NajlepszaGrupaBitcoinowa`"""
|
||||
|
||||
# DALLE GENERATE
|
||||
generateDalleHelpMessage = """Generuj obrazy przy użyciu OpenAI DALLE 2.\nUżycie: `/generate <podpowiedź>`\nCena: 1000 sat"""
|
||||
generateDallePayInvoiceMessage = """Opłać tę fakturę by wygenerować 4 obrazy 👇"""
|
||||
generateDalleGeneratingMessage = """Twoje obrazy są generowane. Proszę czekaj..."""
|
||||
@@ -119,12 +119,12 @@ advancedMessage = """%s
|
||||
⚙️ *Comandos avançados*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Vincule sua carteira a [ BlueWallet ](https://bluewallet.io/) ou [ Zeus ](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Receber ou pagar com lnurl: `/lnurl` o `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Receber ou pagar com lnurl: `/lnurl` o `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Criar uma torneira: `/faucet <capacidade> <por_usuário>`
|
||||
*/tipjar* 🍯 Criar uma tipjar: `/tipjar <capacidade> <por_usuário>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`"""
|
||||
|
||||
*/shop* 🛍 Browse shops: `/shop` or `/shop <user/shop_id>`
|
||||
*/generate* 🎆 Generate DALLE-2 images: `/generate <prompt>`"""
|
||||
# GENERIC
|
||||
enterAmountRangeMessage = """💯 Insira uma quantia entre %d e %d sat."""
|
||||
enterAmountMessage = """💯 Insira uma quantia."""
|
||||
|
||||
@@ -123,7 +123,7 @@ advancedMessage = """%s
|
||||
⚙️ *Продвинутые команды*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Link your wallet to [BlueWallet](https://bluewallet.io/) or [Zeus](https://zeusln.app/)
|
||||
*/lnurl* Получить или оплатить через ⚡️Lnurl: `/lnurl` or `/lnurl <lnurl>`
|
||||
*/lnurl* Получить или оплатить через ⚡️Lnurl: `/lnurl` or `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Создать криптораздачу: `/faucet <ёмкость> <на_пользователя>`
|
||||
*/tipjar* 🍯 Создать копилку: `/tipjar <ёмкость> <на_пользователя>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
|
||||
@@ -119,7 +119,7 @@ advancedMessage = """%s
|
||||
⚙️ *Gelişmiş komutlar*
|
||||
*/transactions* 📊 List transactions
|
||||
*/link* 🔗 Cüzdanını bağla: [BlueWallet](https://bluewallet.io/) veya [Zeus](https://zeusln.app/)
|
||||
*/lnurl* ⚡️ Lnurl iste veya gönder: `/lnurl` veya `/lnurl <lnurl>`
|
||||
*/lnurl* ⚡️ Lnurl iste veya gönder: `/lnurl` veya `/lnurl <lnurl> [memo]`
|
||||
*/faucet* 🚰 Bir fıçı oluştur: `/faucet <toplam> <kullanıcı_başına>`
|
||||
*/tipjar* 🍯 Bir tipjar oluştur: `/tipjar <capacity> <per_user>`
|
||||
*/group* 🎟 Create group tickets: `/group add <mygroup> [<ticket_price>]`
|
||||
|
||||
Reference in New Issue
Block a user