Documentation
ΒΆ
Index ΒΆ
- func CheckConfigValidity() error
- func CheckEnvironment()
- func ClearData() error
- func ClearTerminal()
- func DownloadDependencies(downloadBrowsers, downloadLatest, forceDl bool)
- func ExportConfig(c BotConfigYaml)
- func HandleMessages(w *astilectron.Window)
- func LaunchBotTui()
- func SendMessageToElectron(w *astilectron.Window, msg MessageOut, ...)
- 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 MessageIn
- type MessageOut
- 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) SigTermCleaning()
- func (s *Selenium) WaitForElement(elementTag, locator string, delay int) (bool, error)
- type SplitStringSlice
- type SucessState
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 ClearData ΒΆ added in v0.2.0
func ClearData() error
ClearData remove all IGopher data sub-folder and their content. It will recreate the necessary environment at the end no matter if an error has occurred or not.
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 HandleMessages ΒΆ added in v0.2.0
func HandleMessages(w *astilectron.Window)
HandleMessages is handling function for incoming messages
func LaunchBotTui ΒΆ added in v0.2.0
func LaunchBotTui()
LaunchBotTui start dm bot on main goroutine
func SendMessageToElectron ΒΆ added in v0.2.0
func SendMessageToElectron(w *astilectron.Window, msg MessageOut, callback func(m *astilectron.EventMessage))
SendMessageToElectron will send a message to Electron Gui and execute a callback Callback function is optional
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 `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 {
Activated bool `json:"dmActivated" yaml:"activated"`
// 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"`
}
AutoDM store messaging module configuration
type AutoDmYaml ΒΆ
type AutoDmYaml struct {
DmTemplates SplitStringSlice `json:"dmTemplates" yaml:"dm_templates" validate:"required"`
Greeting GreetingYaml `yaml:"greeting"`
Activated bool `json:"dmActivation,string" 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 `json:"blacklistActivation,string" 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
//DevTools launch Electron gui with devtools openned
DevTools 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 `json:"greetingActivated" yaml:"activated"`
// Add a string before the username
Template string `json:"greetingTemplate" yaml:"template" validate:"required"`
}
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 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"`
// contains filtered or unexported fields
}
IGopher struct store all bot and ig related configuration and modules instances. Settings are readed from Yaml config files.
var BotStruct IGopher
BotStruct is the main struct instance used by this bot
func ReadBotConfigYaml ΒΆ
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 MessageIn ΒΆ added in v0.2.0
type MessageIn struct {
Msg string `json:"msg"`
Payload json.RawMessage `json:"payload,omitempty"`
}
MessageIn represents a message from electron (going in)
type MessageOut ΒΆ added in v0.2.0
type MessageOut struct {
Status SucessState `json:"status"`
Msg string `json:"msg"`
Payload interface{} `json:"payload,omitempty"`
}
MessageOut represents a message for electron (going out)
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 `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 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 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 Selenium ΒΆ
type Selenium struct {
Instance *selenium.Service
Config *ClientConfig
Opts []selenium.ServiceOption
WebDriver selenium.WebDriver
SigTermRoutineExit chan bool
}
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
func (*Selenium) SigTermCleaning ΒΆ added in v0.2.0
func (s *Selenium) SigTermCleaning()
SigTermCleaning launch a gouroutine to handle SigTerm signal and trigger Selenium and Webdriver close if it raised
type SplitStringSlice ΒΆ added in v0.2.0
type SplitStringSlice []string
SplitStringSlice is a custom string slice type used to define a custom json unmarshal rule
func (*SplitStringSlice) UnmarshalJSON ΒΆ added in v0.2.0
func (strSlice *SplitStringSlice) UnmarshalJSON(data []byte) error
UnmarshalJSON custom rule for unmarshal string array from string by splitting it by ';'
type SucessState ΒΆ added in v0.2.0
type SucessState string
const ( SUCCESS SucessState = "Success" ERROR SucessState = "Error" )
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
igopher/gui
command
|
|
|
igopher/gui-bundler
command
|
|
|
igopher/tui
command
|
|
|
internal
|
|
Automatic user fetching and message sending!
Easily configurable and easy to use thanks to his TUI !