models

package
v0.0.0-...-09ac254 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CHANNEL_STATE_EMPTY = "empty"
View Source
const CHANNEL_STATE_START = "start"
View Source
const CHANNEL_STATE_STOP = "stop"
View Source
const INSTAGRAM_STATE_START = "start"
View Source
const INSTAGRAM_STATE_STOP = "stop"
View Source
const INSTAGRAM_STATE_SUSPECTED = "suspected"

Variables

View Source
var ACTIONS = [4]string{
	"like",
	"comment",
	"follow",
	"unfollow",
}
View Source
var Engine *xorm.Engine
View Source
var INSTAGRAM_REGISTRY map[int64]*WorkersPool = map[int64]*WorkersPool{}
View Source
var TARGETS = [5]string{
	"followers",
	"subscriptions",
	"hashtag",
	"likes",
	"comments",
}

Functions

func DeleteChannel

func DeleteChannel(channel *Channel) error

func DeleteInstagram

func DeleteInstagram(instagram *Instagram) error

func Init

func Init(dbstring string)

func Stop

func Stop()

Types

type Channel

type Channel struct {
	Id             int64     `json:"id"              xorm:"pk autoincr index"`
	InstagramId    int64     `json:"-"               xorm:"index"`
	Action         string    `json:"action"          xorm:"varchar(250) notnull"`
	Target         string    `json:"target"          xorm:"varchar(250) notnull"`
	Value          string    `json:"value"           xorm:"varchar(250) notnull"`
	Comments       []string  `json:"comments"        xorm:"jsonb"`
	State          string    `json:"state"           xorm:"varchar(250) notnull default 'stop'"`
	LeadsCount     int       `json:"leads_count"     xorm:"integer"`
	TargetsCount   int       `json:"targets_count"   xorm:"integer"`
	FollowersCount int       `json:"followers_count" xorm:"integer default 0"`
	Version        int       `json:"-"               xorm:"version"`
	CreatedAt      time.Time `json:"created_at"      xorm:"created"`
	UpdatedAt      time.Time `json:"updated_at"      xorm:"updated"`
	*Queue         `json:"-" xorm:"jsonb"`
}

func CreateChannel

func CreateChannel(instagram *Instagram, c *ChannelCredentials) (*Channel, error)

func FindActiveChannels

func FindActiveChannels(instagram *Instagram, action string) ([]*Channel, error)

func FindChannels

func FindChannels(instagram *Instagram) ([]*Channel, error)

func GetChannel

func GetChannel(instagram *Instagram, id int64) (*Channel, error)

func UpdateChannel

func UpdateChannel(channel *Channel, c *ChannelCredentials) (*Channel, error)

func (*Channel) IdString

func (c *Channel) IdString() string

func (*Channel) Instagram

func (c *Channel) Instagram() (*Instagram, error)

func (*Channel) Leads

func (c *Channel) Leads() map[int]bool

func (*Channel) Save

func (c *Channel) Save(update func(c *Channel)) error

type ChannelCredentials

type ChannelCredentials struct {
	Value    string   `json:"value"`
	Action   string   `json:"action"`
	Target   string   `json:"target"`
	Comments []string `json:"comments"`
}

type Counters

type Counters struct {
	Like      int
	Comment   int
	Follow    int
	Unfollow  int
	StartedAt time.Time
}

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Hours

type Hours struct {
	Min int `json:"min"`
	Max int `json:"max"`
}

type Instagram

type Instagram struct {
	Id     int64 `json:"id" xorm:"pk autoincr index"`
	UserId int64 `json:"-" xorm:"index"`

	Info *instabot.UserInfo `json:"info" xorm:"jsonb"`

	State string `json:"state" xorm:"varchar(250) notnull default 'stop'"`

	Username string `json:"username" xorm:"notnull index"`
	Password string `json:"password" xorm:"varchar(250) notnull"`
	Trusted  bool   `json:"trusted" xorm:"bool notnull default false"`
	*Hours   `json:"hours" xorm:"jsonb"`
	*Speed   `json:"speed" xorm:"jsonb"`

	*Counters `json:"-" xorm:"jsonb"`

	Version   int       `json:"-" xorm:"version"`
	CreatedAt time.Time `json:"created_at" xorm:"created"`
	UpdatedAt time.Time `json:"updated_at" xorm:"updated"`
}

TODO: Add FollowersCount field for summary over the channels

func CreateInstagram

