core

package
v2.0.0-...-3cdc74f Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	ID      string
	Text    string
	Payload string
}

type Chat

type Chat struct {
	ID    ChatID
	Title string
	Type  string
}

type ChatID

type ChatID = int64

type Command

type Command struct {
	Text        string
	Description string
}

func DefaultCommands

func DefaultCommands() []Command

type Document

type Document struct {
	File
	MIME string
}

Document ...

type File

type File struct {
	Name string
	Path string
	Size int64
}

File ...

func (*File) Dispose

func (f *File) Dispose() error

Dispose for filesystem cleanup

type IBoolSettingProvider

type IBoolSettingProvider interface {
	GetBool(ChatID, SettingKey) bool
	SetBool(ChatID, SettingKey, bool) error
}

type IBot

type IBot interface {
	Delete(*Message) error
	Edit(*Message, interface{}, ...interface{}) (*Message, error)
	SendText(string, ...interface{}) (*Message, error)
	SendImage(*Image, string) (*Message, error)
	SendAlbum([]*Image) ([]*Message, error)
	SendMedia(*Media) (*Message, error)
	SendMediaAlbum([]*Media) ([]*Message, error)
	SendVideo(*Video, string) (*Message, error)
	IsUserMemberOfChat(*User, ChatID) bool
	GetCommands(ChatID) ([]Command, error)
	SetCommands(ChatID, []Command) error
}

IBot represents abstract bot interface

type IButtonHandler

type IButtonHandler interface {
	GetButtonIds() []string
	ButtonPressed(*Button, *Message, *User, IBot) error
}

type IChatStorage

type IChatStorage interface {
	GetChatByID(ChatID) (*Chat, error)
	CreateChat(ChatID, string, string) error
}

type ICommandService

type ICommandService interface {
	EnableCommands(ChatID, []Command, IBot) error
	DisableCommands(ChatID, []Command, IBot) error
}

type IDocumentHandler

type IDocumentHandler interface {
	HandleDocument(*Document, *Message, IBot) error
}

IDocumentHandler responds to documents sent in chah

type IFileDownloader

type IFileDownloader interface {
	Download(URL, string) (*File, error)
}

IFileDownloader turns URL to File

type IFileUploader

type IFileUploader interface {
	Upload(*File) (URL, error)
}

IFileUploader turns File to URL

type IGameStorage

type IGameStorage interface {
	GetPlayers(ChatID) ([]*User, error)
	GetRounds(ChatID) ([]*Round, error)
	AddPlayer(ChatID, *User) error
	UpdatePlayer(ChatID, *User) error
	AddRound(ChatID, *Round) error
}

IGameStorage is an abstract interface for game players and results handling

type IHttpClient

type IHttpClient interface {
	GetContentType(URL) (string, error)
	GetContent(URL) (string, error)
	GetRedirectLocation(url URL) (URL, error)
	SetHeader(string, string)
}

IHttpClient retreives remote content info

type IImageDownloader

type IImageDownloader interface {
	Download(image *Image) (*File, error)
}

IImageDownloader download Image to disk

type IImageHandler

type IImageHandler interface {
	HandleImage(*Image, *Message, IBot) error
}

IImageHandler responds to images

type ILocalizer

type ILocalizer interface {
	I18n(string, string, ...interface{}) string
	AllKeys() []string
}

ILocalizer for localization

type ILogger

type ILogger interface {
	Close()
	Error(...interface{})
	Errorf(string, ...interface{})
	Info(...interface{})
	Infof(string, ...interface{})
	Warning(...interface{})
	Warningf(string, ...interface{})
}

ILogger for logging

type IMediaFactory

type IMediaFactory interface {
	CreateMedia(URL) ([]*Media, error)
}

IMediaFactory creates Media from URL

type IRand

type IRand interface {
	GetRand(int) int
}

type ISendMediaStrategy

type ISendMediaStrategy interface {
	SendMedia([]*Media, IBot) error
}

type ISendVideoStrategy

