From a15ddcf9853ff201ac0ed9714152929101a67d1f Mon Sep 17 00:00:00 2001 From: chaoqun <27287694+OpenWaygate@users.noreply.github.com> Date: Sat, 31 Aug 2024 22:25:08 +0800 Subject: [PATCH] :sparkles: Support list super chat event --- cmd/superChatEvent/list.go | 32 ++++++++++++++++++++++++++++ cmd/superChatEvent/superChatEvent.go | 26 ++++++++++++++++++++++ main.go | 1 + 3 files changed, 59 insertions(+) create mode 100644 cmd/superChatEvent/list.go create mode 100644 cmd/superChatEvent/superChatEvent.go diff --git a/cmd/superChatEvent/list.go b/cmd/superChatEvent/list.go new file mode 100644 index 0000000..a15b8db --- /dev/null +++ b/cmd/superChatEvent/list.go @@ -0,0 +1,32 @@ +package superChatEvent + +import ( + "github.com/eat-pray-ai/yutu/pkg/superChatEvent" + "github.com/spf13/cobra" +) + +var listCmd = &cobra.Command{ + Use: "list", + Short: "List Super Chat events for a channel", + Long: "List Super Chat events for a channel", + Run: func(cmd *cobra.Command, args []string) { + sc := superChatEvent.NewSuperChatEvent( + superChatEvent.WithHl(hl), + superChatEvent.WithMaxResults(maxResults), + ) + sc.List(parts, output) + }, +} + +func init() { + superChatEventCmd.AddCommand(listCmd) + + listCmd.Flags().StringVarP( + &hl, "hl", "l", "", "Return rendered funding amounts in specified language", + ) + listCmd.Flags().Int64VarP( + &maxResults, "maxResults", "n", 5, "The maximum number of items that should be returned", + ) + listCmd.Flags().StringSliceVarP(&parts, "parts", "p", []string{"id", "snippet"}, "Comma separated parts") + listCmd.Flags().StringVarP(&output, "output", "o", "", "json or yaml") +} diff --git a/cmd/superChatEvent/superChatEvent.go b/cmd/superChatEvent/superChatEvent.go new file mode 100644 index 0000000..357d4b7 --- /dev/null +++ b/cmd/superChatEvent/superChatEvent.go @@ -0,0 +1,26 @@ +package superChatEvent + +import ( + "github.com/eat-pray-ai/yutu/cmd" + "github.com/spf13/cobra" +) + +var ( + hl string + maxResults int64 + parts []string + output string +) + +var superChatEventCmd = &cobra.Command{ + Use: "superChatEvent", + Short: "List Super Chat events for a channel", + Long: "List Super Chat events for a channel", + Run: func(cmd *cobra.Command, args []string) { + cmd.Help() + }, +} + +func init() { + cmd.RootCmd.AddCommand(superChatEventCmd) +} diff --git a/main.go b/main.go index e252405..83beed0 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( _ "github.com/eat-pray-ai/yutu/cmd/playlistItem" _ "github.com/eat-pray-ai/yutu/cmd/search" _ "github.com/eat-pray-ai/yutu/cmd/subscription" + _ "github.com/eat-pray-ai/yutu/cmd/superChatEvent" _ "github.com/eat-pray-ai/yutu/cmd/thumbnail" _ "github.com/eat-pray-ai/yutu/cmd/video" _ "github.com/eat-pray-ai/yutu/cmd/videoAbuseReportReason"