bots

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2020 License: GPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat added in v0.3.4

type Chat struct {
	Username    string
	InitialText string
	ChatId      int64
	UUIDValue   string
	RecordId    uint32
	// contains filtered or unexported fields
}

func (*Chat) Id added in v0.3.4

func (c *Chat) Id() uint32

func (*Chat) SetId added in v0.3.4

func (c *Chat) SetId(u uint32)

func (Chat) SetState added in v0.3.4

func (c Chat) SetState(new, updated bool)

func (*Chat) SetUUID added in v0.3.4

func (c *Chat) SetUUID(s string)

func (*Chat) UUID added in v0.3.4

func (c *Chat) UUID() string

type ChatBotRunner

type ChatBotRunner interface {
	//Run Starts listening for messages from clients.
	Run()
	//FeedBroadcasts Broadcast anything that comes from a channel.
	FeedBroadcast(messageChannel <-chan ChatMessage)
}

type ChatMessage

type ChatMessage struct {
	Text   string
	ChatId string
	Banner string
}

type TelegramProvider

type TelegramProvider func(token string) (*tgbotapi.BotAPI, error)

type TelegramRunner

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

func NewTelegram

func NewTelegram(token string, cfg config.Config, provider TelegramProvider) (*TelegramRunner, error)

NewTelegram creates a new telegram bot runner. This function uses the `chat_db` environment variable for storing the chats.

func (*TelegramRunner) Broadcast added in v0.3.6

func (t *TelegramRunner) Broadcast(message *ChatMessage)

Broadcast a message to all active chats.

func (*TelegramRunner) FeedBroadcast

func (t *TelegramRunner) FeedBroadcast(messageChannel <-chan ChatMessage) error

FeedBroadcast the messages that are passed to each one of the chats.

func (*TelegramRunner) ForEachChat

func (t *TelegramRunner) ForEachChat(callback func(chat interface{}))

ForEachChat goes over all the persisted chats and invokes the callback on them.

func (*TelegramRunner) Run

func (t *TelegramRunner) Run() error

Run the bot, listening for updates from users

Jump to

Keyboard shortcuts

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