Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &commands.YAGCommand{ CmdCategory: commands.CategoryFun, Name: "Weather", Aliases: []string{"w"}, Description: "Shows the weather somewhere (add ?m for metric: -w bergen?m)", RunInDM: true, RequiredArgs: 1, Arguments: []*dcmd.ArgDef{ &dcmd.ArgDef{Name: "Where", Type: dcmd.String}, }, RunFunc: func(data *dcmd.Data) (interface{}, error) { where := data.Args[0].Str() req, err := http.NewRequest("GET", "http://wttr.in/"+where, nil) if err != nil { return err, err } req.Header.Set("User-Agent", "curl/7.49.1") resp, err := http.DefaultClient.Do(req) if err != nil { return err, err } body, err := ioutil.ReadAll(resp.Body) if err != nil { return err, err } unescaped := vtclean.Clean(string(body), false) split := strings.Split(string(unescaped), "\n") out := "```\n" for i := 0; i < 7; i++ { if i >= len(split) { break } out += strings.TrimRight(split[i], " ") + "\n" } out += "\n```" return out, nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.