func CreateInstagram(user *User, c *InstagramCredentials) (*Instagram, error)

func FindAllInstagrams

func FindAllInstagrams() ([]*Instagram, error)

func FindInstagrams

func FindInstagrams(user *User) ([]*Instagram, error)

func GetInstagram

func GetInstagram(user *User, id int64) (*Instagram, error)

func UpdateInstagram

func UpdateInstagram(instagram *Instagram, c *InstagramCredentials) (*Instagram, error)

func UpdateInstagramById

func UpdateInstagramById(instagram *Instagram) (*Instagram, error)

func (*Instagram) ActionSpeed

func (i *Instagram) ActionSpeed(action string) int

func (*Instagram) CheckLimits

func (i *Instagram) CheckLimits(action string) bool

func (*Instagram) CreateChannel

func (i *Instagram) CreateChannel(c *ChannelCredentials) (*Channel, error)

func (*Instagram) DeleteChannel

func (i *Instagram) DeleteChannel(channel *Channel) error

func (*Instagram) FindActiveChannels

func (i *Instagram) FindActiveChannels(action string) ([]*Channel, error)

func (*Instagram) FindChannels

func (i *Instagram) FindChannels() ([]*Channel, error)

func (*Instagram) FindLimits

func (i *Instagram) FindLimits() *Limits

func (*Instagram) GetChannel

func (i *Instagram) GetChannel(id int64) (*Channel, error)

func (*Instagram) IdString

func (i *Instagram) IdString() string

func (*Instagram) Save

func (i *Instagram) Save(callback func(i *Instagram)) error

func (*Instagram) SyncSave

func (i *Instagram) SyncSave(callback func(i *Instagram)) error

func (*Instagram) UpdateChannel

func (i *Instagram) UpdateChannel(channel *Channel, c *ChannelCredentials) (*Channel, error)

func (*Instagram) UpdateInfo

func (i *Instagram) UpdateInfo(client *instabot.Client) error

func (*Instagram) UpdateLimits

func (i *Instagram) UpdateLimits(action string) error

func (*Instagram) User

func (i *Instagram) User() (*User, error)

func (*Instagram) ValidateState

func (i *Instagram) ValidateState(client *instabot.Client) error

type InstagramCredentials

type InstagramCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Trusted  bool   `json:"trusted"`
	Speed    `json:"speed"`
	Hours    `json:"hours"`
}

type InstagramReadOp

type InstagramReadOp struct {
	Error error
}

type InstagramWriteOp

type InstagramWriteOp struct {
	Instagram   *Instagram
	Callback    func(i *Instagram)
	ReadChannel chan *InstagramReadOp
}

type Limits

type Limits struct {
	Like     int
	Comment  int
	Follow   int
	Unfollow int
}

type Queue

type Queue struct {
	MaxId   string
	Leads   []int
	Targets []int
}

type Speed

type Speed struct {
	Like     int `json:"like"`
	Comment  int `json:"comment"`
	Follow   int `json:"follow"`
	Unfollow int `json:"unfollow"`
}

type User

type User struct {
	Id        int64     `json:"id"         xorm:"pk autoincr index"`
	Username  string    `json:"username"   xorm:"notnull index unique"`
	Password  string    `json:"-"          xorm:"varchar(200) notnull"`
	CreatedAt time.Time `json:"created_at" xorm:"created"`
	UpdatedAt time.Time `json:"updated_at" xorm:"updated"`
}

func CreateUser

func CreateUser(c *Credentials) (*User, error)

func GetUser

func GetUser(username string) (*User, error)

func (*User) CreateInstagram

func (u *User) CreateInstagram(c *InstagramCredentials) (*Instagram, error)

func (*User) DeleteInstagram

func (u *User) DeleteInstagram(instagram *Instagram) error

func (*User) FindInstagrams

func (u *User) FindInstagrams() ([]*Instagram, error)

func (*User) GetInstagram

func (u *User) GetInstagram(id int64) (*Instagram, error)

func (*User) UpdateInstagram

func (u *User) UpdateInstagram(instagram *Instagram, c *InstagramCredentials) (*Instagram, error)

func (*User) Verify

func (u *User) Verify(password string) bool

type WorkersPool

type WorkersPool struct {
	WriteOpCh          chan *InstagramWriteOp
	InstagramCommandCh chan string
	StatsCommandCh     chan string
	ChannelCommandChs  map[string]chan string
}

Jump to

Keyboard shortcuts

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