Documentation
ΒΆ
Index ΒΆ
- func CheckConfigValidity() error
- func CheckEnvironment()
- func ClearTerminal()
- func DownloadDependencies(downloadBrowsers, downloadLatest, forceDl bool)
- func ExportConfig(c BotConfigYaml)
- func SimulateHandWriting(element selenium.WebElement, input string) bool
- type Account
- type AccountYaml
- type AutoDM
- type AutoDmYaml
- type BlacklistManager
- type BlacklistYaml
- type BotConfigYaml
- type ClientConfig
- type GreetingConfig
- type GreetingYaml
- type IGopher
- type QuotaManager
- type QuotasYaml
- type ScheduleYaml
- type SchedulerManager
- type ScrapperConfig
- type ScrapperYaml
- type Selenium
- func (s *Selenium) CloseSelenium()
- func (s *Selenium) Fatal(msg string, err error)
- func (s *Selenium) GetElement(elementTag, locator string) (selenium.WebElement, error)
- func (s *Selenium) GetElements(elementTag, locator string) ([]selenium.WebElement, error)
- func (s *Selenium) InitChromeWebDriver()
- func (s *Selenium) InitFirefoxWebDriver()
- func (s *Selenium) InitializeSelenium(clientConfig *ClientConfig)
- func (s *Selenium) IsElementPresent(by, value string) bool
- func (s *Selenium) WaitForElement(elementTag, locator string, delay int) (bool, error)
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func CheckConfigValidity ΒΆ
func CheckConfigValidity() error
CheckConfigValidity check bot config validity
func CheckEnvironment ΒΆ
func CheckEnvironment()
CheckEnvironment check existence of sub-directories and files required for the operation of the program and creates them otherwise
func ClearTerminal ΒΆ
func ClearTerminal()
ClearTerminal clear current terminal session according to user OS
func DownloadDependencies ΒΆ
func DownloadDependencies(downloadBrowsers, downloadLatest, forceDl bool)
DownloadDependencies automate selenium dependencies downloading (ChromeDriver binary, the Firefox binary, the Selenium WebDriver JARs, and the Sauce Connect proxy binary)
func ExportConfig ΒΆ
func ExportConfig(c BotConfigYaml)
ExportConfig export BotConfigYaml instance to config.yaml config file
func SimulateHandWriting ΒΆ
func SimulateHandWriting(element selenium.WebElement, input string) bool
SimulateHandWriting simulate human writing by typing input string character by character with random interruptions between letters
Types ΒΆ
type Account ΒΆ
type Account struct {
Username string `yaml:"username" validate:"required,min=1,max=30"`
Password string `yaml:"password" validate:"required,min=1"`
}
Account store personnal credentials
type AccountYaml ΒΆ
type AccountYaml struct {
Username string `yaml:"username" validate:"required,min=1,max=30"`
Password string `yaml:"password" validate:"required"`
}
AccountYaml is the yaml account configuration representation
type AutoDM ΒΆ
type AutoDM struct {
Activated bool `yaml:"activated"`
// List of all availlables message templates
DmTemplates []string `yaml:"dm_templates" validate:"required"`
// Greeting module add a customized DM header with recipient username
Greeting GreetingConfig `yaml:"greeting"`
}
AutoDM store messaging module configuration
type AutoDmYaml ΒΆ
type AutoDmYaml struct {
DmTemplates []string `yaml:"dm_templates" validate:"required"`
Greeting GreetingYaml `yaml:"greeting"`
Activated bool `yaml:"activated"`
}
AutoDmYaml is the yaml autodm module configuration representation
type BlacklistManager ΒΆ
type BlacklistManager struct {
// BlacklistedUsers: list of all blacklisted usernames
BlacklistedUsers [][]string
// Activated: quota manager activation boolean
Activated bool `yaml:"activated"`
}
BlacklistManager data
func (*BlacklistManager) AddUser ΒΆ
func (bm *BlacklistManager) AddUser(user string)
AddUser add argument username to the blacklist
func (*BlacklistManager) FilterScrappedUsers ΒΆ
func (bm *BlacklistManager) FilterScrappedUsers(users []selenium.WebElement) []selenium.WebElement
FilterScrappedUsers remove blacklisted users from WebElement slice and return it
func (*BlacklistManager) InitializeBlacklist ΒΆ
func (bm *BlacklistManager) InitializeBlacklist() error
InitializeBlacklist check existence of the blacklist csv file and initialize it if it doesn't exist.
func (*BlacklistManager) IsBlacklisted ΒΆ
func (bm *BlacklistManager) IsBlacklisted(user string) bool
IsBlacklisted check if the given user is already blacklisted
type BlacklistYaml ΒΆ
type BlacklistYaml struct {
Activated bool `yaml:"activated"`
}
BlacklistYaml is the yaml blacklist module configuration representation
type BotConfigYaml ΒΆ
type BotConfigYaml struct {
Account AccountYaml `yaml:"account"`
SrcUsers ScrapperYaml `yaml:"scrapper"`
AutoDm AutoDmYaml `yaml:"auto_dm"`
Quotas QuotasYaml `yaml:"quotas"`
Schedule ScheduleYaml `yaml:"schedule"`
Blacklist BlacklistYaml `yaml:"blacklist"`
}
BotConfigYaml is the raw representation of the yaml bot config file
func ImportConfig ΒΆ
func ImportConfig() BotConfigYaml
ImportConfig read config.yaml, parse it in BotConfigYaml instance and finally return it
func ResetBotConfig ΒΆ
func ResetBotConfig() BotConfigYaml
ResetBotConfig return default bot configuration instance
type ClientConfig ΒΆ
type ClientConfig struct {
// LogLevel set loglevel threshold
// If undefined or wrong set it to INFO level
LogLevel logrus.Level
// ForceDependenciesDl force re-download of all dependencies
ForceDependenciesDl bool
// Debug set selenium debug mode and display its logging to stderr
Debug bool
// IgnoreDependencies disable dependencies manager on startup
IgnoreDependencies bool
// Headless execute Selenium webdriver in headless mode
Headless bool
// Port : communication port
Port uint16
}
ClientConfig struct centralize all client configuration and flags. Inizialized at program startup, not safe to modify this after.
func CreateClientConfig ΒΆ
func CreateClientConfig() *ClientConfig
CreateClientConfig create default ClientConfig instance and return a pointer on it
type GreetingConfig ΒΆ
type GreetingConfig struct {
Activated bool `yaml:"activated"`
// Add a string before the username
Template string `yaml:"template"`
}
GreetingConfig store greeting configuration for AutoDM module
type GreetingYaml ΒΆ
GreetingYaml is the yaml dm greeting configuration representation
type IGopher ΒΆ
type IGopher struct {
// SeleniumStruct contain all selenium stuff and config
SeleniumStruct Selenium
// User credentials
UserAccount Account `yaml:"account"`
// Automatic messages sending module
DmModule AutoDM `yaml:"auto_dm"`
// Quotas
Quotas QuotaManager `yaml:"quotas"`
// Scrapper
ScrapperManager ScrapperConfig `yaml:"scrapper"`
// Scheduler
Scheduler SchedulerManager `yaml:"schedule"`
// Interracted users blacklist
Blacklist BlacklistManager `yaml:"blacklist"`
}
IGopher struct store all bot and ig related configuration and modules instances. Settings are readed from Yaml config files.
func ReadBotConfigYaml ΒΆ
func ReadBotConfigYaml() IGopher
ReadBotConfigYaml read config yml file and initialize it for use with bot
func (*IGopher) ConnectToInstagram ΒΆ
func (bot *IGopher) ConnectToInstagram()
ConnectToInstagram get ig login webpage and connect user account
func (*IGopher) FetchUsersFromUserFollowers ΒΆ
FetchUsersFromUserFollowers scrap username list from users followers. Source accounts and quantity are set by the bot user.
type QuotaManager ΒΆ
type QuotaManager struct {
// HourTimestamp: hourly timestamp used to handle hour limitations
HourTimestamp time.Time
// DayTimestamp: daily timestamp used to handle day limitations
DayTimestamp time.Time
// DmSent: quantity of dm sent in the last hour
DmSent int
// DmSentDay: quantity of dm sent in the last day
DmSentDay int
// MaxDmHour: maximum dm quantity per hour
MaxDmHour int `yaml:"dm_per_hour" validate:"numeric"`
// MaxDmDay: maximum dm quantity per day
MaxDmDay int `yaml:"dm_per_day" validate:"numeric"`
// Activated: quota manager activation boolean
Activated bool `yaml:"activated"`
}
QuotaManager data
func (*QuotaManager) AddDm ΒΆ
func (qm *QuotaManager) AddDm()
AddDm report to the manager a message sending. It increment dm counter and check if quotas are still valid.
func (*QuotaManager) CheckQuotas ΒΆ
func (qm *QuotaManager) CheckQuotas()
CheckQuotas check if quotas have not been exceeded and pauses the program otherwise.
func (*QuotaManager) InitializeQuotaManager ΒΆ
func (qm *QuotaManager) InitializeQuotaManager()
InitializeQuotaManager initialize Quota manager with user settings
func (*QuotaManager) ResetDailyQuotas ΒΆ
func (qm *QuotaManager) ResetDailyQuotas()
ResetDailyQuotas reset daily dm counter and update timestamp
func (*QuotaManager) ResetHourlyQuotas ΒΆ
func (qm *QuotaManager) ResetHourlyQuotas()
ResetHourlyQuotas reset hourly dm counter and update timestamp
type QuotasYaml ΒΆ
type QuotasYaml struct {
DmDay int `yaml:"dm_per_day" validate:"numeric"`
DmHour int `yaml:"dm_per_hour" validate:"numeric"`
Activated bool `yaml:"activated"`
}
QuotasYaml is the yaml quotas module configuration representation
type ScheduleYaml ΒΆ
type ScheduleYaml struct {
BeginAt string `yaml:"begin_at" validate:"contains=:"`
EndAt string `yaml:"end_at" validate:"contains=:"`
Activated bool `yaml:"activated"`
}
ScheduleYaml is the yaml scheduler module configuration representation
type SchedulerManager ΒΆ
type SchedulerManager struct {
// BeginAt: Begin time setting
BeginAt string `yaml:"begin_at" validate:"contains=:"`
// EndAt: End time setting
EndAt string `yaml:"end_at" validate:"contains=:"`
// BeginAtTimestamp: begin timestamp
BeginAtTimestamp time.Time
// EndAtTimestamp: end timestamp
EndAtTimestamp time.Time
// Activated: quota manager activation boolean
Activated bool `yaml:"activated"`
}
SchedulerManager data
func (*SchedulerManager) CheckTime ΒΆ
func (s *SchedulerManager) CheckTime() error
CheckTime check scheduler and pause the bot if it's not working time
func (*SchedulerManager) InitializeScheduler ΒΆ
func (s *SchedulerManager) InitializeScheduler() error
InitializeScheduler convert string time from config to time.Time instances
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 []string `yaml:"src_accounts" validate:"required"`
Quantity int `yaml:"fetch_quantity" validate:"numeric,min=1"`
}
ScrapperYaml is the yaml user scrapping configuration representation
type Selenium ΒΆ
type Selenium struct {
Instance *selenium.Service
Config *ClientConfig
Opts []selenium.ServiceOption
WebDriver selenium.WebDriver
}
Selenium instance and opts
func (*Selenium) CloseSelenium ΒΆ
func (s *Selenium) CloseSelenium()
CloseSelenium close webdriver and selenium instance
func (*Selenium) GetElement ΒΆ
func (s *Selenium) GetElement(elementTag, locator string) (selenium.WebElement, error)
GetElement wait for element and then return when it's available
func (*Selenium) GetElements ΒΆ
func (s *Selenium) GetElements(elementTag, locator string) ([]selenium.WebElement, error)
GetElements wait for elements and then return when they're available
func (*Selenium) InitChromeWebDriver ΒΆ
func (s *Selenium) InitChromeWebDriver()
InitChromeWebDriver init and launch web driver with Chrome
func (*Selenium) InitFirefoxWebDriver ΒΆ
func (s *Selenium) InitFirefoxWebDriver()
InitFirefoxWebDriver init and launch web driver with Firefox
func (*Selenium) InitializeSelenium ΒΆ
func (s *Selenium) InitializeSelenium(clientConfig *ClientConfig)
InitializeSelenium start a Selenium WebDriver server instance (if one is not already running).
func (*Selenium) IsElementPresent ΒΆ
IsElementPresent check if an element is present on the current webpage
Automatic user fetching and message sending!
Easily configurable and easy to use thanks to his TUI !