Permalink
Browse files

Support trivia and youtubeinvite plugins.

  • Loading branch information...
1 parent bcc475c commit fe1460df4775860a173b6c2278acbfde19ef3daa @iopred committed May 29, 2016
View
@@ -22,14 +22,15 @@ import (
"github.com/iopred/bruxism/statsplugin"
"github.com/iopred/bruxism/streamerplugin"
"github.com/iopred/bruxism/topstreamersplugin"
+ "github.com/iopred/bruxism/triviaplugin"
+ "github.com/iopred/bruxism/youtubeinviteplugin"
)
var youtubeURL bool
var youtubeAuth string
var youtubeConfigFilename string
var youtubeTokenFilename string
var youtubeLiveVideoIDs string
-var youtubeLiveChatIDs string
var discordToken string
var discordEmail string
var discordPassword string
@@ -52,7 +53,6 @@ func init() {
flag.StringVar(&youtubeConfigFilename, "youtubeconfig", "youtubeoauth2config.json", "The filename that contains the oauth2 config.")
flag.StringVar(&youtubeTokenFilename, "youtubetoken", "youtubeoauth2token.json", "The filename to store the oauth2 token.")
flag.StringVar(&youtubeLiveVideoIDs, "youtubelivevideoids", "", "Comma separated list of video id's to poll.")
- flag.StringVar(&youtubeLiveChatIDs, "youtubelivechatids", "", "Comma separated list of chat id's to poll.")
flag.StringVar(&discordToken, "discordtoken", "", "Discord token.")
flag.StringVar(&discordEmail, "discordemail", "", "Discord account email.")
flag.StringVar(&discordPassword, "discordpassword", "", "Discord account password.")
@@ -91,14 +91,17 @@ func main() {
cp.AddCommand("numbertrivia", numbertriviaplugin.NumberTriviaCommand, numbertriviaplugin.NumberTriviaHelp)
}
- youtube := bruxism.NewYouTube(youtubeURL, youtubeAuth, youtubeConfigFilename, youtubeTokenFilename, youtubeLiveVideoIDs, youtubeLiveChatIDs)
+ ytip := youtubeinviteplugin.New()
+
+ youtube := bruxism.NewYouTube(youtubeURL, youtubeAuth, youtubeConfigFilename, youtubeTokenFilename, youtubeLiveVideoIDs)
bot.RegisterService(youtube)
bot.RegisterPlugin(youtube, cp)
bot.RegisterPlugin(youtube, slowmodeplugin.New())
bot.RegisterPlugin(youtube, topstreamersplugin.New(youtube))
bot.RegisterPlugin(youtube, streamerplugin.New(youtube))
bot.RegisterPlugin(youtube, reminderplugin.New())
+ bot.RegisterPlugin(youtube, triviaplugin.New())
// Register the Discord service if we have an email or token.
if (discordEmail != "" && discordPassword != "") || discordToken != "" {
@@ -124,6 +127,8 @@ func main() {
if carbonitexKey != "" {
bot.RegisterPlugin(discord, carbonitexplugin.New(carbonitexKey))
}
+ bot.RegisterPlugin(youtube, triviaplugin.New())
+ bot.RegisterPlugin(discord, ytip)
}
// Register the IRC service if we have an IRC server and Username.
@@ -135,6 +140,8 @@ func main() {
bot.RegisterPlugin(irc, topstreamersplugin.New(youtube))
bot.RegisterPlugin(irc, streamerplugin.New(youtube))
bot.RegisterPlugin(irc, reminderplugin.New())
+ bot.RegisterPlugin(youtube, triviaplugin.New())
+ bot.RegisterPlugin(irc, ytip)
}
if slackToken != "" {
@@ -145,6 +152,8 @@ func main() {
bot.RegisterPlugin(slack, cp)
bot.RegisterPlugin(slack, topstreamersplugin.New(youtube))
bot.RegisterPlugin(slack, streamerplugin.New(youtube))
+ bot.RegisterPlugin(youtube, triviaplugin.New())
+ bot.RegisterPlugin(slack, ytip)
}
// Start all our services.
View
@@ -63,6 +63,11 @@ func (p *helpPlugin) Help(bot *Bot, service Service, message Message, detailed b
func (p *helpPlugin) Message(bot *Bot, service Service, message Message) {
if !service.IsMe(message) {
if MatchesCommand(service, "help", message) || MatchesCommand(service, "command", message) {
+ if service.Name() == YouTubeServiceName {
+ service.SendMessage(message.Channel(), "Visit septapus dot com for help.")
+ return
+ }
+
_, parts := ParseCommand(service, message)
help := []string{}
@@ -26,7 +26,7 @@ func InviteHelp(bot *bruxism.Bot, service bruxism.Service, message bruxism.Messa
}
return "<discordinvite>", "Joins the provided Discord server."
case bruxism.YouTubeServiceName:
- return "<livechatid>", "Joins the provided YouTube chat by id (this may be hard to find)."
+ return "<videoid>", "Joins the provided YouTube live stream."
}
return "<channel>", "Joins the provided channel."
}
@@ -20,6 +20,7 @@ type liveChannel struct {
DiscordChannelID string
Live []string
Last time.Time
+ JoinSeptapus bool
}
type livePlugin struct {
@@ -73,6 +74,12 @@ func (p *livePlugin) pollChannel(bot *bruxism.Bot, service bruxism.Service, lc *
}
}
if !found {
+ if lc.JoinSeptapus {
+ ytservice := bot.Services[bruxism.YouTubeServiceName]
+ if ytservice != nil {
+ ytservice.Join(v)
+ }
+ }
if lc.Last.Add(6 * time.Hour).Before(time.Now()) {
lc.Last = time.Now()
@@ -128,6 +135,8 @@ func (p *livePlugin) Help(bot *bruxism.Bot, service bruxism.Service, message bru
return []string{
fmt.Sprintf("Announces when you go live in <#%s> as well as an optional channel.", livePluginChannelID),
bruxism.CommandHelp(service, "setyoutubechannel", "<youtube channel id>", "Sets your youtube channel id.")[0],
+ bruxism.CommandHelp(service, "setjoinseptapus", "", "Septapus will join your livestreams.")[0],
+ bruxism.CommandHelp(service, "unsetjoinseptapus", "", "Septapus will no longer join your livestreams.")[0],
bruxism.CommandHelp(service, "setdiscordchannel", "", fmt.Sprintf("%s will also announce you going live in this channel.", service.UserName()))[0],
bruxism.CommandHelp(service, "unsetdiscordchannel", "", "Disables additional live announcement of channel.")[0],
"Example:",
@@ -187,7 +196,23 @@ func (p *livePlugin) Message(bot *bruxism.Bot, service bruxism.Service, message
for _, lc := range p.Live {
if lc.UserID == message.UserID() {
lc.DiscordChannelID = ""
- service.SendMessage(messageChannel, fmt.Sprintf("Discord Channel ID unset. messages will not be sent hire when you go live."))
+ service.SendMessage(messageChannel, fmt.Sprintf("Discord Channel ID unset. Messages will not be sent hire when you go live."))
+ return
+ }
+ }
+ } else if bruxism.MatchesCommand(service, "setjoinseptapus", message) {
+ for _, lc := range p.Live {
+ if lc.UserID == message.UserID() {
+ lc.JoinSeptapus = true
+ service.SendMessage(messageChannel, fmt.Sprintf("Septapus will now join your livestreams."))
+ return
+ }
+ }
+ } else if bruxism.MatchesCommand(service, "unsetjoinseptapus", message) {
+ for _, lc := range p.Live {
+ if lc.UserID == message.UserID() {
+ lc.JoinSeptapus = false
+ service.SendMessage(messageChannel, fmt.Sprintf("Septapus will no longer join your livestreams."))
return
}
}
Oops, something went wrong.

0 comments on commit fe1460d

Please sign in to comment.