types

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Username string `json:"username" yaml:"username" validate:"required,min=1,max=30"`
	Password string `json:"password" yaml:"password" validate:"required,min=1"`
}

Account store personnal credentials

type AccountYaml

type AccountYaml struct {
	Username string `json:"username" yaml:"username" validate:"required,min=1,max=30"`
	Password string `json:"password" yaml:"password" validate:"required"`
}

AccountYaml is the yaml account configuration representation

type AutoDM

type AutoDM struct {
	// List of all availlables message templates
	DmTemplates []string `json:"dmTemplates" yaml:"dm_templates" validate:"required"`
	// Greeting module add a customized DM header with recipient username
	Greeting  GreetingConfig `yaml:"greeting"`
	Activated bool           `json:"dmActivated" yaml:"activated"`
}

AutoDM store messaging module configuration

type AutoDmYaml

type AutoDmYaml struct {
	DmTemplates SplitStringSlice `json:"dmTemplates" yaml:"dm_templates" validate:"required"`
	Greeting    GreetingYaml     `json:"greeting" yaml:"greeting"`
	Activated   bool             `json:"dmActivation,string" yaml:"activated"`
}

AutoDmYaml is the yaml autodm module configuration representation

type BlacklistYaml

type BlacklistYaml struct {
	Activated bool `json:"blacklistActivation,string" yaml:"activated"`
}

BlacklistYaml is the yaml blacklist module configuration representation

type BotConfigYaml

type BotConfigYaml struct {
	Account   AccountYaml   `json:"account" yaml:"account"`
	SrcUsers  ScrapperYaml  `json:"scrapper" yaml:"scrapper"`
	AutoDm    AutoDmYaml    `json:"auto_dm" yaml:"auto_dm"`
	Quotas    QuotasYaml    `json:"quotas" yaml:"quotas"`
	Schedule  ScheduleYaml  `json:"schedule" yaml:"schedule"`
	Blacklist BlacklistYaml `json:"blacklist" yaml:"blacklist"`
	Selenium  SeleniumYaml  `json:"webdriver" yaml:"webdriver"`
}

BotConfigYaml is the raw representation of the yaml bot config file

type GreetingConfig

type GreetingConfig struct {
	// Add a string before the username
	Template  string `json:"greetingTemplate" yaml:"template" validate:"required"`
	Activated bool   `json:"greetingActivated" yaml:"activated"`
}

GreetingConfig store greeting configuration for AutoDM module

type GreetingYaml

type GreetingYaml struct {
	Template  string `json:"greetingTemplate" yaml:"template"`
	Activated bool   `json:"greetingActivation,string" yaml:"activated"`
}

GreetingYaml is the yaml dm greeting configuration representation

type IGopher

type IGopher struct {
	// SeleniumStruct contain all selenium stuff and config
	SeleniumStruct engine.Selenium `yaml:"webdriver"`
	// User credentials
	UserAccount Account `yaml:"account"`
	// Automatic messages sending module
	DmModule AutoDM `yaml:"auto_dm"`
	// Quotas
	Quotas quotas.QuotaManager `yaml:"quotas"`
	// Scrapper
	ScrapperManager ScrapperConfig `yaml:"scrapper"`
	// Scheduler
	Scheduler scheduler.Manager `yaml:"schedule"`
	// Interracted users blacklist
	Blacklist blacklist.Manager `yaml:"blacklist"`
	// Channels
	InfoCh            chan string `yaml:"-"`
	ErrCh             chan string `yaml:"-"`
	CrashCh           chan error  `yaml:"-"`
	ExitCh            chan bool   `yaml:"-"`
	HotReloadCallback chan bool   `yaml:"-"`
	ReloadCallback    chan bool   `yaml:"-"`
	// Running state
	Running bool `yaml:"-"`
}

IGopher struct store all bot and ig related configuration and modules instances. Settings are readed from Yaml config files.

func ReadBotConfigYaml

func ReadBotConfigYaml() (IGopher, error)

ReadBotConfigYaml read config yml file and initialize it for use with bot

func (*IGopher) HotReload

func (bot *IGopher) HotReload() error

HotReload update bot config without stopping it Some settings cannot be updated this way like account credentials

type QuotasYaml

type QuotasYaml struct {
	DmDay     int  `json:"dmDay,string" yaml:"dm_per_day" validate:"numeric,min=1"`
	DmHour    int  `json:"dmHour,string" yaml:"dm_per_hour" validate:"numeric,min=1"`
	Activated bool `json:"quotasActivation,string" yaml:"activated"`
}

QuotasYaml is the yaml quotas module configuration representation

type ScheduleYaml

type ScheduleYaml struct {
	BeginAt   string `json:"beginAt" yaml:"begin_at" validate:"contains=:"`
	EndAt     string `json:"endAt" yaml:"end_at" validate:"contains=:"`
	Activated bool   `json:"scheduleActivation,string" yaml:"activated"`
}

ScheduleYaml is the yaml scheduler module configuration representation

type ScrapperConfig

type ScrapperConfig struct {
	SrcAccounts     []string `yaml:"src_accounts"`
	FetchedAccounts []string
	Quantity        int `yaml:"fetch_quantity" validate:"numeric"`
}

ScrapperConfig store scrapper configuration for user fetching It also store fetched usernames

type ScrapperYaml

type ScrapperYaml struct {
	Accounts SplitStringSlice `json:"srcUsers" yaml:"src_accounts" validate:"required"`
	Quantity int              `json:"scrappingQuantity,string" yaml:"fetch_quantity" validate:"numeric,min=1"`
}

ScrapperYaml is the yaml user scrapping configuration representation

type SeleniumYaml

type SeleniumYaml struct {
	Proxy proxy.Proxy `json:"proxy" yaml:"proxy"`
}

SeleniumYaml is the yaml selenium configuration representation

type SplitStringSlice

type SplitStringSlice []string

SplitStringSlice is a custom string slice type used to define a custom json unmarshal rule

func (*SplitStringSlice) UnmarshalJSON

func (strSlice *SplitStringSlice) UnmarshalJSON(data []byte) error

UnmarshalJSON custom rule for unmarshal string array from string by splitting it by ';'

Jump to

Keyboard shortcuts

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