bot

package
v0.0.0-...-c4c190d Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

package to help deep refactoring stay best

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HammertimeInfo

func HammertimeInfo() string

func NextMeetupInfo

func NextMeetupInfo() string

func ReplaceUsername

func ReplaceUsername(text, username string) string

Types

type ApplicationConfig

type ApplicationConfig struct {
	LogLevel logrus.Level
}

func (*ApplicationConfig) UnmarshalYAML

func (c *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type BotAPI

type BotAPI interface {
	GetUpdatesChan(config tgbotapi.UpdateConfig) (tgbotapi.UpdatesChannel, error)
	Send(c tgbotapi.Chattable) (tgbotapi.Message, error)
}

Generic (joke) bot API interface to use in tests, consider tgbotapi as implementation

type Config

type Config struct {
	Telegram    TelegramConfig    `yaml:"telegram"`
	Application ApplicationConfig `yaml:"application"`
}

func NewConfig

func NewConfig(path string) (*Config, error)

type MessageProvider

type MessageProvider interface {
	// GetGreeting returns a greeting message
	GetGreeting() string
	// GetCurse returns a farewell message
	GetCurse() string
	// GetRoll returns a topic message
	GetRoll() string
}

MessageProvider common chat message repo interface

type Service

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

func NewService

func NewService(bot BotAPI, msg MessageProvider, logger *logrus.Entry) *Service

func NewServiceFromTgbotapi

func NewServiceFromTgbotapi(apiKey string, msg MessageProvider) (*Service, error)

func (*Service) GetMessage

func (s *Service) GetMessage() MessageProvider

func (*Service) GoAwayMessage

func (s *Service) GoAwayMessage(update *tgbotapi.Update, username string) error

func (*Service) Greeting

func (s *Service) Greeting(update *tgbotapi.Update, username string) error

func (*Service) Hammertime

func (s *Service) Hammertime(update *tgbotapi.Update) error

func (*Service) HandleUpdate

func (s *Service) HandleUpdate(update *tgbotapi.Update)

func (*Service) Listen

func (s *Service) Listen()

func (*Service) NextMeetup

func (s *Service) NextMeetup(update *tgbotapi.Update) error

func (*Service) RollMessage

func (s *Service) RollMessage(update *tgbotapi.Update) error

func (*Service) Send

func (s *Service) Send(update *tgbotapi.Update, text string) error

type TelegramConfig

type TelegramConfig struct {
	ApiKey string `yaml:"api_key"`
}

Jump to

Keyboard shortcuts

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