2019-07-13 09:44:31 +00:00
|
|
|
package discord
|
|
|
|
|
2019-07-14 07:04:14 +00:00
|
|
|
import (
|
|
|
|
"dorisbot/models"
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
)
|
2019-07-13 09:44:31 +00:00
|
|
|
|
|
|
|
// 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 -
|
2019-07-14 07:04:14 +00:00
|
|
|
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
|
|
|
|
}
|
2019-07-13 09:44:31 +00:00
|
|
|
return
|
|
|
|
}
|