Skip to content

Commit

Permalink
Add youtube command
Browse files Browse the repository at this point in the history
  • Loading branch information
godwhoa committed Apr 14, 2019
1 parent d638442 commit 1fb1445
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/godwhoa/oodle/oodle"
"github.com/godwhoa/oodle/plugins/core"
"github.com/godwhoa/oodle/plugins/hackterm"
"github.com/godwhoa/oodle/plugins/lazy"
"github.com/godwhoa/oodle/plugins/oodnet"
"github.com/godwhoa/oodle/plugins/sed"
"github.com/godwhoa/oodle/plugins/urban"
Expand Down Expand Up @@ -77,6 +78,7 @@ func main() {
sed.Register(deps),
webhook.Register(deps),
oodnet.Register(deps),
lazy.Register(deps),
); err != nil {
logger.Fatal(err)
}
Expand Down
29 changes: 29 additions & 0 deletions plugins/lazy/youtube.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package lazy

import (
"net/url"
"strings"

m "github.com/godwhoa/oodle/middleware"
"github.com/godwhoa/oodle/oodle"
)

func Register(deps *oodle.Deps) error {
bot := deps.Bot
bot.RegisterCommands(YoutubeSearch())
return nil
}

func YoutubeSearch() oodle.Command {
cmd := oodle.Command{
Prefix: ".",
Name: "youtube",
Description: "Gives you a search url. That's it.",
Usage: ".youtube <query>",
Fn: func(nick string, args []string) (reply string, err error) {
word := strings.Join(args, " ")
return "https://www.youtube.com/results?search_query=" + url.PathEscape(word), nil
},
}
return m.Chain(cmd, m.MinArg(1))
}

0 comments on commit 1fb1445

Please sign in to comment.