events

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rtjc

type Rtjc struct {
	Port      int
	Submitter Submitter
}

Rtjc is a listener for incoming rtjc commands. Publishes whatever it got from the socket compatible with the legacy rtjc bot. Primarily use case is to push news events from news.radio-t.com

func (Rtjc) Listen

func (l Rtjc) Listen(ctx context.Context)

Listen on Port accept and forward to telegram

type Submitter

type Submitter interface {
	Submit(ctx context.Context, text string, pin bool) error
}

Submitter defines interface to submit (usually asynchronously) to the chat

type SuperUser

type SuperUser []string

SuperUser for moderators

func (SuperUser) IsSuper

func (s SuperUser) IsSuper(userName string) bool

IsSuper checks if user name in su list

type TelegramListener

type TelegramListener struct {
	TbAPI            tbAPI
	MsgLogger        msgLogger
	Bots             bot.Interface
	Group            string // can be int64 or public group username (without "@" prefix)
	Debug            bool
	IdleDuration     time.Duration
	AllActivityTerm  Terminator
	BotsActivityTerm Terminator
	SuperUsers       SuperUser
	// contains filtered or unexported fields
}

TelegramListener listens to tg update, forward to bots and send back responses Not thread safe

func (*TelegramListener) Do

func (l *TelegramListener) Do(ctx context.Context) (err error)

Do process all events, blocked call

func (*TelegramListener) Submit

func (l *TelegramListener) Submit(ctx context.Context, text string, pin bool) error

Submit message text to telegram's group

type Terminator

type Terminator struct {
	BanDuration   time.Duration
	BanPenalty    int
	AllowedPeriod time.Duration
	Exclude       SuperUser
	// contains filtered or unexported fields
}

Terminator helps to block too active users

Jump to

Keyboard shortcuts

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