igopher

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 33 Imported by: 0

README ΒΆ

IGopher : (WIP) Golang smart bot for Instagram DM automation

IGopher logo

Build CI Go Report Card Documentation link PkgGoDev

⚑ Powerful, customizable and easy to use Instagram dm bot. With TUI and GUI! Using Selenium webdriver and Yaml configuration files.


Disclaimer: This is a research project. I am in no way responsible for the use you made of this tool. In addition, I am not responsible for any sanctions and/or limitations imposed on your account after using this bot.


Table of Contents

Introduction

IGopher is a new Instagram automation tool that aims to simplify the deployment of such tools and make their use more pleasant thanks to a TUI (terminal User Interface) as well as a GUI (Graphical User Interface) arriving very soon.

Automatic user fetching and message sending!

The bot configuration is very easy thanks to the different configuration menus in the TUI. Parameters are managed and saved in Yaml files easy to edit manually!

Easily configurable and easy to use thanks to his TUI !

Requirements

  • For Windows:

Features

  • Selenium webdriver engine 🌠
  • Automatic dependencies downloading and installation 🌠
  • Automated IG connection & message sending 🌠
  • Users scrapping from ig user followers 🌠
  • Scheduler 🌠
  • Quotas & user blacklist modules 🌠
  • Human writing simulation 🌠
  • Fully and easily customizable through Yaml files or with TUI 🌠
  • TUI (Terminal User Interface) 🌠
  • Many more to come ! πŸ₯³

Check this Project to see all planned features for this tool! Feel free to suggest additional features to implement! πŸ₯³

Getting Started

From release

  1. Download lastest release executable for your operating system
  2. Move the executable to a dedicated folder (it will create folders/files)
  3. Launch it:
  • On Windows, open a Windows Terminal in the folder (or powershell/cmd but the experience quality can be lower) and execute it: ./tui.exe
  • On Linux, open you favorite shell in the folder and execute it: ./tui
  1. Configure the bot with your Instagram credentials and set your desired scrapping and autodm settings. To do that, you can use the TUI settings screen or directly edit the config.yaml file.
  2. You're ready! Just hit the "Launch" option in the TUI main menu πŸš€

From sources

  1. Install Go (v1.13+) on your system
  2. Download lastest release source archive or clone the master branch
  3. Launch it with this command: go run ./cmd/igopher/tui
  4. Configure the bot with your Instagram credentials and set your desired scrapping and autodm settings. To do that, you can use the TUI settings screen or directly edit the config.yaml file.
  5. You're ready! Just hit the "Launch" option in the TUI main menu πŸš€

Flags

IGopher have a flags system for debuging or to enable system feature. You can activate them by adding them after the executable call, for exemple to activate headless mode: ./tui --headless

There is the list of all available flags:

--debug
      Display debug and selenium output
--force-download
      Force redownload of all dependencies even if exists
--headless
      Run WebDriver with frame buffer
--ignore-dependencies
      Skip dependencies management
--loglevel string
      Log level threshold (default "info")
--port int
      Specify custom communication port (default 8080)

You can recover this list by adding --help flag.

🀝 Contributing

Contributions are greatly appreciated!

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some amazing stuff')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Create a new Pull Request

Issues and feature requests are welcome! Feel free to check issues page.

Author

πŸ‘€ Hugo Bollon

Show your support

Give a ⭐️ if this project helped you!

πŸ“ License

This project is under MIT license.

Documentation ΒΆ

Index ΒΆ

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 ΒΆ

type GreetingYaml struct {
	Template  string `yaml:"template"`
	Activated bool   `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"`
}

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

func ReadBotConfigYaml ΒΆ

func ReadBotConfigYaml() IGopher

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 ΒΆ

func (sc *IGopher) FetchUsersFromUserFollowers() ([]string, error)

FetchUsersFromUserFollowers scrap username list from users followers. Source accounts and quantity are set by the bot user.

func (*IGopher) SendMessage ΒΆ

func (bot *IGopher) SendMessage(user, message string) (bool, error)

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

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) Fatal ΒΆ

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

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

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 ΒΆ

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

IsElementPresent check if an element is present on the current webpage

func (*Selenium) WaitForElement ΒΆ

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

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

Directories ΒΆ

Path Synopsis
cmd
igopher command
igopher/tui command

Jump to

Keyboard shortcuts

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