config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config implements several helper functions to abstract away getting information stored. Database used is BoltDB for fast concurrently safe actions. To further abstract away BoltDB which is a K/V store we use github.com/asdine/storm You may read more about these at https://github.com/asdine/storm & https://github.com/boltdb/bolt

Index

Constants

This section is empty.

Variables

View Source
var ConfigDir = filepath.Join(os.Getenv("HOME"), ".config", "instahelper")

ConfigDir is the folder where we should store our config

View Source
var DB *storm.DB

DB is the wrapper around BoltDB. It contains an instance of BoltDB and uses it to perform all the needed operations

View Source
var Models = []interface{}{
	&Account{}, &InstahelperConfig{}, &Notification{},
}

Models for boltdb

Functions

func Accounts

func Accounts() (*[]Account, error)

Accounts will return all accounts in the database

func Close

func Close() error

Close the database. Should be deferred after opening the database

func Delete

func Delete(key string) error

Delete a value from the key value cache.

func Get

func Get(key string) interface{}

Get a value from the key value cache. Returns nil if not found.

func Migrate

func Migrate() error

Migrate will reindex all fields

func Open

func Open() error

Open opens a database at the set location

func Set

func Set(key string, value interface{}, dur time.Duration) error

Set is a quick interface to a key value cache. dur is the amount of time to cache the object before deleting if 0 then will cache infinitely

Types

type Account

type Account struct {
	ID int `storm:"id,increment" json:"id"`

	Username string `storm:"unique" json:"username"`
	Password string `json:"-"`

	// Vanity Info
	FullName  string `json:"full_name"`
	Bio       string `json:"bio"`
	Following int    `json:"following"`
	Followers int    `json:"followers"`
	// profile pic url
	ProfilePic string `json:"profile_pic"`

	Private bool `json:"private"`

	// Cached GoInsta object
	CachedInsta []byte `json:"-"`

	// Settings is not inline to be able to copy over settings between accounts
	Settings `storm:"inline"`

	// LastAccess is the last time the account was accessed using insta.Acc
	LastAccess time.Time `json:"last_access"`

	// LastUpdate is when the vanity info was last updated
	LastUpdate time.Time `json:"last_update"`

	// AddedAt is when the user added this account
	AddedAt time.Time `storm:"index" json:"added_at"`
}

Account is an Instagram Account

func (*Account) Update

func (m *Account) Update() error

Update the model using the values provided - helper function

type InstahelperConfig

type InstahelperConfig struct {
	// AESKey used to encrypt password and Account.CachedInsta
	// Don't change
	AESKey []byte

	ID int `storm:"id"`

	// Username for Instahelper
	Username string

	// Password for Instahelper
	Password string

	// Analytics enabled?
	Analytics bool

	// Automatic Updates?
	// TODO
	AutomaticUpdates bool
}

InstahelperConfig is information about the Instahelper package as a whole

func Config

func Config() (*InstahelperConfig, error)

Config will return the instahelper config

func (*InstahelperConfig) Update

func (m *InstahelperConfig) Update() error

Update the model using the values provided - helper function

type Notification

type Notification struct {
	ID   int    `storm:"id,increment" json:"id"`
	Link string `json:"link"`
	Text string `json:"text,omitempty"`
}

A Notification that would be shown in the top navbar.

type Settings

type Settings struct {
	FollowsPerDay   int `json:"follows_per_day,omitempty"`
	CommentsPerDay  int `json:"comments_per_day,omitempty"`
	LikesPerDay     int `json:"likes_per_day,omitempty"`
	UnfollowsPerDay int `json:"unfollows_per_day,omitempty"`

	// Proxy to make requests with
	Proxy string `json:"proxy,omitempty"`

	// UnfollowAt is the number of follows when the bot should start unfollowing
	UnfollowAt int `json:"unfollow_at,omitempty"`
	// UnfollowNonFollowers will decide if we unfollow those who do not follow after one day
	UnfollowNonFollowers bool `json:"unfollow_non_followers,omitempty"`

	// Tags to follow, comment, or like
	Tags []string `json:"tags,omitempty"`
	// CommentList is the list of comments to choose from when commenting
	CommentList []string `json:"comment_list,omitempty"`

	// Blacklist is a list of accounts to avoid following, commenting, or liking
	Blacklist []string `json:"blacklist,omitempty"`
	// Whitelist is the list of users to only follow, comment, and like on
	Whitelist []string `json:"whitelist,omitempty"`

	// FollowPrivate will decide if we follow private accounts
	FollowPrivate bool `json:"follow_private,omitempty"`
}

Settings for a given account

Jump to

Keyboard shortcuts

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