_function

package
v0.0.0-...-b23f6f9 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: GPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const BrowserUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
View Source
const ClientUserAgent = "tieba/" + ClientVersion
View Source
const ClientVersion = "12.58.1.0"
View Source
const ResetPwdExpire = 60 * 30
View Source
const ResetPwdMaxTimes = 5

Variables

View Source
var CookieList sync.Map //= make(map[int32]_type.TypeCookie)
View Source
var DefaultCient *http.Client
View Source
var EchoEmptyArray = make([]string, 0)
View Source
var EchoEmptyObject = make(map[string]any, 0)
View Source
var EmptyHeaders = map[string]string{}
View Source
var FidList sync.Map //= make(map[string]int64)
View Source
var GormDB = new(GormDBPool)
View Source
var IgnoreProxy bool
View Source
var LocalTime, _ = time.LoadLocation("Asia/Shanghai")

Tieba works in GMT+8

View Source
var MessageTypeList = []string{"email", "ntfy", "bark"}
View Source
var Now = time.Now().In(LocalTime)
View Source
var Options sync.Map //  make(map[string]string)
View Source
var ResetPwdList sync.Map //= make(map[int32]*ResetPwdStruct)
View Source
var SettingsFilter = SettingsKeys
View Source
var SettingsKeys = []string{"ann", "system_url", "stop_reg", "enable_reg", "yr_reg", "cktime", "sign_mode", "sign_hour", "cron_limit", "sign_sleep", "retry_max", "mail_name", "mail_yourname", "mail_host", "mail_port", "mail_secure", "mail_auth", "mail_smtpname", "mail_smtppw", "go_forum_sync_policy", "go_ntfy_addr", "go_bark_addr"} // "system_name", "system_keywords", "system_description"
View Source
var TBClient *http.Client

Functions

func AddSign

func AddSign(form *map[string]string, client_type string)

func Addslashes

func Addslashes(str string) string

func ApiTemplate

func ApiTemplate[T any](code int, message string, data T, version string) _type.ApiTemplate

func AppendStrings

func AppendStrings(s ...string) string

func ConnectToMySQL

func ConnectToMySQL(username string, password string, endpoint string, dbname string, logLevel logger.LogLevel, servicePrefix string) (*gorm.DB, *gorm.DB, error)

func ConnectToSQLite

func ConnectToSQLite(path string, logLevel logger.LogLevel, servicePrefix string) (*gorm.DB, *gorm.DB, error)

func CreatePasswordHash

func CreatePasswordHash(password string) ([]byte, error)

func DeleteOption

func DeleteOption(keyName string, ext ...any) error

func DeleteUserOption

func DeleteUserOption(keyName string, uid string, ext ...any) error

func EchoNoContent

func EchoNoContent(c echo.Context) error

func EchoReject

func EchoReject(c echo.Context) error

func Fetch

func Fetch(_url string, _method string, _body []byte, _headers map[string]string, client *http.Client) ([]byte, error)

func GenHMAC256

func GenHMAC256(ciphertext, key []byte) []byte

func GetBaiduUserInfo

func GetBaiduUserInfo(cookie _type.TypeCookie) (*_type.BaiduUserInfoResponse, error)

func GetCookie

func GetCookie(pid int32, bduss_only ...bool) _type.TypeCookie

func GetFid

func GetFid(name string) int64

func GetForumList

func GetForumList(cookie _type.TypeCookie, uid string, page int64) (*_type.ForumListResponse, error)

func GetForumNameShare

func GetForumNameShare(name string) (*_type.ForumNameShareResponse, error)
func GetGravatarLink(email string) string

func GetLoginQRCode

func GetLoginQRCode() (*_type.LoginQRCode, error)

func GetLoginResponse

func GetLoginResponse(tmpBDUSS string) (*_type.LoginResponse, error)

func GetManagerInfo

func GetManagerInfo(fid uint64) (*tbpb.GetBawuInfoResIdl_DataRes, error)

func GetManagerStatus

func GetManagerStatus(portrait string, fid int64) (*_type.IsManagerPreCheckResponse, error)

func GetManagerTasks

func GetManagerTasks(cookie _type.TypeCookie, fid int64) (*_type.ManagerTasksResponse, error)

func GetOneKeySignList

func GetOneKeySignList(cookie _type.TypeCookie) (any, error)

func GetOption

func GetOption(keyName string) string

func GetSemver

func GetSemver(cur, ver2 string) string

func GetTbs

func GetTbs(bduss string) (*_type.TbsResponse, error)

func GetUnicastResponse

func GetUnicastResponse(sign string) (*_type.WrapUnicastResponse, error)

func GetUserInfoByTiebaUID

func GetUserInfoByTiebaUID(tbuid string) (*tbpb.GetUserByTiebaUidResIdl_DataRes, error)

func GetUserInfoByUsernameOrPortrait

func GetUserInfoByUsernameOrPortrait(requestType string, value string) (*_type.TiebaPanelUserInfoResponse, error)

func GetUserOption

func GetUserOption(keyName string, uid string) string

func GetWebForumList

