deeprefactoringbot

package module
v0.0.0-...-3b3dc66 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: MIT Imports: 8 Imported by: 0

README

CircleCI Go Report Card

Introduction

This is a community bot of Глубокий Рефакторинг (Deep Refactoring). It can handle various things including producing sarcastic comments on every [@achikin]1 post (not enabled by default).

Development guideline

Create bot api_key

  • In telegram open dialog with [@BotFather]2
  • Follow instructions there to create bot and obtain api_key

Contribution

  • Install [Go 1.8+]3
  • Download code to $GOPATH/src/github.com/deeprefactoring/deeprefactoring-bot folder:
mkdir -p github.com/deeprefactoring
cd github.com/deeprefactoring
git clone github.com/deeprefactoring/deeprefactoring-bot
  • Copy config.yml.example to config.yml
  • Use api_key from previous steps in config.yaml
  • Install dependencies make deps
  • Build make build, produces deeprefactoring-bot binary
  • Run tests make test
Messages

Change messages.yml file to add new bot messages.

[1]: Famous deep refactoring collaborator Anton Chikin in Telegram
[2]: https://telegram.me/BotFather
[3]: https://golang.org/dl

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"`
}

Directories

Path Synopsis
cmd
app
internal

Jump to

Keyboard shortcuts

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