{"id":19307773,"url":"https://github.com/sger/weather-bot","last_synced_at":"2025-10-26T11:34:11.147Z","repository":{"id":64299541,"uuid":"48317384","full_name":"sger/weather-bot","owner":"sger","description":"Weather bot in Golang","archived":false,"fork":false,"pushed_at":"2015-12-20T15:53:11.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-06T01:23:13.982Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-20T11:18:06.000Z","updated_at":"2015-12-22T08:21:25.000Z","dependencies_parsed_at":"2023-01-15T09:15:30.753Z","dependency_job_id":null,"html_url":"https://github.com/sger/weather-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sger%2Fweather-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sger%2Fweather-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sger%2Fweather-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sger%2Fweather-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sger","download_url":"https://codeload.github.com/sger/weather-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240409583,"owners_count":19796793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T00:12:29.359Z","updated_at":"2025-10-26T11:34:11.065Z","avatar_url":"https://github.com/sger.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Weather bot\n\nFirst create a new bot in Slack more info here [https://api.slack.com/bot-users](https://api.slack.com/bot-users)\n\nUsage:\n\ncreate a go file with name test_wb.go\n\n```\npackage main\n\nimport (\n\t\"fmt\"\n\twb \"github.com/sger/weather-bot\"\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n)\n\nfunc main() {\n\n\tif len(os.Args) != 2 {\n\t\tfmt.Fprintf(os.Stderr, \"usage: weather-bot token\\n\")\n\t\tos.Exit(1)\n\t}\n\n\tws, r, err := wb.Connect(os.Args[1])\n\tfmt.Println(\"bot is running, hit ^C to exit\")\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor {\n\t\tm, err := wb.GetMessage(ws)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tif m.Type == \"message\" \u0026\u0026 strings.HasPrefix(m.Text, \"\u003c@\"+r.Self.Id+\"\u003e\") {\n\t\t\tfields := strings.Fields(m.Text)\n\t\t\tif len(fields) == 2 {\n\t\t\t\tgo func(m wb.Message) {\n\t\t\t\t\tm.Text = getWeather(fields[1])\n\t\t\t\t\tm.Text += \"\\nThank you \" + \"\u003c@\" + m.User + \"\u003e\" + \"\\n\"\n\t\t\t\t\twb.PostMessage(ws, m)\n\t\t\t\t}(m)\n\t\t\t} else {\n\t\t\t\tgo func(m wb.Message) {\n\t\t\t\t\tm.Text = \"sorry wrong usage please write @name-of-the-weather-bot: Athens\"\n\t\t\t\t\twb.PostMessage(ws, m)\n\t\t\t\t}(m)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc getWeather(city string) string {\n\tf, err := wb.Search(city)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn fmt.Sprintf(\"Temperature for today\\n Kelvin: %.2fK | Celsius: %.2f°C | Fahrenheit: %.2f°F\", f.Info.Temp, f.Info.Temp-273.15, f.Info.Temp*9/5-459.67)\n}\n```\n\nand run it with\n```\n$ go build test_wb.go\n$ ./test_wb my-bot-token\n```\nopen up your slack client and send a message to you bot myBot: london press enter to see the reply\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsger%2Fweather-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsger%2Fweather-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsger%2Fweather-bot/lists"}