Documentation
¶
Index ¶
- Constants
- Variables
- func AssertEventType(event Event, eventType EventType) error
- func ColumnMigrationTasks(db *gorm.DB) error
- func DownloadProfilePicture(telegram *tb.Bot, user *tb.User) ([]byte, error)
- func GetAmount(input string) (amount int64, err error)
- func GetLnbitsUser(u *tb.User, bot TipBot) (*lnbits.User, error)
- func GetLnbitsUserWithSettings(u *tb.User, bot TipBot) (*lnbits.User, error)
- func GetMemoFromCommand(command string, fromWord int) string
- func GetUser(u *tb.User, bot TipBot) (*lnbits.User, error)
- func GetUserByTelegramUsername(toUserStrWithoutAt string, bot TipBot) (*lnbits.User, error)
- func GetUserStr(user *tb.User) string
- func GetUserStrMd(user *tb.User) string
- func LoadPublicLocalizer(ctx context.Context) *i18n2.Localizer
- func LoadReplyToUser(ctx context.Context) *lnbits.User
- func LoadUser(ctx context.Context) *lnbits.User
- func LoadUserLocalizer(ctx context.Context) *i18n2.Localizer
- func MakeProgressbar(current int64, total int64) string
- func MakeTipjarbar(current int64, total int64) string
- func ProfilePhotosOf(bot *tb.Bot, user *tb.User) ([]tb.Photo, error)
- func RandStringRunes(n int) string
- func ResetUserState(user *lnbits.User, bot *TipBot)
- func SatoshisToFiat(amount int64, currency string) (fiat float64, err error)
- func SetUserState(user *lnbits.User, bot *TipBot, stateKey lnbits.UserStateKey, stateData string)
- func TipCheckSyntax(ctx context.Context, m *tb.Message) (bool, string)
- func Translate(ctx context.Context, MessgeID string) string
- func TranslateUser(ctx context.Context, MessgeID string) string
- func TryRecognizeQrCode(img image.Image) (*gozxing.Result, error)
- func UpdateUserRecord(user *lnbits.User, bot TipBot) error
- func UserGetAnonLNURL(user *lnbits.User) (string, error)
- func UserGetLNURL(user *lnbits.User) (string, error)
- type Cache
- type ChatInviteLink
- type CreateChatInviteLink
- type Creator
- type Databases
- type EditSingleButtonParams
- type EnterAmountStateData
- type EnterUserStateData
- type Event
- type EventHandler
- type EventType
- type Group
- type InlineFaucet
- type InlineReceive
- type InlineSend
- type InlineTipjar
- type InterceptionWrapper
- type Interceptor
- type Invoice
- type InvoiceEvent
- type InvoiceEventCallback
- type InvoiceEventKey
- type JoinTicket
- type LNURLInvoice
- type LnurlAuthState
- type LnurlPayState
- type LnurlWithdrawState
- type Message
- type MessageOption
- type PayData
- type Result
- type SendData
- type Shop
- type ShopItem
- type ShopView
- type Shops
- type StateCallbackMessage
- type Ticket
- type TicketEvent
- type TipBot
- func (bot *TipBot) CreateWalletForTelegramUser(tbUser *tb.User) (*lnbits.User, error)
- func (bot *TipBot) DescriptionHash(metadata lnurl.Metadata, payerData string) (string, error)
- func (bot *TipBot) GetUserBalance(user *lnbits.User) (amount int64, err error)
- func (bot *TipBot) GetUserBalanceCached(user *lnbits.User) (amount int64, err error)
- func (bot *TipBot) GracefulShutdown()
- func (bot *TipBot) HandleLNURL(rawlnurl string) (string, lnurl.LNURLParams, error)
- func (bot *TipBot) SendCheckSyntax(ctx context.Context, m *tb.Message) (bool, string)
- func (bot *TipBot) Start()
- func (bot *TipBot) UserExists(user *tb.User) (*lnbits.User, bool)
- func (bot *TipBot) UserGetAnonLightningAddress(user *lnbits.User) (string, error)
- func (bot *TipBot) UserGetLightningAddress(user *lnbits.User) (string, error)
- func (bot *TipBot) UserIsBanned(user *lnbits.User) bool
- type TipTooltip
- type TipTooltipOption
- type Transaction
- type TransactionOption
- type TransactionsList
- type VoucherBot
Constants ¶
const ( // MainMenuCommandWebApp = "⤵️ Recv" // MainMenuCommandBalance = "Balance" // MainMenuCommandInvoice = "⚡️ Invoice" // MainMenuCommandHelp = "📖 Help" // MainMenuCommandSend = "⤴️ Send" // SendMenuCommandEnter = "👤 Enter" MainMenuCommandWebApp = "🗳️ App" MainMenuCommandBalance = "Balance" MainMenuCommandInvoice = "⚡️ Invoice" MainMenuCommandHelp = "📖 Help" MainMenuCommandPosApp = "💳 PosApp" MainMenuCommandSend = "⤴️" SendMenuCommandEnter = "👤 Enter" )
we can't use space in the label of buttons, because string splitting will mess everything up.
const ( JoinTicketIndex = "join-ticket:*" MessageOrderedByReplyToFrom = "message.reply_to_message.from.id" TipTooltipKeyPattern = "tip-tool-tip:*" )
const ( InvoiceCallbackGeneric = iota + 1 InvoiceCallbackInlineReceive InvoiceCallbackLNURLPayReceive InvoiceCallbackGroupTicket InvoiceCallbackSatdressProxy InvoiceCallbackGenerateDalle InvoiceCallbackPayJoinTicket )
const ( MAX_SHOPS = 10 MAX_ITEMS_PER_SHOP = 20 MAX_FILES_PER_ITEM = 200 SHOP_TITLE_MAX_LENGTH = 50 ITEM_TITLE_MAX_LENGTH = 1500 SHOPS_DESCRIPTION_MAX_LENGTH = 1500 )
Variables ¶
var BotProfilePicture []byte
var ShopsNoShopsText = "*There are no shops here yet.*"
var ShopsText = ""
-------------- shops handler -------------- var ShopsText = "*Welcome to %s shop.*\n%s\nThere are %d shops here.\n%s"
var ShopsTextShopCount = "*Browse %d shops:*"
var ShopsTextWelcome = "*You are browsing %s shop.*"
Functions ¶
func AssertEventType ¶
func ColumnMigrationTasks ¶
func DownloadProfilePicture ¶
DownloadProfilePicture downloads a profile picture from Telegram. This is a public function because it is used in another package (lnurl)
func GetAmount ¶
GetAmount parses an amount from a string like 1.2k or 3.50€ and returns the value in satoshis
func GetLnbitsUser ¶
GetLnbitsUser will not update the user in Database. this is required, because fetching lnbits.User from a incomplete tb.User will update the incomplete (partial) user in storage. this function will accept users like this: &tb.User{ID: toId, Username: username} without updating the user in storage.
func GetMemoFromCommand ¶
func GetUserStr ¶
func GetUserStrMd ¶
func LoadPublicLocalizer ¶
LoadUser from context
func LoadReplyToUser ¶
LoadReplyToUser from context
func LoadUserLocalizer ¶
LoadUser from context
func MakeProgressbar ¶
func MakeTipjarbar ¶
func ProfilePhotosOf ¶
ProfilePhotosOf returns list of profile pictures for a user.
func RandStringRunes ¶
func ResetUserState ¶
func SetUserState ¶
func TryRecognizeQrCode ¶
TryRecognizeInvoiceFromQrCode will try to read an invoice string from a qr code and invoke the payment ctx.
Types ¶
type Cache ¶
type Cache struct {
*store.GoCacheStore
}
type ChatInviteLink ¶
type CreateChatInviteLink ¶
type Databases ¶
func AutoMigration ¶
func AutoMigration() *Databases
type EditSingleButtonParams ¶
type EnterAmountStateData ¶
type EnterAmountStateData struct {
ID string `json:"ID"` // holds the ID of the tx object in bunt db
Type string `json:"Type"` // holds type of the tx in bunt db (needed for type checking)
Amount int64 `json:"Amount"` // holds the amount entered by the user mSat
AmountMin int64 `json:"AmountMin"` // holds the minimum amount that needs to be entered mSat
AmountMax int64 `json:"AmountMax"` // holds the maximum amount that needs to be entered mSat
OiringalCommand string `json:"OiringalCommand"` // hold the originally entered command for evtl later use
}
type EnterUserStateData ¶
type EnterUserStateData struct {
ID string `json:"ID"` // holds the ID of the tx object in bunt db
Type string `json:"Type"` // holds type of the tx in bunt db (needed for type checking)
Amount int64 `json:"Amount"` // holds the amount entered by the user mSat
AmountMin int64 `json:"AmountMin"` // holds the minimum amount that needs to be entered mSat
AmountMax int64 `json:"AmountMax"` // holds the maximum amount that needs to be entered mSat
OiringalCommand string `json:"OiringalCommand"` // hold the originally entered command for evtl later use
}
type EventHandler ¶
type InlineFaucet ¶
type InlineFaucet struct {
*storage.Base
Message string `json:"inline_faucet_message"`
Amount int64 `json:"inline_faucet_amount"`
RemainingAmount int64 `json:"inline_faucet_remainingamount"`
PerUserAmount int64 `json:"inline_faucet_peruseramount"`
From *lnbits.User `json:"inline_faucet_from"`
To []*lnbits.User `json:"inline_faucet_to"`
Memo string `json:"inline_faucet_memo"`
NTotal int `json:"inline_faucet_ntotal"`
NTaken int `json:"inline_faucet_ntaken"`
UserNeedsWallet bool `json:"inline_faucet_userneedswallet"`
LanguageCode string `json:"languagecode"`
}
type InlineReceive ¶
type InlineReceive struct {
*storage.Base
MessageText string `json:"inline_receive_messagetext"`
Message tb.Editable `json:"inline_receive_message"`
Amount int64 `json:"inline_receive_amount"`
From *lnbits.User `json:"inline_receive_from"`
To *lnbits.User `json:"inline_receive_to"`
From_SpecificUser bool `json:"from_specific_user"`
Memo string `json:"inline_receive_memo"`
LanguageCode string `json:"languagecode"`
}
type InlineSend ¶
type InlineSend struct {
*storage.Base
Message string `json:"inline_send_message"`
Amount int64 `json:"inline_send_amount"`
From *lnbits.User `json:"inline_send_from"`
To *lnbits.User `json:"inline_send_to"`
To_SpecificUser bool `json:"to_specific_user"`
Memo string `json:"inline_send_memo"`
LanguageCode string `json:"languagecode"`
}
type InlineTipjar ¶
type InlineTipjar struct {
*storage.Base
Message string `json:"inline_tipjar_message"`
Amount int64 `json:"inline_tipjar_amount"`
GivenAmount int64 `json:"inline_tipjar_givenamount"`
PerUserAmount int64 `json:"inline_tipjar_peruseramount"`
To *lnbits.User `json:"inline_tipjar_to"`
From []*lnbits.User `json:"inline_tipjar_from"`
Memo string `json:"inline_tipjar_memo"`
NTotal int `json:"inline_tipjar_ntotal"`
NGiven int `json:"inline_tipjar_ngiven"`
LanguageCode string `json:"languagecode"`
}
type InterceptionWrapper ¶
type InterceptionWrapper struct {
Endpoints []interface{}
Handler intercept.Func
Interceptor *Interceptor
}
type Interceptor ¶
type InvoiceEvent ¶
type InvoiceEvent struct {
*Invoice
*storage.Base
User *lnbits.User `json:"user"` // the user that is being paid
Message *tb.Message `json:"message,omitempty"` // the message that the invoice replies to
InvoiceMessage *tb.Message `json:"invoice_message,omitempty"` // the message that displays the invoice
LanguageCode string `json:"languagecode"` // language code of the user
Callback int `json:"func"` // which function to call if the invoice is paid
CallbackData string `json:"callbackdata"` // add some data for the callback
Chat *tb.Chat `json:"chat,omitempty"` // if invoice is supposed to be sent to a particular chat
Payer *lnbits.User `json:"payer,omitempty"` // if a particular user is supposed to pay this
UserCurrency string `json:"usercurrency,omitempty"` // the currency a user selected
}
func (InvoiceEvent) Key ¶
func (invoiceEvent InvoiceEvent) Key() string
func (InvoiceEvent) Type ¶
func (invoiceEvent InvoiceEvent) Type() EventType
type InvoiceEventCallback ¶
type InvoiceEventCallback map[int]EventHandler
var InvoiceCallback InvoiceEventCallback
type InvoiceEventKey ¶
type InvoiceEventKey int
type JoinTicket ¶
type JoinTicket struct {
Sender *tb.User `json:"sender"`
Message *tb.Message `json:"message"`
CreatedTimestamp time.Time `json:"created_timestamp"`
Ticket *Ticket `json:"ticket"`
}
func (JoinTicket) Key ¶
func (jt JoinTicket) Key() string
func (JoinTicket) Type ¶
func (jt JoinTicket) Type() EventType
type LNURLInvoice ¶
type LNURLInvoice struct {
*Invoice
Comment string `json:"comment"`
User *lnbits.User `json:"user"`
CreatedAt time.Time `json:"created_at"`
Paid bool `json:"paid"`
PaidAt time.Time `json:"paid_at"`
From string `json:"from"`
Nip57Receipt nostr.Event `json:"nip57_receipt"`
Nip57ReceiptRelays []string `json:"nip57_receipt_relays"`
}
func (LNURLInvoice) Key ¶
func (lnurlInvoice LNURLInvoice) Key() string
type LnurlAuthState ¶
type LnurlPayState ¶
type LnurlPayState struct {
*storage.Base
From *lnbits.User `json:"from"`
LNURLPayParams lnurl.LNURLPayParams `json:"LNURLPayParams"`
LNURLPayValues lnurl.LNURLPayValues `json:"LNURLPayValues"`
Amount int64 `json:"amount"`
Comment string `json:"comment"`
DescriptionHash string `json:"descriptionHash,omitempty"`
LanguageCode string `json:"languagecode"`
}
LnurlPayState saves the state of the user for an LNURL payment
type LnurlWithdrawState ¶
type LnurlWithdrawState struct {
*storage.Base
From *lnbits.User `json:"from"`
LNURLWithdrawResponse lnurl.LNURLWithdrawResponse `json:"LNURLWithdrawResponse"`
LNURResponse lnurl.LNURLResponse `json:"LNURLResponse"`
Amount int64 `json:"amount"`
Comment string `json:"comment"`
LanguageCode string `json:"languagecode"`
Success bool `json:"success"`
Invoice lnbits.Invoice `json:"invoice"`
Message string `json:"message"`
}
LnurlWithdrawState saves the state of the user for an LNURL payment
type Message ¶
type Message struct {
Message *tb.Message `json:"message"`
// contains filtered or unexported fields
}
func NewMessage ¶
func NewMessage(m *tb.Message, opts ...MessageOption) *Message
type MessageOption ¶
type MessageOption func(m *Message)
func WithDuration ¶
func WithDuration(duration time.Duration, tipBot *TipBot) MessageOption
type PayData ¶
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"`
SuccessAction *lnurl.SuccessAction `json:"successAction"`
TelegramMessage *tb.Message `json:"telegrammessage"`
}
type Shop ¶
type Shop struct {
*storage.Base
Owner *lnbits.User `json:"owner"` // owner of the shop
Type string `json:"Type"` // type of the shop
Title string `json:"title"` // Title of the item
Description string `json:"description"` // Description of the item
ItemIds []string `json:"ItemsIDs"` //
Items map[string]ShopItem `json:"Items"` //
LanguageCode string `json:"languagecode"`
ShopsID string `json:"shopsID"`
MaxItems int `json:"maxItems"`
}
type ShopItem ¶
type ShopItem struct {
ID string `json:"ID"` // ID of the tx object in bunt db
ShopID string `json:"shopID"` // ID of the shop
Owner *lnbits.User `json:"owner"` // Owner of the item
Type string `json:"Type"` // Type of the tx object in bunt db
FileIDs []string `json:"fileIDs"` // Telegram fileID of the item files
FileTypes []string `json:"fileTypes"` // Telegram file type of the item files
Title string `json:"title"` // Title of the item
Description string `json:"description"` // Description of the item
Price int64 `json:"price"` // price of the item
NSold int `json:"nSold"` // number of times item was sold
TbPhoto *tb.Photo `json:"tbPhoto"` // Telegram photo object
LanguageCode string `json:"languagecode"`
MaxFiles int `json:"maxFiles"`
}
type StateCallbackMessage ¶
type Ticket ¶
type Ticket struct {
Price int64 `json:"price"`
Memo string `json:"memo"`
Creator *lnbits.User `gorm:"embedded;embeddedPrefix:creator_"`
Cut int64 `json:"cut"` // Percent to cut from ticket price
BaseFee int64 `json:"base_fee"`
CutCheap int64 `json:"cut_cheap"` // Percent to cut from ticket price
BaseFeeCheap int64 `json:"base_fee_cheap"`
}
type TicketEvent ¶
type TicketEvent struct {
*storage.Base
*InvoiceEvent
Group *Group `gorm:"embedded;embeddedPrefix:group_"`
}
func (TicketEvent) Key ¶
func (ticketEvent TicketEvent) Key() string
func (TicketEvent) Type ¶
func (ticketEvent TicketEvent) Type() EventType
type TipBot ¶
type TipBot struct {
DB *Databases
Bunt *storage.DB
ShopBunt *storage.DB
Telegram *tb.Bot
Client *lnbits.Client
Cache
// contains filtered or unexported fields
}
func (*TipBot) CreateWalletForTelegramUser ¶
func (*TipBot) DescriptionHash ¶
DescriptionHash is the SHA256 hash of the metadata
func (*TipBot) GetUserBalance ¶
func (*TipBot) GetUserBalanceCached ¶
func (*TipBot) GracefulShutdown ¶
func (bot *TipBot) GracefulShutdown()
GracefulShutdown will gracefully shutdown the bot It will wait for all mutex locks to unlock before shutdown.
func (*TipBot) HandleLNURL ¶
fiatjaf/go-lnurl 1.8.4 with proxy
func (*TipBot) SendCheckSyntax ¶
func (*TipBot) Start ¶
func (bot *TipBot) Start()
Start will initialize the Telegram bot and lnbits.
func (*TipBot) UserGetAnonLightningAddress ¶
func (*TipBot) UserGetLightningAddress ¶
type TipTooltip ¶
type TipTooltip struct {
Message
ID string `json:"id"`
TipAmount int64 `json:"tip_amount"`
Ntips int `json:"ntips"`
LastTip time.Time `json:"last_tip"`
Tippers []*tb.User `json:"tippers"`
}
func NewTipTooltip ¶
func NewTipTooltip(m *tb.Message, opts ...TipTooltipOption) *TipTooltip
func (TipTooltip) Key ¶
func (ttt TipTooltip) Key() string
type TipTooltipOption ¶
type TipTooltipOption func(m *TipTooltip)
func TipAmount ¶
func TipAmount(amount int64) TipTooltipOption
func Tips ¶
func Tips(nTips int) TipTooltipOption
type Transaction ¶
type Transaction struct {
ID uint `gorm:"primarykey"`
Time time.Time `json:"time"`
Bot *TipBot `gorm:"-"`
From *lnbits.User `json:"from" gorm:"-"`
To *lnbits.User `json:"to" gorm:"-"`
FromId int64 `json:"from_id" `
ToId int64 `json:"to_id" `
FromUser string `json:"from_user"`
ToUser string `json:"to_user"`
Type string `json:"type"`
Amount int64 `json:"amount"`
ChatID int64 `json:"chat_id"`
ChatName string `json:"chat_name"`
Memo string `json:"memo"`
Success bool `json:"success"`
FromWallet string `json:"from_wallet"`
ToWallet string `json:"to_wallet"`
FromLNbitsID string `json:"from_lnbits"`
ToLNbitsID string `json:"to_lnbits"`
Invoice lnbits.Invoice `gorm:"embedded;embeddedPrefix:invoice_"`
}
func NewTransaction ¶
func NewTransaction(bot *TipBot, from *lnbits.User, to *lnbits.User, amount int64, opts ...TransactionOption) *Transaction
func (*Transaction) Send ¶
func (t *Transaction) Send() (success bool, err error)
type TransactionOption ¶
type TransactionOption func(t *Transaction)
func TransactionChat ¶
func TransactionChat(chat *tb.Chat) TransactionOption
func TransactionType ¶
func TransactionType(transactionType string) TransactionOption
type TransactionsList ¶
Source Files
¶
- amounts.go
- balance.go
- bot.go
- buttons.go
- buy.go
- cards.go
- database.go
- donate.go
- edit.go
- faucet.go
- files.go
- generate.go
- gpt.go
- groups.go
- handler.go
- help.go
- helpers.go
- inline_query.go
- inline_receive.go
- inline_send.go
- interceptor.go
- invoice.go
- link.go
- lnurl-auth.go
- lnurl-pay.go
- lnurl-withdraw.go
- lnurl.go
- message.go
- nostr.go
- pay.go
- photo.go
- pos.go
- satdress.go
- scrub.go
- send.go
- setting.go
- shop.go
- shop_helpers.go
- start.go
- state.go
- telegram.go
- text.go
- ticket.go
- tip.go
- tipjar.go
- tooltip.go
- transaction.go
- transactions.go
- translate.go
- users.go
- voucherbot.go