utils

package
v0.0.0-...-4d073a7 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Unlicense Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bot tele.Bot
View Source
var Config = ConfigInit("config.json")
View Source
var DB = DataBaseInit("bot.db")
View Source
var GotdClient *telegram.Client
View Source
var GotdContext tdctx.Context

Functions

func Blacklist

func Blacklist(chats ...int64) tele.MiddlewareFunc

func BotInit

func BotInit()

BotInit initializes Telegram Bot Moved from auto init to manual init to make the code in utils package testable

func DataBaseInit

func DataBaseInit(file string) gorm.DB

func DownloadFile

func DownloadFile(filepath string, url string) (err error)

func ErrorReporting

func ErrorReporting(err error, context tele.Context)

func FFmpegConvert

func FFmpegConvert(context tele.Context, filePath string, targetType string) error

func FindUserInMessage

func FindUserInMessage(context tele.Context) (tele.User, int64, error)

func ForwardPost

func ForwardPost(context tele.Context) error

Forward channel post to chat

func GetBless

func GetBless() string

func GetHtmlText

func GetHtmlText(message tele.Message) string

func GetNope

func GetNope() string

func GetStartOfDay

func GetStartOfDay() int64

func GetUserFromDB

func GetUserFromDB(findstring string) (tele.User, error)

func IsAdmin

func IsAdmin(userid int64) bool

func IsAdminOrModer

func IsAdminOrModer(userid int64) bool

func MentionUser

func MentionUser(user *tele.User) string

func OnChatMember

func OnChatMember(context tele.Context) error

func OnText

func OnText(context tele.Context) error

func OnUserJoined

func OnUserJoined(context tele.Context) error

func OnUserLeft

func OnUserLeft(context tele.Context) error

func RandInt

func RandInt(min int, max int) int

func Remove

func Remove(context tele.Context) error

Remove message

func ReplyAndRemove

func ReplyAndRemove(message string, context tele.Context) error

func Restrict

func RestrictionTimeMessage

func RestrictionTimeMessage(seconds int64) string

func StringInSlice

func StringInSlice(a string, list []string) bool

func UserFullName

func UserFullName(user *tele.User) string

func UserName

func UserName(user *tele.User) string

func Whitelist

func Whitelist(chats ...int64) tele.MiddlewareFunc

Types

type AntiSpam

type AntiSpam struct {
	Text string `gorm:"primaryKey"`
	Type string
}

type Bets

type Bets struct {
	UserID    int64  `gorm:"primaryKey"`
	Text      string `gorm:"primaryKey"`
	Timestamp int64  `gorm:"primaryKey"`
}

type Bless

type Bless struct {
	Text string `gorm:"primaryKey"`
}

type Configuration

type Configuration struct {
	Token                 string   `json:"token"`
	AppID                 int      `json:"app_id"`
	AppHash               string   `json:"app_hash"`
	BotApiUrl             string   `json:"bot_api_url"`
	AllowedUpdates        []string `json:"allowed_updates"`
	Listen                string   `json:"listen"`
	EndpointPublicURL     string   `json:"endpoint_public_url"`
	MaxConnections        int      `json:"max_connections"`
	Chat                  int64    `json:"chat"`
	ReserveChat           int64    `json:"reserve_chat"`
	CommentChat           int64    `json:"comment_chat"`
	StreamChannel         int64    `json:"stream_channel"`
	Channel               int64    `json:"channel"`
	Admins                []int64  `json:"admins"`
	Moders                []int64  `json:"moders"`
	SysAdmin              int64    `json:"sysadmin"`
	CurrencyKey           string   `json:"currency_key"`
	OpenAIKey             string   `json:"openai_key"`
	ReleasesUrl           string   `json:"releases_url"`
	NHentaiCookie         string   `json:"nhentai_cookie"`
	YandexSummarizerToken string   `json:"yandex_summarizer_token"`
}

func ConfigInit

func ConfigInit(file string) Configuration

type Duelist

type Duelist struct {
	UserID int64 `gorm:"primaryKey"`
	Deaths int
	Kills  int
}

type Get

type Get struct {
	Name    string `gorm:"primaryKey"`
	Title   string
	Type    string
	Data    string
	Caption string
	Creator int64
}

type Nope

type Nope struct {
	Text string `gorm:"primaryKey"`
}

type PidorList

type PidorList tele.User

type PidorStats

type PidorStats struct {
	Date   time.Time `gorm:"primaryKey"`
	UserID int64
}

type RestrictConfig

type RestrictConfig struct {
	Chats   []int64
	In, Out tele.HandlerFunc
}

type Stats

type Stats struct {
	ContextID    int64 `gorm:"primaryKey"`
	StatType     int64 `gorm:"primaryKey"`
	Count        int64
	DayTimestamp int64 `gorm:"primaryKey"`
	LastUpdate   int64 `gorm:"default:1685221200"`
}

type StatsWords

type StatsWords struct {
	ID        int64 `gorm:"primaryKey;autoIncrement"`
	Word      string
	ShortWord string
}

type Warn

type Warn struct {
	UserID   int64 `gorm:"primaryKey"`
	Amount   int
	LastWarn time.Time
}

Jump to

Keyboard shortcuts

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