postgres

package
v0.0.0-...-bf1951f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 0, illimited number of conns
	MaxConn = 0
	// 0, letting them idle forever
	MaxIdleConn = 0
	// 0, connections are reused forever
	MaxLifetimeConn = 0
)

Variables

This section is empty.

Functions

func ConnectToBotFromDatabase

func ConnectToBotFromDatabase(db *sqlx.DB, botModel *Bot, f func(ctx context.Context, client *telegram.Client, dispatcher tg.UpdateDispatcher, options telegram.Options) error) error

func DeleteBotByUserID

func DeleteBotByUserID(db *sqlx.DB, botUserID int64) error

func DeleteDeviceBySessionString

func DeleteDeviceBySessionString(db *sqlx.DB, session string) error

func GetEnvVariable

func GetEnvVariable(name string) (string, error)

func InsertNewBot

func InsertNewBot(
	db *sqlx.DB,
	phone string,
	username string,
	password string,
	userID int64,
	title string,
) error

func InsertNewDevice

func InsertNewDevice(db *sqlx.DB, userID int64, apiID int, apiHash string, sessionString string, deviceModel string, systemVersion string, appVersion string, langPack string, langCode string, systemLangCode string, proxy string) error

func OpenDBConnection

func OpenDBConnection() (*sqlx.DB, error)

OpenDBConnection func for opening database connection.

Types

type Bot

type Bot struct {
	UserID      int64  `db:"user_id"`
	PhoneNumber string `db:"phone_number"`
	Username    string `db:"username"`
	Password    string `db:"password"`
	Title       string `db:"title"`
	Premium     bool   `db:"premium"`
}

func GetAllBots

func GetAllBots(db *sqlx.DB) ([]Bot, error)

func GetBotByUserID

func GetBotByUserID(db *sqlx.DB, botUserID int64) (*Bot, error)

type BotAndEntityRelationship

type BotAndEntityRelationship struct {
	FirstEntityID  int64         `db:"entity_id_1"`
	SecondEntityID int64         `db:"entity_id_2"`
	Hash           sql.NullInt64 `db:"hash"`
}

type ChannelsPts

type ChannelsPts struct {
	ChannelID int64
	Pts       int
}

type Device

type Device struct {
	BotUserID      int64          `db:"bot_user_id" json:"bot_user_id"`
	ApiID          int            `db:"api_id" json:"api_id"`
	ApiHash        string         `db:"api_hash" json:"api_hash"`
	SessionString  string         `db:"session_string" json:"session_string"`
	DeviceModel    string         `db:"device_model" json:"device_model"`
	SystemVersion  string         `db:"system_version" json:"system_version"`
	AppVersion     string         `db:"app_version" json:"app_version"`
	LangPack       string         `db:"lang_pack" json:"lang_pack"`
	LangCode       string         `db:"lang_code" json:"lang_code"`
	SystemLangCode string         `db:"system_lang_code" json:"system_lang_code"`
	Proxy          sql.NullString `db:"proxy" json:"proxy"`
	CreationDate   string         `db:"creation_date" json:"creation_date"`
}

func GetRandomDevice

func GetRandomDevice(db *sqlx.DB, botUserID int64) (*Device, error)

type State

type State struct {
	BotUserID int64         `db:"bot_user_id"`
	ID        sql.NullInt64 `db:"id"`
	Pts       sql.NullInt32 `db:"pts"`
	Qts       sql.NullInt32 `db:"qts"`
	Date      sql.NullInt32 `db:"date"`
	Seq       sql.NullInt32 `db:"seq"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL