Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
Fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JustHumanz committed Mar 22, 2021
1 parent b4457e1 commit 0861a77
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v3.3.2
- Fix Youtube upcoming/live/past command
- Fix Bilibili fanart nill pointer
- Add twitch embed inline

v3.3.1
- Add pixiv as fanart
- Rebase fanart & livestream struct
Expand Down
2 changes: 1 addition & 1 deletion pkg/database/bilidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func BilGet(GroupID int64, MemberID int64, Status string) []LiveStream {
Limit = 2525
}

rows, err := DB.Query(`SELECT * FROM Vtuber.LiveBiliBili Inner join Vtuber.VtuberMember on VtuberMember.id=VtuberMember_id Inner join Vtuber.VtuberGroup on VtuberGroup.id = VtuberGroup_id Where (VtuberGroup.id=? or VtuberMember.id=?) AND Status=? Order by ScheduledStart DESC Limit ?`, GroupID, MemberID, Status, Limit)
rows, err := DB.Query(`SELECT LiveBiliBili.* FROM Vtuber.LiveBiliBili Inner join Vtuber.VtuberMember on VtuberMember.id=VtuberMember_id Inner join Vtuber.VtuberGroup on VtuberGroup.id = VtuberGroup_id Where (VtuberGroup.id=? or VtuberMember.id=?) AND Status=? Order by ScheduledStart ASC Limit ?`, GroupID, MemberID, Status, Limit)
if err != nil {
log.Error(err)
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/database/ytdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ func YtGetStatus(Group, Member int64, Status, Region string) ([]LiveStream, erro
}
defer rows.Close()

} else if Status == "past" {
rows, err = DB.Query(`SELECT Youtube.* FROM Vtuber.Youtube Inner join Vtuber.VtuberMember on VtuberMember.id=VtuberMember_id Inner join Vtuber.VtuberGroup on VtuberGroup.id = VtuberGroup_id Where (VtuberGroup.id=? or VtuberMember.id=?) AND Status=? Order by EndStream DESC Limit ?`, Group, Member, Status, limit)
if err != nil {
return nil, err
} else if err == sql.ErrNoRows {
return nil, errors.New("Not found any schdule")
}
defer rows.Close()
} else {
rows, err = DB.Query(`SELECT Youtube.* FROM Vtuber.Youtube Inner join Vtuber.VtuberMember on VtuberMember.id=VtuberMember_id Inner join Vtuber.VtuberGroup on VtuberGroup.id = VtuberGroup_id Where (VtuberGroup.id=? or VtuberMember.id=?) AND Status=? Order by ScheduledStart DESC Limit ?`, Group, Member, Status, limit)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion service/fanart/bilibili/bilibili.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func Start(a *discordgo.Session, b *cron.Cron, c database.VtubersPayload, d conf
log.Error(err)
}
if STB.Item.Pictures != nil && v.Desc.Type == 2 { //type 2 is picture post (prob,heheheh)
for _, pic := range STB.Item.Pictures {
img = append(img, pic.ImgSrc)
}

TBiliData := database.DataFanart{
PermanentURL: "https://t.bilibili.com/" + v.Desc.DynamicIDStr + "?tab=2",
Author: v.Desc.UserProfile.Info.Uname,
Expand Down Expand Up @@ -108,7 +112,6 @@ func Start(a *discordgo.Session, b *cron.Cron, c database.VtubersPayload, d conf
SetDescription(TBiliData.Text).
SetImage(TBiliData.Photos[0]).
AddField("User Tags", tags).
//AddField("Similar art", msg).
SetFooter("1/"+strconv.Itoa(len(TBiliData.Photos))+" photos", config.BiliBiliIMG).
InlineAllFields().
SetColor(Color).MessageEmbed)
Expand Down
2 changes: 1 addition & 1 deletion service/frontend/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func Module(s *discordgo.Session, m *discordgo.MessageCreate) {

//FindName Find a valid Vtuber name from message handler
func FindVtuber(MemberName string, ID int64) database.Member {
if ID == 0 {
if ID != 0 {
for _, Group := range Payload.VtuberData {
for _, Name := range Group.Members {
if Name.ID == ID {
Expand Down
2 changes: 1 addition & 1 deletion service/frontend/youtube_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func YoutubeMessage(s *discordgo.Session, m *discordgo.MessageCreate) {
SetTitle(FixName).
SetThumbnail(Youtube.Thumb).
SetDescription(Youtube.Title).
SetImage(Youtube.Thumb).
SetImage(Youtube.Member.YoutubeAvatar).
SetURL("https://www.youtube.com/watch?v="+Youtube.VideoID).
AddField("Live duration", durationlive.String()).
AddField("Live ended", duration.String()+" Ago").
Expand Down
1 change: 1 addition & 0 deletions service/livestream/twitch/notif.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func SendNotif(Data database.LiveStream) error {
SetURL(ImgURL).
AddField("Start live", durafmt.Parse(expiresAt.Sub(Data.Schedul.In(loc))).LimitFirstN(1).String()+" Ago").
AddField("Viewers", engine.NearestThousandFormat(float64(View))+" "+FanBase).
InlineAllFields().
AddField("Game", Data.Game).
SetFooter(Data.Schedul.In(loc).Format(time.RFC822), config.TwitchIMG).
SetColor(Color).MessageEmbed)
Expand Down

0 comments on commit 0861a77

Please sign in to comment.