likeforce

package
v0.0.0-...-1e1828c Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCount

func ByteCount(count int) string

ByteCount to make human-readable rating

func ExtractButtonID

func ExtractButtonID(update tgbotapi.Update) (int, error)

ExtractButtonID extract ID of the message with button from callback request

func ExtractChatID

func ExtractChatID(update tgbotapi.Update) (int64, error)

ExtractChatID extracts ID of the chat from which update goes

func ExtractPostID

func ExtractPostID(update tgbotapi.Update) (int, error)

ExtractPostID extracts ID of the message that button was reply on

func GetPostTitle

func GetPostTitle(chatName string, postID int) (string, error)

GetPostTitle extracts post title for public channel

func MakeDigestPosts

func MakeDigestPosts(chat *storage.Chat, chatName string) (string, error)

MakeDigestPosts returns text digest about top users for given chat

func MakeDigestUsers

func MakeDigestUsers(chat *storage.Chat) (string, error)

MakeDigestUsers returns text digest about top users for given chat

func UserStat

func UserStat(user storage.User) (string, error)

UserStat to get human-readable message with user stat

Types

type ButtonHandler

type ButtonHandler struct {
	*Telegram
}

ButtonHandler psorcesses a new post in a group

func (*ButtonHandler) Handle

func (tg *ButtonHandler) Handle(update tgbotapi.Update)

Handle do actions for given Telegram update

func (*ButtonHandler) Match

func (tg *ButtonHandler) Match(update tgbotapi.Update) bool

Match returns true if handler can process given Telegram update

type Config

type Config struct {
	Telegram TelegramConfig
	Messages MessagesConfig
	Redis    redis.Options
}

Config is a container for TOML config content

func ReadConfig

func ReadConfig(path string) (Config, error)

ReadConfig reads TOML config into Config

type DigestHandler

type DigestHandler struct {
	*Telegram
}

DigestHandler psorcesses a new post in a group

func (*DigestHandler) Handle

func (tg *DigestHandler) Handle(update tgbotapi.Update)

Handle do actions for given Telegram update

func (*DigestHandler) Match

func (tg *DigestHandler) Match(update tgbotapi.Update) bool

Match returns true if handler can process given Telegram update

type Handler

type Handler interface {
	Match(update tgbotapi.Update) bool
	Handle(update tgbotapi.Update)
}

Handler is an interface for Telegram update processors

type LikeHandler

type LikeHandler struct {
	*Telegram
}

LikeHandler processes "/like" message

func (*LikeHandler) Handle

func (tg *LikeHandler) Handle(update tgbotapi.Update)

Handle do actions for given Telegram update

func (*LikeHandler) Match

func (tg *LikeHandler) Match(update tgbotapi.Update) bool

Match returns true if handler can process given Telegram update

type MessagesConfig

type MessagesConfig struct {
	Like     []string
	Liked    string
	Disliked string
	Self     string
	Error    string
}

MessagesConfig is a container for bot messages customization

type PostHandler

type PostHandler struct {
	*Telegram
}

PostHandler psorcesses a new post in a group

func (*PostHandler) Handle

func (tg *PostHandler) Handle(update tgbotapi.Update)

Handle do actions for given Telegram update

func (*PostHandler) Match

func (tg *PostHandler) Match(update tgbotapi.Update) bool

Match returns true if handler can process given Telegram update

type Telegram

type Telegram struct {
	// contains filtered or unexported fields
}

Telegram is a main logic for handling messages

func NewTelegram

func NewTelegram(config Config, storage storage.Storage, logger *onelog.Logger) (*Telegram, error)

NewTelegram creates Telegram instance

func (*Telegram) RegisterHandler

func (tg *Telegram) RegisterHandler(handler Handler)

RegisterHandler adds new Handler for processing of Telegram updates

func (*Telegram) Serve

func (tg *Telegram) Serve() error

Serve forever to process all incoming messages

type TelegramConfig

type TelegramConfig struct {
	Token   string
	Debug   bool
	Timeout int
	Admin   string
}

TelegramConfig is a container for telegram configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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