dalle config

This commit is contained in:
callebtc
2022-08-30 17:32:45 +02:00
parent 890448ce81
commit 2e4a793c20
3 changed files with 13 additions and 5 deletions
+3
View File
@@ -25,3 +25,6 @@ database:
transactions_path: "data/transactions.db"
shop_buntdb_path: "data/shop.db"
groupsdb_path: "data/groups.db"
generate:
dalle_key: "asd"
dalle_price: 1000
+6
View File
@@ -14,8 +14,14 @@ var Configuration = struct {
Telegram TelegramConfiguration `yaml:"telegram"`
Database DatabaseConfiguration `yaml:"database"`
Lnbits LnbitsConfiguration `yaml:"lnbits"`
Generate GenerateConfiguration `yaml:"generate"`
}{}
type GenerateConfiguration struct {
DalleKey string `yaml:"dalle_key"`
DallePrice int64 `yaml:"dalle_price"`
}
type SocksConfiguration struct {
Host string `yaml:"host"`
Username string `yaml:"username"`
+4 -5
View File
@@ -9,6 +9,7 @@ import (
"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"
@@ -18,8 +19,6 @@ import (
tb "gopkg.in/lightningtipbot/telebot.v3"
)
const DALLE2PRICE = 100 // satoshis
// 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) {
@@ -57,7 +56,7 @@ func (bot *TipBot) confirmGenerateImages(ctx intercept.Context) (intercept.Conte
if err != nil {
return ctx, err
}
invoice, err := bot.createInvoiceWithEvent(ctx, me, DALLE2PRICE, fmt.Sprintf("DALLE2 %s", GetUserStr(user.Telegram)), InvoiceCallbackGenerateDalle, prompt)
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
@@ -74,7 +73,7 @@ func (bot *TipBot) confirmGenerateImages(ctx intercept.Context) (intercept.Conte
bot.trySendMessage(ctx.Message().Sender, Translate(ctx, "generateDallePayInvoiceMessage"))
// invoke internal pay if enough balance
if balance > DALLE2PRICE {
if balance >= internal.Configuration.Generate.DallePrice {
m.Text = fmt.Sprintf("/pay %s", invoice.PaymentRequest)
return bot.payHandler(ctx)
}
@@ -102,7 +101,7 @@ func (bot *TipBot) generateDalleImages(event Event) {
}
// create the client with the bearer token api key
dalleClient, err := dalle.NewHTTPClient("API KEY")
dalleClient, err := dalle.NewHTTPClient(internal.Configuration.Generate.DalleKey)
// handle err
if err != nil {
return