Skip to content

Commit

Permalink
Add screenshot command for oodnet
Browse files Browse the repository at this point in the history
  • Loading branch information
godwhoa committed Apr 12, 2019
1 parent e2bac53 commit 4cfe1c5
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion plugins/oodnet/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Register(deps *oodle.Deps) error {
if key == "" {
return nil
}
bot.RegisterCommands(Submit(checker, key))
bot.RegisterCommands(Submit(checker, key), Screenshot(checker, key))
return nil
}

Expand Down Expand Up @@ -47,3 +47,31 @@ func Submit(checker oodle.Checker, key string) oodle.Command {
}
return m.Chain(cmd, m.MinArg(2), m.RegisteredOnly(checker))
}

func Screenshot(checker oodle.Checker, key string) oodle.Command {
cmd := oodle.Command{
Prefix: ".",
Name: "screenshot",
Description: "IDK, ask exezin.",
Usage: ".screenshot <desc> <url>",
Fn: func(nick string, args []string) (string, error) {
desc := strings.Join(args[:len(args)-1], " ")
rawurl := args[len(args)-1]

if _, err := url.ParseRequestURI(rawurl); err != nil {
return "Last arg. isn't an url", nil
}
form := url.Values{}
form.Set("url", rawurl)
form.Set("username", nick)
form.Set("text", desc)
form.Set("password", key)
_, err := u.HTTPClient.PostForm("https://oods.net/screenshot-submit", form)
if err != nil {
return "Failed to submit: " + err.Error(), nil
}
return "Submitted!", nil
},
}
return m.Chain(cmd, m.MinArg(2), m.RegisteredOnly(checker))
}

0 comments on commit 4cfe1c5

Please sign in to comment.