func GetWebForumList(cookie _type.TypeCookie, page int64) (*_type.WebForumListResponse, error)

func HtmlSpecialchars

func HtmlSpecialchars(html string) string

func InitClient

func InitClient(timeout int) *http.Client

func InitOptions

func InitOptions()

func IsOfficialSupport

func IsOfficialSupport() bool

func JsonDecode

func JsonDecode[T any](jsonByte []byte, template *T) error

func JsonEncode

func JsonEncode[T any](data T) ([]byte, error)

func LocaleTimeDiff

func LocaleTimeDiff(hour int64) int64

for GMT+8

func Md5

func Md5(str string) string

func MultipartBodyBuilder

func MultipartBodyBuilder(_body map[string]any, files ...MultipartBodyBinaryFileType) ([]byte, string, error)

func PostCheckinClient

func PostCheckinClient(cookie _type.TypeCookie, kw string, fid int32) (*_type.ClientSignResponse, error)

func PostSync

func PostSync(cookie _type.TypeCookie) (any, error)

!!! Calling this api will change the IP location !!! / DO NOT ASK ME WHY THE RESPONSE IS `ANY`!!!

func RandomEmoji

func RandomEmoji() string

func RemoveLeadingZeros

func RemoveLeadingZeros(data []byte) []byte

from chatgpt

func ScanTiebaByPid

func ScanTiebaByPid(pid int32)

func SendBark

func SendBark(_to, title, body string) error

func SendEmail

func SendEmail(_to, title, body string) error

TODO GPG?

func SendMessage

func SendMessage(_type string, uid int32, _subject, _body string) error

func SendNtfy

func SendNtfy(_to, title, body string) error

func SetOption

func SetOption[T ~string | ~bool | ~int](keyName string, value T, ext ...any) error

func SetUserOption

func SetUserOption[T ~string | ~bool | ~int](keyName string, value T, uid string, ext ...any) error

func Sha1

func Sha1(str string) string

func Sha256

func Sha256(str []byte) string

func TBFetch

func TBFetch(_url string, _method string, _body []byte, _headers map[string]string) ([]byte, error)

func UpdateNow

func UpdateNow()

func Upgrade

func Upgrade(version string) error

version = "20240707.c7990c7.6a6db54"

func VariablePtrWrapper

func VariablePtrWrapper[T any](anyValue T) *T

func VariableWrapper

func VariableWrapper[T any](anyValue T) T

func VerifyEmail

func VerifyEmail(email string) bool

func VerifyPasswordHash

func VerifyPasswordHash(hashedPassword string, password string) error

func VerifyURL

func VerifyURL(_url string) bool

Types

type BarkResponseStruct

type BarkResponseStruct struct {
	Code      int    `json:"code,omitempty"`
	Message   string `json:"message,omitempty"`
	Timestamp int64  `json:"timestamp,omitempty"`
}

type GithubReleasesListResponseItem

type GithubReleasesListResponseItem struct {
	HTMLURL         string `json:"html_url,omitempty"`
	ID              int    `json:"id,omitempty"`
	TagName         string `json:"tag_name,omitempty"`
	TargetCommitish string `json:"target_commitish,omitempty"`
	Name            string `json:"name,omitempty"`
	Draft           bool   `json:"draft,omitempty"`
	Prerelease      bool   `json:"prerelease,omitempty"`
	CreatedAt       string `json:"created_at,omitempty"`
	PublishedAt     string `json:"published_at,omitempty"`
	Assets          []struct {
		URL                string `json:"url,omitempty"`
		Name               string `json:"name,omitempty"`
		State              string `json:"state,omitempty"`
		Size               int    `json:"size,omitempty"`
		CreatedAt          string `json:"created_at,omitempty"`
		UpdatedAt          string `json:"updated_at,omitempty"`
		BrowserDownloadURL string `json:"browser_download_url,omitempty"`
	} `json:"assets,omitempty"`
	Body string `json:"body,omitempty"`
}

type GormDBPool

type GormDBPool struct {
	R *gorm.DB
	W *gorm.DB
}

type MultipartBodyBinaryFileType

type MultipartBodyBinaryFileType struct {
	Fieldname string
	Filename  string
	Binary    []byte
}

type NtfyResponseStruct

type NtfyResponseStruct struct {
	ID      string `json:"id,omitempty"`
	Time    int64  `json:"time,omitempty"`
	Expires int64  `json:"expires,omitempty"`
	Event   string `json:"event,omitempty"`
	Topic   string `json:"topic,omitempty"`
	Message string `json:"message,omitempty"`
}

type PushMessageTemplateStruct

type PushMessageTemplateStruct struct {
	Title string
	Body  string
}

func PushMessageTemplateResetPassword

func PushMessageTemplateResetPassword(verifyMessage, code string) PushMessageTemplateStruct

func PushMessageTestTemplate

func PushMessageTestTemplate() PushMessageTemplateStruct

type ResetPwdStruct

type ResetPwdStruct struct {
	VerifyCode string
	Expire     int64
	Value      string
	Time       int64
}

Jump to

Keyboard shortcuts

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