config

package
v0.0.0-...-aa48d00 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config holds everything related to configuration

Package config holds everything related to configuration

Index

Constants

This section is empty.

Variables

View Source
var (
	// Token is the token value of the bot
	Token string
	// BotName contains the @name of the bot after initializing in an account
	BotName string
)
View Source
var (
	// Phrases is the list of predefined phrases to say randomly
	Phrases = []string{}
	// CionList is the list of words ending with "cion"
	CionList map[string]bool
)
View Source
var AutoEnableTimer map[int64]*time.Timer

Contains the timers for the automatic conversation enabled

Functions

func EnabledChatConfig

func EnabledChatConfig(enable bool, scheduleEnableFor *time.Time, chatId int64) error

EnabledChatConfig enable/disable the bot answer

func FindAllChatConfigWithId

func FindAllChatConfigWithId() (map[int64]ChatConfig, error)

FindAllChatConfigWithId Return all the ChatConfig in a map with the chatId

func ScheduleAutoEnable

func ScheduleAutoEnable(chatId int64, scheduleFor *time.Time)

ScheduleAutoEnable schedule the auto enable chatConfig

func UpdateChatConfig

func UpdateChatConfig(chatId int64, input *ChatConfig) error

UpdateChatConfig Persist the ChatConfig for the chatId

Types

type ChatConfig

type ChatConfig struct {
	// Enabled defines if the bot should answer
	Enabled bool
	// DisableUntil defines until bot should not answer
	DisableUntil time.Time
	// PercentAnswer is the probability of anwser to any update
	PercentAnswer int
	// IsGroup is true if the related chat is a group
	IsGroup bool
	// Pole is true if the bot should say "Pole" every day
	Pole bool
}

ChatConfig contains the base configuration for a single chat

func CreateChatConfig

func CreateChatConfig(chatId int64, isGroup bool) *ChatConfig

CreateChatConfig Initialize the ChatConfig for the chatId and persist it

func FindChatConfig

func FindChatConfig(chatId int64) (res *ChatConfig, err error)

FindChatConfig Find the ChatConfig for the chatId

func NewChatConfig

func NewChatConfig(isGroup bool) *ChatConfig

NewChatConfig creates a default chat configuration

Jump to

Keyboard shortcuts

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