Documentation
¶
Index ¶
- Variables
- func ExtractDeepLinkPublicID(botUsername string, uries []string) ([]string, error)
- type Admin
- type AdminSummaryStats
- type Auth
- type ChannelPostInfo
- type Chat
- func (srv *Chat) Add(ctx context.Context, user *core.User, identity ChatIdentity) (*FullChat, error)
- func (srv *Chat) DisconnectChat(ctx context.Context, user *core.User, id core.ChatID, leave bool) error
- func (srv *Chat) GetChat(ctx context.Context, user *core.User, id core.ChatID) (*FullChat, error)
- func (srv *Chat) GetChats(ctx context.Context, user *core.User) ([]*core.Chat, error)
- func (srv *Chat) ProcessChannelPostURIes(ctx context.Context, postInfo *ChannelPostInfo, uries []string) error
- func (srv *Chat) UpdateTitle(ctx context.Context, chatID int64, title string) error
- type ChatIdentity
- type ChatRestrictionStatus
- type ChatSubRequest
- type DownloadResult
- type File
- func (srv *File) AddFile(ctx context.Context, user *core.User, in *InputFile) (*OwnedFile, error)
- func (srv *File) CheckFileRestrictionsChat(ctx context.Context, user *core.User, id core.FileID) (*ChatRestrictionStatus, error)
- func (srv *File) DeleteFile(ctx context.Context, user *core.User, id core.FileID) error
- func (srv *File) GetFileByID(ctx context.Context, user *core.User, id core.FileID) (*DownloadResult, error)
- func (srv *File) GetFileByPublicID(ctx context.Context, user *core.User, publicID string) (*DownloadResult, error)
- func (srv *File) RegisterDownload(ctx context.Context, user *core.User, file *core.File) (*DownloadResult, error)
- func (srv *File) SetChatRestriction(ctx context.Context, user *core.User, fileID core.FileID, chatID core.ChatID) (*SetChatRestrictionResult, error)
- type FullChat
- type InputFile
- type OwnedFile
- type SetChatRestrictionResult
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrChatNotFoundOrBotIsNotAdmin = errors.New("chat not found or bot is not admin") ErrChatIsUser = errors.New("chat is private (user)") ErrBotIsNotChatAdmin = errors.New("bot is not admin") ErrBotNotEnoughRights = errors.New("bot not has rights") ErrUserIsNotChatAdmin = errors.New("user is not admin") ErrChatAlreadyConnected = errors.New("chat already connected") )
View Source
var ( ErrInvalidID = errors.New("invalid file id") ErrCantCheckMembership = errors.New("can't check membership of user") )
View Source
var ErrFileViolatesCopyright = errors.New("file violates copyright")
View Source
var ErrUserIsNotAdmin = errors.New("user is not admin")
View Source
var (
ErrUsersCantUploadFiles = errors.New("users can't upload files")
)
Functions ¶
Types ¶
type Admin ¶
type Admin struct {
User core.UserStore
File core.FileStore
Download core.DownloadStore
Chat core.ChatStore
}
func (*Admin) SummaryStats ¶
type AdminSummaryStats ¶
type ChannelPostInfo ¶
func (*ChannelPostInfo) Link ¶
func (info *ChannelPostInfo) Link() string
Link returns tg:// deeplink to post
type Chat ¶
type Chat struct {
Telegram *tgbotapi.BotAPI
Txier store.Txier
File core.FileStore
Chat core.ChatStore
Download core.DownloadStore
}
func (*Chat) Add ¶
func (srv *Chat) Add(ctx context.Context, user *core.User, identity ChatIdentity) (*FullChat, error)
Add links chat to Share File Bot.
func (*Chat) DisconnectChat ¶
func (srv *Chat) DisconnectChat( ctx context.Context, user *core.User, id core.ChatID, leave bool, ) error
DisconnectChat disconnect user linked chat and optionaly leave it.
func (*Chat) ProcessChannelPostURIes ¶
func (srv *Chat) ProcessChannelPostURIes( ctx context.Context, postInfo *ChannelPostInfo, uries []string, ) error
ProcessChannelPostURIes called on each channel post and should scan for backlinks to bot.
Flow:
- resolve chat, if chat is not found finish without error
- extract bot /start uries
- query files by public link and restrction chat id
- update files
type ChatIdentity ¶
func NewChatIdentityFromID ¶
func NewChatIdentityFromID(id int64) ChatIdentity
func NewChatIdentityFromUsername ¶
func NewChatIdentityFromUsername(un string) ChatIdentity
type ChatRestrictionStatus ¶
type ChatSubRequest ¶
func (*ChatSubRequest) Link ¶
func (sub *ChatSubRequest) Link() string
type DownloadResult ¶
type DownloadResult struct {
File *core.File
OwnedFile *OwnedFile
ChatSubRequest *ChatSubRequest
}
type File ¶
type File struct {
File core.FileStore
Chat core.ChatStore
Telegram *tgbotapi.BotAPI
Redis redis.UniversalClient
Download core.DownloadStore
IsUsersCanUploadFiles bool
}
func (*File) CheckFileRestrictionsChat ¶
func (*File) DeleteFile ¶
func (*File) GetFileByID ¶
func (*File) GetFileByPublicID ¶
func (*File) RegisterDownload ¶
type FullChat ¶
type FullChat struct {
*core.Chat
// Count of files
Files int
// Stats of downloads
Stats *core.ChatDownloadStats
}
func (*FullChat) GetStats ¶
func (chat *FullChat) GetStats() *core.ChatDownloadStats
Click to show internal directories.
Click to hide internal directories.