type ISendVideoStrategy interface {
	SendVideo(*Video, string, IBot) error
}

type ISettingsProvider

type ISettingsProvider interface {
	GetData(ChatID, SettingKey) ([]byte, error)
	SetData(ChatID, SettingKey, []byte) error
}

type ITask

type ITask interface {
	Perform([]byte, chan []byte) error
}

type ITaskFactory

type ITaskFactory interface {
	NewTask(string) ITask
}

type ITextHandler

type ITextHandler interface {
	HandleText(*Message, IBot) error
}

ITextHandler responds to all the text messages

type IUserStorage

type IUserStorage interface {
	GetUserById(int64) (*User, error)
	CreateUser(*User) error
}

type IVideoConverter

type IVideoConverter interface {
	GetCodec(string) string
	Convert(*Video, int) (*Video, error)
}

IVideoConverter convert Video with specified bitrate

type IVideoFactory

type IVideoFactory interface {
	CreateVideo(path string) (*Video, error)
}

IVideoFactory retreives video file parameters from file on disk

type IVideoHandler

type IVideoHandler interface {
	HandleVideo(*Video, *Message, IBot) error
}

IVideoHandler responds to videos

type IVideoSplitter

type IVideoSplitter interface {
	Split(*Video, int) ([]*Video, error)
}

IVideoSplitter convert Video with specified bitrate

type IVpnAPI

type IVpnAPI interface {
	GetKeys(ChatID) ([]*VpnKey, error)
	CreateKey(ChatID, string) (*VpnKey, error)
	DeleteKey(*VpnKey) error
}

type Image

type Image struct {
	File
	ID      string
	FileURL string
	Width   int
	Height  int
}

Image represents remote image file that can be also downloaded

type Keyboard

type Keyboard = [][]*Button

type Media

type Media struct {
	ResourceURL URL
	URL         URL
	Title       string
	Description string
	Caption     string
	Duration    int    // video only
	Codec       string // video only
	Size        int
	Type        MediaType
}

Media ...

type MediaType

type MediaType int

MediaType ...

const (
	// Video media type
	TVideo MediaType = iota
	// Photo media type
	TPhoto
	// Text media type
	TText
	// Audio media type
	TAudio
)

type Message

type Message struct {
	ID        int
	Chat      *Chat
	IsPrivate bool
	Sender    *User
	Text      string
	ReplyTo   *Message
	Video     *Video
}

Message from chat

type Round

type Round struct {
	Day    string
	Winner *User
}

Round is a single game result

type SettingKey

type SettingKey string
const (
	SFaggotGameEnabled         SettingKey = "faggot_game"
	SInstagramFlowEnabled      SettingKey = "instagram_flow"
	SInstagramFlowRemoveSource SettingKey = "instagram_flow_remove_source"
	SLinkFlowEnabled           SettingKey = "link_flow"
	SLinkFlowRemoveSource      SettingKey = "link_flow_remove_source"
	SPayloadList               SettingKey = "payload_list"
	STwitterFlowEnabled        SettingKey = "twitter_flo"
	STwitterFlowRemoveSource   SettingKey = "twitter_flow_remove_source"
	SYoutubeFlowEnabled        SettingKey = "youtube_flow"
	SYoutubeFlowRemoveSource   SettingKey = "youtube_flow_remove_source"
)

type URL

type URL = string

URL ...

type User

type User struct {
	ID           int64
	FirstName    string
	LastName     string
	Username     string
	LanguageCode string
}

User ...

func (*User) DisplayName

func (u *User) DisplayName() string

type Video

type Video struct {
	File
	ID       string
	Width    int
	Height   int
	Bitrate  int
	Duration int
	Codec    string
	Thumb    *Image
}

Video ...

func (*Video) Dispose

func (vf *Video) Dispose()

Dispose to cleanup filesystem

type VpnKey

type VpnKey struct {
	ID     string
	ChatID ChatID
	Title  string
	Key    string
}

Jump to

Keyboard shortcuts

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