IGopher: github.com/hbollon/IGopher Index | Files

package igopher

import "github.com/hbollon/IGopher"


Package Files

actions.go config.go dependencies.go engine.go modules.go simulation.go utils.go

func ClearTerminal Uses

func ClearTerminal()

ClearTerminal clear current terminal session according to user OS

func DownloadDependencies Uses

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 Uses

func ExportConfig(c BotConfigYaml)

ExportConfig export BotConfigYaml instance to config.yaml config file

func SimulateHandWriting Uses

func SimulateHandWriting(element selenium.WebElement, input string) bool

SimulateHandWriting simulate human writing by typing input string character by character with random interruptions between letters

type Account Uses

type Account struct {
    Username string `yaml:"username"`
    Password string `yaml:"password"`

Account store personnal credentials

type AccountYaml Uses

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 Uses

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 GreetingConfig `yaml:"greeting"`

AutoDM store messaging module configuration

type AutoDmYaml Uses

type AutoDmYaml struct {
    DmTemplates []string     `yaml:"dm_templates"`
    Greeting    GreetingYaml `yaml:"greeting"`
    Activated   bool         `yaml:"activated"`

AutoDmYaml is the yaml autodm module configuration representation

type BlacklistManager Uses

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 Uses

func (bm *BlacklistManager) AddUser(user string)

AddUser add argument username to the blacklist

func (*BlacklistManager) InitializeBlacklist Uses

func (bm *BlacklistManager) InitializeBlacklist() error

InitializeBlacklist check existence of the blacklist csv file and initialize it if it doesn't exist.

func (*BlacklistManager) IsBlacklisted Uses

func (bm *BlacklistManager) IsBlacklisted(user string) bool

IsBlacklisted check if the given user is already blacklisted

type BlacklistYaml Uses

type BlacklistYaml struct {
    Activated bool `yaml:"activated"`

BlacklistYaml is the yaml blacklist module configuration representation

type BotConfig Uses

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 BotConfigYaml Uses

type BotConfigYaml struct {
    Account   AccountYaml   `yaml:"account"`
    SrcUsers  SrcUsersYaml  `yaml:"users_src"`
    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 Uses

func ImportConfig() BotConfigYaml

ImportConfig read config.yaml, parse it in BotCvalidate:"numeric"onfigYaml instance and finally return it

func ResetBotConfig Uses

func ResetBotConfig() BotConfigYaml

ResetBotConfig return default bot configuration instance

type ClientConfig Uses

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 Uses

func CreateClientConfig() *ClientConfig

CreateClientConfig create default ClientConfig instance and return a pointer on it

type CustomTime Uses

type CustomTime struct {

CustomTime is a custom time.Time used to set a custom yaml unmarshal rule

func (*CustomTime) UnmarshalYAML Uses

func (t *CustomTime) UnmarshalYAML(unmarshal func(interface{}) error) error

type GreetingConfig Uses

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 Uses

type GreetingYaml struct {
    Template  string `yaml:"template"`
    Activated bool   `yaml:"activated"`

GreetingYaml is the yaml dm greeting configuration representation

type QuotaManager Uses

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 Uses

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 Uses

func (qm *QuotaManager) CheckQuotas()

CheckQuotas check if quotas have not been exceeded and pauses the program otherwise.

func (*QuotaManager) InitializeQuotaManager Uses

func (qm *QuotaManager) InitializeQuotaManager()

InitializeQuotaManager initialize Quota manager with user settings

func (*QuotaManager) ResetDailyQuotas Uses

func (qm *QuotaManager) ResetDailyQuotas()

ResetDailyQuotas reset daily dm counter and update timestamp

func (*QuotaManager) ResetHourlyQuotas Uses

func (qm *QuotaManager) ResetHourlyQuotas()

ResetHourlyQuotas reset hourly dm counter and update timestamp

type QuotasYaml Uses

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 Uses

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 Uses

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 Uses

func (s *SchedulerManager) CheckTime() error

CheckTime check scheduler and pause the bot if it's not working time

type Selenium Uses

type Selenium struct {
    Instance  *selenium.Service
    Config    *ClientConfig
    Opts      []selenium.ServiceOption
    WebDriver selenium.WebDriver

Selenium instance and opts

func (*Selenium) CloseSelenium Uses

func (s *Selenium) CloseSelenium()

CloseSelenium close webdriver and selenium instance

func (*Selenium) ConnectToInstagram Uses

func (s *Selenium) ConnectToInstagram()

ConnectToInstagram get ig login webpage and connect user account

func (*Selenium) Fatal Uses

func (s *Selenium) Fatal(msg string, err error)

Fatal closes all selenium stuff and call logrus fatal with error printing

func (*Selenium) GetElement Uses

func (s *Selenium) GetElement(elementTag, locator string) (selenium.WebElement, error)

GetElement wait for element and then return when it is available

func (*Selenium) InitChromeWebDriver Uses

func (s *Selenium) InitChromeWebDriver()

InitChromeWebDriver init and launch web driver with Chrome

func (*Selenium) InitFirefoxWebDriver Uses

func (s *Selenium) InitFirefoxWebDriver()

InitFirefoxWebDriver init and launch web driver with Firefox

func (*Selenium) InitializeSelenium Uses

func (s *Selenium) InitializeSelenium(clientConfig *ClientConfig)

InitializeSelenium start a Selenium WebDriver server instance (if one is not already running).

func (*Selenium) IsElementPresent Uses

func (s *Selenium) IsElementPresent(by, value string) bool

IsElementPresent check if an element is present on the current webpage

func (*Selenium) SendMessage Uses

func (s *Selenium) SendMessage(user, message string) (bool, error)

SendMessage navigate to Instagram direct message interface and send one to specified user by simulating human typing

func (*Selenium) WaitForElement Uses

func (s *Selenium) WaitForElement(elementTag, locator string, delay int) (bool, error)

WaitForElement search and wait until searched element appears. Delay argument is in seconds.

type SrcUsersYaml Uses

type SrcUsersYaml struct {
    Accounts []string `yaml:"src_accounts"`
    Quantity int      `yaml:"fetch_quantity" validate:"numeric"`

SrcUsersYaml is the yaml user scrapping configuration representation

Package igopher imports 30 packages (graph). Updated 2021-01-26. Refresh now. Tools for package owners.