providers

package
v0.0.0-...-dbd4f66 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discord

type Discord struct {
	UserChannel *discordgo.Channel

	Token  string
	UserID string
	// contains filtered or unexported fields
}

Discord is a struct implementing MsgProvider interface

func (*Discord) AddReaction

func (d *Discord) AddReaction(msgID, reaction string) error

func (*Discord) Close

func (d *Discord) Close()

func (*Discord) Init

func (d *Discord) Init() error

func (*Discord) MessagesChannel

func (d *Discord) MessagesChannel() chan Message

func (*Discord) ReactionsChannel

func (d *Discord) ReactionsChannel() chan Reaction

func (*Discord) RemoveReaction

func (d *Discord) RemoveReaction(msgID, reaction string) error

func (*Discord) SendMessage

func (d *Discord) SendMessage(msg string, asString bool) (sentMsgID string, err error)

func (*Discord) SendMessageWithFile

func (d *Discord) SendMessageWithFile(path string) (sentMsgID string, err error)

func (*Discord) SendStringHandler

func (d *Discord) SendStringHandler(text string) (sentMsgID string, err error)

type Message

type Message struct {
	ID              string
	ChatID          string
	ReferencedMsgID string
	Content         string
}

type MessageSendFunc

type MessageSendFunc func(text string) (sentMsgID string, err error)

type MsgProvider

type MsgProvider interface {
	Init() error
	Close()
	// MessagesChannel returns a channel with messages from other users (not bot's own)
	MessagesChannel() chan Message
	// ReactionsChannel returns a channel with reactions of other users (not bot's own)
	ReactionsChannel() chan Reaction
	// asText argument should make the message be sent as pure text, don't try to embed data
	SendMessage(msg string, asText bool) (sentMsgID string, err error)
	AddReaction(msgID, reaction string) error
	RemoveReaction(msgID, reaction string) error
}

func CreateDiscord

func CreateDiscord(conf configuration.Configuration) (MsgProvider, error)

CreateDiscord is a factory function implementing ProviderFactoryFunc signature It is used by CreateProvider

func CreateProvider

func CreateProvider(config configuration.Configuration) (MsgProvider, error)

CreateProvider is a MsgProvider factory function

func CreateTelegram

func CreateTelegram(config configuration.Configuration) (MsgProvider, error)

type ProviderFactoryFunc

type ProviderFactoryFunc func(configuration.Configuration) (MsgProvider, error)

Every MsgProvider should have a function that implement this signature

type Reaction

type Reaction struct {
	MessageID string
	ChatID    string
	Content   string
}

type Telegram

type Telegram struct {
	Token  string
	ChatID string
	// contains filtered or unexported fields
}

func (*Telegram) AddReaction

func (t *Telegram) AddReaction(msgID, reaction string) error

NOTE: Telegram API doesn't support all emojis as reactions https://core.telegram.org/bots/api#reactiontype

func (*Telegram) Close

func (t *Telegram) Close()

func (*Telegram) Init

func (t *Telegram) Init() error

func (*Telegram) MessagesChannel

func (t *Telegram) MessagesChannel() chan Message

func (*Telegram) ReactionsChannel

func (t *Telegram) ReactionsChannel() chan Reaction

func (*Telegram) RemoveReaction

func (t *Telegram) RemoveReaction(msgID, reaction string) error

func (*Telegram) SendMessage

func (t *Telegram) SendMessage(msg string, asText bool) (sentMsgID string, err error)

Jump to

Keyboard shortcuts

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