add line message command , not fin
This commit is contained in:
@@ -26,6 +26,22 @@ func GetAllFacebookPage() (pages []*FacebookPage, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetFacebookPage -
|
||||
func GetFacebookPage(id string) (page *FacebookPage, err error) {
|
||||
err = x.Get(&page, `select * from "public"."facebook_page" where "id" = $1`, id)
|
||||
return
|
||||
}
|
||||
|
||||
// AddPage -
|
||||
func (p *FacebookPage) AddPage() (err error) {
|
||||
rows, err := x.NamedQuery(`insert into "public"."facebook_page" ("id", "lastpost") values (:id, :lastpost) returning *`, p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = rows.StructScan(&p)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePost -
|
||||
func (p *FacebookPage) UpdatePost(postID string) (err error) {
|
||||
query := `update "public"."facebook_page" set "lastpost" = $1 where id = $2`
|
||||
|
||||
@@ -15,8 +15,8 @@ type KeyCommands struct {
|
||||
Mtime time.Time `db:"mtime" cc:"ctime"`
|
||||
}
|
||||
|
||||
// GetKeyCommand -
|
||||
func GetKeyCommand(c, g string) (cmd *KeyCommands, err error) {
|
||||
// GetGroupKeyCommand -
|
||||
func GetGroupKeyCommand(c, g string) (cmd *KeyCommands, err error) {
|
||||
if len(c) == 0 {
|
||||
return nil, errors.New("command is empty")
|
||||
}
|
||||
|
||||
@@ -24,3 +24,37 @@ func CheckGroup(g string) (exists bool, err error) {
|
||||
}
|
||||
return ss.C > 0, nil
|
||||
}
|
||||
|
||||
// CheckGroupOwner -
|
||||
func CheckGroupOwner(user, g string) (exists bool, err error) {
|
||||
ss := struct {
|
||||
C int `db:"c"`
|
||||
}{}
|
||||
|
||||
err = x.Get(&ss, `select count(*) as c from "public"."line_group" where "id" = $1 and "owner" = $2`, g, user)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return ss.C > 0, nil
|
||||
}
|
||||
|
||||
// GetLineGroup -
|
||||
func GetLineGroup(id string) (g *LineGroup, err error) {
|
||||
err = x.Get(&g, `select * from "public"."line_group" where "id" = $1`, id)
|
||||
return
|
||||
}
|
||||
|
||||
// AddLineGroup -
|
||||
func AddLineGroup(name, owner string, notify bool) (g *LineGroup, err error) {
|
||||
err = x.Get(&g, `insert into "public"."line_group" ("name", "owner", "notify") values ($1, $2, $3)`, name, owner, notify)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteGroup -
|
||||
func (p *LineGroup) DeleteGroup() (err error) {
|
||||
_, err = x.Exec(`delete from "public"."line_group" where "id" = $1`, p.ID)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -18,3 +18,21 @@ type LineYoutubeRT struct {
|
||||
Youtube string `db:"youtube" cc:"youtube"`
|
||||
Tmpl string `db:"tmpl" cc:"tmpl"`
|
||||
}
|
||||
|
||||
// AddRT - add facebook line rt
|
||||
func (p *LineFacebookRT) AddRT() (err error) {
|
||||
_, err = x.NamedExec(`insert into "public"."line_fb_rt" ("line", "facebook", "tmpl") values (:line, :facebook, :tmpl)`, p)
|
||||
return
|
||||
}
|
||||
|
||||
// AddRT - add twitch line rt
|
||||
func (p *LineTwitchRT) AddRT() (err error) {
|
||||
_, err = x.NamedExec(`insert into "public"."line_twitch_rt" ("line", "twitch", "type", "tmpl") values (:line, :twitch, :type, :tmpl)`, p)
|
||||
return
|
||||
}
|
||||
|
||||
// AddRT - add youtube line rt
|
||||
func (p *LineYoutubeRT) AddRT() (err error) {
|
||||
_, err = x.NamedExec(`insert into "public"."line_youtube_rt" ("line", "youtube", "tmpl") values (:line, :youtube, :tmpl)`, p)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -32,6 +32,16 @@ func GetJoinChatChannel() (channels []*TwitchChannel, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Add -
|
||||
func (p *TwitchChannel) Add() (err error) {
|
||||
rows, err := x.NamedQuery(`insert into "public"."twitch_channel" ("name", "laststream", "join", "opayid") values (:name, :laststream, :join, :opayid) returning *`, p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = rows.StructScan(p)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateStream -
|
||||
func (p *TwitchChannel) UpdateStream(streamID string) (err error) {
|
||||
query := `update "public"."twitch_channel" set "laststream" = $1 where "id" = $2`
|
||||
|
||||
Reference in New Issue
Block a user