add video command body
This commit is contained in:
parent
9628bdfca3
commit
1c35860c17
@ -2,7 +2,6 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"math/rand"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,8 +28,7 @@ func GetRandomLotteryByType(t string) (p *Lottery, err error) {
|
|||||||
|
|
||||||
// GetRandomLotteryByTypeAndLimit -
|
// GetRandomLotteryByTypeAndLimit -
|
||||||
func GetRandomLotteryByTypeAndLimit(t string, limit int) (p []*Lottery, err error) {
|
func GetRandomLotteryByTypeAndLimit(t string, limit int) (p []*Lottery, err error) {
|
||||||
offset := rand.Intn(10)
|
err = x.Select(&p, `select * from "public"."lottery" where "type" = $1 offset floor(random() * (select count(*) as c from "public"."lottery" where "type" = $2)) limit $3`, t, t, limit)
|
||||||
err = x.Select(&p, `select * from "public"."lottery" where "type" = $1 order by random() offset $2 limit $3`, t, offset, limit)
|
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,8 @@ func selectAct(cmd, sub, txt string, s *lineobj.SourceObject) (res string) {
|
|||||||
return delTwitchChannel(sub, txt, s)
|
return delTwitchChannel(sub, txt, s)
|
||||||
case "image":
|
case "image":
|
||||||
return fmt.Sprintf("$image$%s", sub)
|
return fmt.Sprintf("$image$%s", sub)
|
||||||
|
case "video":
|
||||||
|
return fmt.Sprintf("$video$%s", sub)
|
||||||
case "addyoutube":
|
case "addyoutube":
|
||||||
return addYoutubeChannel(sub, txt, s)
|
return addYoutubeChannel(sub, txt, s)
|
||||||
case "delyoutube":
|
case "delyoutube":
|
||||||
|
@ -79,6 +79,13 @@ func parseResult(str string) interface{} {
|
|||||||
OriginalContentURL: strs[0],
|
OriginalContentURL: strs[0],
|
||||||
PreviewImageURL: strs[1],
|
PreviewImageURL: strs[1],
|
||||||
}
|
}
|
||||||
|
} else if strings.HasPrefix(str, "$video$") {
|
||||||
|
str = strings.Replace(str, "$video$", "", 1)
|
||||||
|
strs := strings.Split(str, ";")
|
||||||
|
m = &line.VideoMessage{
|
||||||
|
OriginalContentURL: strs[0],
|
||||||
|
PreviewImageURL: strs[1],
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m = &line.TextMessage{
|
m = &line.TextMessage{
|
||||||
Text: str,
|
Text: str,
|
||||||
|
Loading…
Reference in New Issue
Block a user