Documentation ΒΆ
Index ΒΆ
- func DownloadDependencies(downloadBrowsers, downloadLatest, forceDl bool)
- func SimulateHandWriting(element selenium.WebElement, input string) bool
- type Account
- type AutoDM
- type BlacklistManager
- type BotConfig
- type ClientConfig
- type CustomTime
- type QuotaManager
- type SchedulerManager
- type Selenium
- func (s *Selenium) CloseSelenium()
- func (s *Selenium) ConnectToInstagram()
- func (s *Selenium) Fatal(msg string, err error)
- func (s *Selenium) GetElement(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) SendMessage(user, message string) (bool, error)
- func (s *Selenium) WaitForElement(elementTag, locator string, delay int) (bool, error)
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
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 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 AutoDM ΒΆ
type AutoDM struct { Activated bool `yaml:"activated"` // List of all availlables message templates DmTemplates []string `yaml:"dm_templates"` // Greeting module add a customized DM header with recipient username Greeting struct { Activated bool `yaml:"activated"` // Add a string before the username Template string `yaml:"template"` } `yaml:"greeting"` }
AutoDM store messaging module configuration
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) 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 BotConfig ΒΆ
type BotConfig struct { // User credentials UserAccount Account `yaml:"account"` // Automatic messages sending module DmModule AutoDM `yaml:"auto_dm"` // Quotas Quotas QuotaManager `yaml:"quotas"` // Scheduler Scheduler SchedulerManager `yaml:"schedule"` // Interracted users blacklist Blacklist BlacklistManager `yaml:"blacklist"` }
BotConfig struct store all bot and ig related configuration . These parameters are readed from Yaml config files.
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 BotConfig BotConfig }
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 CustomTime ΒΆ
CustomTime is a custom time.Time used to set a custom yaml unmarshal rule
func (*CustomTime) UnmarshalYAML ΒΆ
func (t *CustomTime) UnmarshalYAML(unmarshal func(interface{}) error) error
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"` // MaxDmDay: maximum dm quantity per day MaxDmDay int `yaml:"dm_per_day"` // 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 SchedulerManager ΒΆ
type SchedulerManager struct { // HourTimestamp: hourly timestamp used to handle hour limitations BeginAt CustomTime `yaml:"begin_at"` // DayTimestamp: daily timestamp used to handle day limitations EndAt CustomTime `yaml:"end_at"` // 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
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) ConnectToInstagram ΒΆ
func (s *Selenium) ConnectToInstagram()
ConnectToInstagram get ig login webpage and connect user account
func (*Selenium) GetElement ΒΆ
func (s *Selenium) GetElement(elementTag, locator string) (selenium.WebElement, error)
GetElement wait for element and then return when it is 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
func (*Selenium) SendMessage ΒΆ
SendMessage navigate to Instagram direct message interface and send one to specified user by simulating human typing