update code
This commit is contained in:
parent
fd3bd2679e
commit
4f0b650ac2
@ -111,8 +111,11 @@ func (p *ChannelModel) SetNotifyState(state bool) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetFacebookPageList -
|
// GetFacebookPageList -
|
||||||
func (p *ChannelModel) GetFacebookPageList() (pages *pubmodel.FacebookPageModel, err error) {
|
func (p *ChannelModel) GetFacebookPageList() (pages []*pubmodel.FacebookPageModel, err error) {
|
||||||
db := models.GetConn()
|
return pubmodel.GetFacebookPageListByChannel(p.ID)
|
||||||
_ = db
|
}
|
||||||
return
|
|
||||||
|
// GetFacebookPageByID -
|
||||||
|
func (p *ChannelModel) GetFacebookPageByID(id string) (page *pubmodel.FacebookPageModel, err error) {
|
||||||
|
return pubmodel.GetFacebookPageByChannelAndID(id, p.ID)
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,35 @@ func GetFacebookPageByID(id string) (page *FacebookPageModel, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFacebookPageListByChannel -
|
||||||
|
func GetFacebookPageListByChannel(channel string) (pages []*FacebookPageModel, err error) {
|
||||||
|
if len(channel) == 0 {
|
||||||
|
return nil, errors.New("channel is empty")
|
||||||
|
}
|
||||||
|
db := models.GetConn()
|
||||||
|
query := `select id, lastpost, ctime, mtime from public.facebook_page where channel = $1`
|
||||||
|
err = db.Select(&pages, query, channel)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFacebookPageByChannelAndID -
|
||||||
|
func GetFacebookPageByChannelAndID(id, channel string) (page *FacebookPageModel, err error) {
|
||||||
|
if len(channel) == 0 || len(id) == 0 {
|
||||||
|
return nil, errors.New("channel or id is empty")
|
||||||
|
}
|
||||||
|
db := models.GetConn()
|
||||||
|
page = &FacebookPageModel{}
|
||||||
|
query := `select id, lastpost, ctime, mtime from public.facebook_page where id = $1 and channel = $2`
|
||||||
|
err = db.Get(page, query, channel)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// GetAllFacebookPage -
|
// GetAllFacebookPage -
|
||||||
func GetAllFacebookPage() (pages []*FacebookPageModel, err error) {
|
func GetAllFacebookPage() (pages []*FacebookPageModel, err error) {
|
||||||
db := models.GetConn()
|
db := models.GetConn()
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func addServer(info EvtInfo, name string) string {
|
func addServer(info EvtInfo, name string) string {
|
||||||
exists, err := dsmodel.GetDiscordServerByID(info.Server)
|
exists, err := dsmodel.GetServerByID(info.Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("check server exists fail :: ", err)
|
log.Println("check server exists fail :: ", err)
|
||||||
return "check server info fail"
|
return "check server info fail"
|
||||||
@ -15,7 +15,7 @@ func addServer(info EvtInfo, name string) string {
|
|||||||
return "server already setup"
|
return "server already setup"
|
||||||
}
|
}
|
||||||
|
|
||||||
ds, err := dsmodel.NewDiscordServer(info.Server, name, 0)
|
ds, err := dsmodel.NewServer(info.Server, name, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("create dsmodel fail :: ", err)
|
log.Println("create dsmodel fail :: ", err)
|
||||||
return "create server data fail"
|
return "create server data fail"
|
||||||
|
@ -32,7 +32,7 @@ func messageCreateEvt(s *discordgo.Session, evt *discordgo.MessageCreate) {
|
|||||||
_ = channelID
|
_ = channelID
|
||||||
_ = uid
|
_ = uid
|
||||||
|
|
||||||
server, err := dsmodel.GetDiscordServerByID(guildID)
|
server, err := dsmodel.GetServerByID(guildID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("get server err :: ", err)
|
log.Println("get server err :: ", err)
|
||||||
return
|
return
|
||||||
|
@ -49,7 +49,7 @@ func getCMD(str string) (cmd string, keyword bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRegServerCommandAction(s *discordgo.Session, msgEvt *discordgo.MessageCreate, server *dsmodel.DiscordServerModel, cmd string) (c *pubmodel.CommandModel, acts []*cmdparser.CmdAction, err error) {
|
func getRegServerCommandAction(s *discordgo.Session, msgEvt *discordgo.MessageCreate, server *dsmodel.ServerModel, cmd string) (c *pubmodel.CommandModel, acts []*cmdparser.CmdAction, err error) {
|
||||||
cmds, err := pubmodel.GetCommandByPlatformBinding(cmd, server.ID, "discord")
|
cmds, err := pubmodel.GetCommandByPlatformBinding(cmd, server.ID, "discord")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("get command err :: ", err)
|
log.Println("get command err :: ", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user