package discord import ( "dorisbot/models" "errors" "time" ) // ChannelFacebookRT - type ChannelFacebookRT struct { Channel string `db:"channel"` Facebook string `db:"facebook"` Tmpl string `db:"tmpl"` Ctime time.Time `db:"ctime"` Mtime time.Time `db:"mtime"` } // ChannelInstagramRT - type ChannelInstagramRT struct { Channel string `db:"channel"` Instagram string `db:"instagram"` Tmpl string `db:"tmpl"` Ctime time.Time `db:"ctime"` Mtime time.Time `db:"mtime"` } // ChannelYoutubeRT - type ChannelYoutubeRT struct { Channel string `db:"channel"` Youtube string `db:"youtube"` Tmpl string `db:"tmpl"` Ctime time.Time `db:"ctime"` Mtime time.Time `db:"mtime"` } // ChannelTwitchRT - type ChannelTwitchRT struct { Channel string `db:"channel"` Twitch string `db:"twitch"` Tmpl string `db:"tmpl"` Ctime time.Time `db:"ctime"` Mtime time.Time `db:"mtime"` } // CreateFacebookRT - func CreateFacebookRT(channel, facebook, tmpl string) (rt *ChannelFacebookRT, err error) { if len(channel) == 0 || len(facebook) == 0 { return nil, errors.New("channel or fbid is empty") } rt = &ChannelFacebookRT{ Channel: channel, Facebook: facebook, Tmpl: tmpl, } return } // GetFacebookRT - func GetFacebookRT(channel, facebook string) (rt *ChannelFacebookRT, err error) { if len(channel) == 0 || len(facebook) == 0 { return nil, errors.New("channel or fbid is empty") } rt = &ChannelFacebookRT{} db := models.GetConn() query := `select channel, facebook, tmpl, ctime, mtime where channel = $1 and facebook = $2` err = db.Get(rt, query, channel, facebook) if err != nil { return nil, err } return }