Documentation
¶
Index ¶
- Variables
- func ClearRequests(walletPath string, testnet bool) error
- func ContainsChar(e rune, s string) int
- func ContainsInt64(e int64, s []int64) int
- func CountChar(e rune, s string) uint
- func CreateRequest(amount float64, walletPath string, testnet bool) (string, string, error)
- func ExecCMD(cmd string) ([]byte, error)
- func GetBalance(walletPath string, testnet bool) (float64, error)
- func GetCurrentlySoldTickets(stats *LDBMap) (uint64, error)
- func GetRequest(requestID string, walletPath string, testnet bool) (map[string]json.RawMessage, error)
- func GetTotalSoldTickets(stats *LDBMap) (uint64, error)
- func LogsInit(verboseHandle io.Writer, infoHandle io.Writer, warningHandle io.Writer, ...)
- func Max(a, b int) int
- func MaxFloat64(a, b float64) float64
- func Min(a, b int) int
- func MinFloat64(a, b float64) float64
- func NameValidate(name string) bool
- func PayTo(dstAddress string, amount float64, walletPath string, testnet bool) error
- func PayToUser(user *User, amount float64, walletPath string, testnet bool) error
- func RemoveRequest(requestID string, walletPath string, testnet bool) error
- func Reverse(a *[]*User)
- func SetCurrentlySoldTickets(sold uint64, stats *LDBMap) error
- func SetTotalSoldTickets(sold uint64, stats *LDBMap) error
- func WalletValidate(wallet string) bool
- type Bot
- func (b *Bot) BuyTicket(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) ChangeName(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) ChangeWalletAddress(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) GamePrepare(botAPI *tgbotapi.BotAPI)
- func (b *Bot) GameReset(botAPI *tgbotapi.BotAPI)
- func (b *Bot) GameRestore(botAPI *tgbotapi.BotAPI)
- func (b *Bot) Leaderboard(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) MakeAMove(move byte, update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) NoUnsubscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) Play(botAPI *tgbotapi.BotAPI)
- func (b *Bot) Reset(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) ShowStats(password string, update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) Start()
- func (b *Bot) StartSale(price float64, password string, update tgbotapi.Update, ...)
- func (b *Bot) Status(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) StopSale(number uint64, password string, update tgbotapi.Update, ...)
- func (b *Bot) Subscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) Unsubscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) Welcome(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- func (b *Bot) YesUnsubscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
- type LDBMap
- func (m LDBMap) BatchDelete(key string)
- func (m LDBMap) BatchPut(key string, value string)
- func (m LDBMap) BatchWrite() error
- func (m LDBMap) Close()
- func (m LDBMap) Delete(key string) error
- func (m LDBMap) Exist(key string) bool
- func (m LDBMap) Get(key string) string
- func (m LDBMap) Iterate() map[string]string
- func (m LDBMap) Len() int
- func (m LDBMap) Put(key string, value string) error
- type Options
- type SynMap
- type UMap
- func (m UMap) BatchDelete(uid int64)
- func (m UMap) BatchPut(uid int64, user *User)
- func (m UMap) BatchWrite() error
- func (m UMap) Close()
- func (m UMap) Delete(uid int64) error
- func (m UMap) Exist(uid int64) bool
- func (m UMap) Get(uid int64) *User
- func (m UMap) Iterate() map[int64]*User
- func (m UMap) Len() int
- func (m UMap) Put(uid int64, user *User) error
- type User
- func Deserialize(data []byte) (User, error)
- func MergesortJoinDate(items []*User) []*User
- func MergesortLastTicketDate(items []*User) []*User
- func MergesortLeaderboardPosition(items []*User) []*User
- func MergesortTotalWonAmount(items []*User) []*User
- func NewUser(userID int64, name string, subscribed, hasTicket, isPlayer bool, ...) User
- func (u *User) GetHasTicket() bool
- func (u *User) GetIsPlayer() bool
- func (u *User) GetJoinDate() time.Time
- func (u *User) GetLastTicketDate() time.Time
- func (u *User) GetLastWonAmount() float64
- func (u *User) GetLeaderboardPosition() uint32
- func (u *User) GetName() string
- func (u *User) GetPlaySequence() string
- func (u *User) GetSubscribed() bool
- func (u *User) GetTotalWonAmount() float64
- func (u *User) GetUserID() int64
- func (u *User) GetWalletAddress() string
- func (u *User) Serialize() []byte
- func (u *User) SetHasTicket(val bool)
- func (u *User) SetIsPlayer(val bool)
- func (u *User) SetJoinDate(date time.Time)
- func (u *User) SetLastTicketDate(date time.Time)
- func (u *User) SetLastWonAmount(val float64)
- func (u *User) SetLeaderboardPosition(val uint32)
- func (u *User) SetName(val string)
- func (u *User) SetPlaySequence(val string)
- func (u *User) SetSubscribed(val bool)
- func (u *User) SetTotalWonAmount(val float64)
- func (u *User) SetUserID(id int64)
- func (u *User) SetWalletAddress(val string)
- type Users
- func (u Users) Apply(uid int64, fn func(u *User) error) error
- func (u Users) BatchDelete(uid int64)
- func (u Users) BatchPut(uid int64, user *User)
- func (u Users) BatchWrite() error
- func (u Users) Close()
- func (u Users) Delete(uid int64) error
- func (u Users) Exist(uid int64) bool
- func (u Users) FormJoinDateList() []*User
- func (u Users) FormLastTicketDateList() []*User
- func (u Users) FormLeaderboardPositionList() []*User
- func (u Users) FormTotalWonAmountList() []*User
- func (u Users) Get(uid int64) *User
- func (u Users) Iterate() map[int64]*User
- func (u Users) Len() int
- func (u Users) Put(uid int64, user *User) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ClearRequests ¶
ClearRequests removes all active requests
func ContainsChar ¶
ContainsChar checks if string contains a character.
func ContainsInt64 ¶
ContainsInt64 checks if slice contains an element.
func CreateRequest ¶
CreateRequest creates payment request
func GetBalance ¶
GetBalance returns current balance of specified wallet
func GetCurrentlySoldTickets ¶
GetCurrentlySoldTickets shows current game amount of sold tickets.
func GetRequest ¶
func GetRequest(requestID string, walletPath string, testnet bool) (map[string]json.RawMessage, error)
GetRequest returns request's metadata
func GetTotalSoldTickets ¶
GetTotalSoldTickets shows total amount of sold tickets.
func MaxFloat64 ¶
MaxFloat64 determines maximum of two values.
func MinFloat64 ¶
MinFloat64 determines minumum of two values.
func RemoveRequest ¶
RemoveRequest removes payment request
func SetCurrentlySoldTickets ¶
SetCurrentlySoldTickets sets current game amount of sold tickets.
func SetTotalSoldTickets ¶
SetTotalSoldTickets sets total amount of sold tickets.
func WalletValidate ¶
WalletValidate validates wallet address.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot strcture.
func New ¶
func New( token string, opts *Options, crn *cron.Cron, users *Users, requests *LDBMap, stats *LDBMap, names *LDBMap, players []int64, leaderboard *[]*User, ) Bot
New creates an object of Bot structure.
func (*Bot) BuyTicket ¶
func (b *Bot) BuyTicket(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
BuyTicket handles ticket purchase.
func (*Bot) ChangeName ¶
func (b *Bot) ChangeName(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
ChangeName updates username of user.
func (*Bot) ChangeWalletAddress ¶
func (b *Bot) ChangeWalletAddress(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
ChangeWalletAddress updates wallet address of user.
func (*Bot) GamePrepare ¶
func (b *Bot) GamePrepare(botAPI *tgbotapi.BotAPI)
GamePrepare takes all necessary actions to prepare the game. Sort users by last ticket purchase date and align to ^2 number.
func (*Bot) GameReset ¶
func (b *Bot) GameReset(botAPI *tgbotapi.BotAPI)
GameReset resets all users to pregame state and cleans players list.
func (*Bot) GameRestore ¶
func (b *Bot) GameRestore(botAPI *tgbotapi.BotAPI)
GameRestore resurects game if bot crashed.
func (*Bot) Leaderboard ¶
func (b *Bot) Leaderboard(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
Leaderboard shows leaderboard message.
func (*Bot) NoUnsubscribe ¶
func (b *Bot) NoUnsubscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
NoUnsubscribe dismiss unsubscribe action.
func (*Bot) Reset ¶
func (b *Bot) Reset(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
Reset resets ticket purchase and any active modifying actions.
func (*Bot) StartSale ¶
func (b *Bot) StartSale( price float64, password string, update tgbotapi.Update, botAPI *tgbotapi.BotAPI, )
StartSale starts sale of tickets with specified price.
func (*Bot) Status ¶
func (b *Bot) Status(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
Status shows status message filled up with user's stats.
func (*Bot) StopSale ¶
func (b *Bot) StopSale( number uint64, password string, update tgbotapi.Update, botAPI *tgbotapi.BotAPI, )
StopSale stops sale of tickets after certain threshold.
func (*Bot) Subscribe ¶
func (b *Bot) Subscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
Subscribe enables notifications for user. Without subscription almost any action isn't available
func (*Bot) Unsubscribe ¶
func (b *Bot) Unsubscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
Unsubscribe disables notifications for user.
func (*Bot) Welcome ¶
func (b *Bot) Welcome(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
Welcome to everyone.
func (*Bot) YesUnsubscribe ¶
func (b *Bot) YesUnsubscribe(update tgbotapi.Update, botAPI *tgbotapi.BotAPI)
YesUnsubscribe confirms unsubscribe action. Appear only when user has ticket.
type LDBMap ¶
type LDBMap struct {
// contains filtered or unexported fields
}
LDBMap structure.
func (LDBMap) BatchDelete ¶
BatchDelete deletes an object from the vault by batching (leveldb).
func (LDBMap) BatchWrite ¶
BatchWrite performs write of the batch to the database.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options structure.
func NewOptions ¶
func NewOptions( capacity uint, timeout uint, opTimeout uint, modifyTime uint, roundTime uint, payTime uint, schedule string, ticketPrice float64, testnet bool, donationAddress string, dbPath string, cashboxWalletPath string, bankWalletPath string, password string, ) Options
NewOptions creates an object of NewOptions structure.
type SynMap ¶
type SynMap struct {
// contains filtered or unexported fields
}
SynMap structure. Implements map of interfaces with adaptation to multithreading.
type UMap ¶
type UMap struct {
// contains filtered or unexported fields
}
UMap structure.
func (UMap) BatchDelete ¶
BatchDelete deletes an object from the vault by batching (leveldb).
func (UMap) BatchWrite ¶
BatchWrite performs write of the batch to the database.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User structure.
func Deserialize ¶
Deserialize performs deserialization of the User structure.
func MergesortJoinDate ¶
MergesortJoinDate performs merge sort by join date.
func MergesortLastTicketDate ¶
MergesortLastTicketDate performs merge sort by last buy ticket date.
func MergesortLeaderboardPosition ¶
MergesortLeaderboardPosition performs merge sort by leaderboard position.
func MergesortTotalWonAmount ¶
MergesortTotalWonAmount performs merge sort by total won amount.
func NewUser ¶
func NewUser( userID int64, name string, subscribed, hasTicket, isPlayer bool, leaderboardPosition uint32, ) User
NewUser creates an object of User structure.
func (*User) GetHasTicket ¶
GetHasTicket performs non-blocking get of user's ticket status.
func (*User) GetIsPlayer ¶
GetIsPlayer performs non-blocking get of user's player status.
func (*User) GetJoinDate ¶
GetJoinDate performs non-blocking get of user's join date.
func (*User) GetLastTicketDate ¶
GetLastTicketDate performs non-blocking get of user's last ticket purchase date.
func (*User) GetLastWonAmount ¶
GetLastWonAmount performs non-blocking get of user's last won amount.
func (*User) GetLeaderboardPosition ¶
GetLeaderboardPosition performs non-blocking get of user's leaderboard position.
func (*User) GetPlaySequence ¶
GetPlaySequence performs non-blocking get of user's play sequence.
func (*User) GetSubscribed ¶
GetSubscribed performs non-blocking get of user's subscription status.
func (*User) GetTotalWonAmount ¶
GetTotalWonAmount performs non-blocking get of user's total won amount.
func (*User) GetWalletAddress ¶
GetWalletAddress performs non-blocking get of user's wallet address.
func (*User) SetHasTicket ¶
SetHasTicket performs non-blocking set of user's ticket status.
func (*User) SetIsPlayer ¶
SetIsPlayer performs non-blocking set of user's player status.
func (*User) SetJoinDate ¶
SetJoinDate performs non-blocking set of user's join date.
func (*User) SetLastTicketDate ¶
SetLastTicketDate performs non-blocking set of user's last ticket purchase date.
func (*User) SetLastWonAmount ¶
SetLastWonAmount performs non-blocking set of user's last won amount.
func (*User) SetLeaderboardPosition ¶
SetLeaderboardPosition performs non-blocking set of user's leaderboard position.
func (*User) SetPlaySequence ¶
SetPlaySequence performs non-blocking set of user's play sequence.
func (*User) SetSubscribed ¶
SetSubscribed performs non-blocking set of user's subscription status.
func (*User) SetTotalWonAmount ¶
SetTotalWonAmount performs non-blocking set of user's total won amount.
func (*User) SetWalletAddress ¶
SetWalletAddress performs non-blocking set of user's wallet address.
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
Users structure.
func (Users) BatchDelete ¶
BatchDelete deletes an object from the vault by batching (leveldb).
func (Users) BatchWrite ¶
BatchWrite performs write of the batch to the database.
func (Users) FormJoinDateList ¶
FormJoinDateList forms list of *User sorted by join date.
func (Users) FormLastTicketDateList ¶
FormLastTicketDateList forms list of *User sorted by last ticket purchase date.
func (Users) FormLeaderboardPositionList ¶
FormLeaderboardPositionList forms list of *User sorted by position in the leaderboard.
func (Users) FormTotalWonAmountList ¶
FormTotalWonAmountList forms list of *User sorted by total won amount.