Skip to content

Commit

Permalink
Merge pull request #5 from eandersons/Language-option
Browse files Browse the repository at this point in the history
Language option
  • Loading branch information
kellya committed Mar 12, 2023
2 parents 8fb2e5e + 6e7fb5a commit c07a52c
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 106 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build
*.mbp
config.yaml
**__pycache
build
config.yaml
venv
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
[![build status](https://build.arachnitech.com/badges/maubot-weather.png)](https://build.arachnitech.com/#/builders/2) [![latest Release](https://img.shields.io/github/v/release/kellya/maubot-weather)](https://github.com/kellya/maubot-weather/releases) [![Latest in dev](https://img.shields.io/github/v/tag/kellya/maubot-weather?label=latest%20%28dev%29)](https://github.com/kellya/maubot-weather/tree/develop)

# weather

A simple [maubot](https://github.com/maubot/maubot) (which was based on the echobot) that gets the weather from [wttr.in](http://wttr.in) and returns the text to the chat

## Usage
* `!weather` - Reply with the weather based on the default config value
* `!weather <location>` - Reply with the location for the specified <location> where
<location> can be an airport code, or a city

* `!weather` - Reply with the weather based on the default config value; \
if the default location is not provided, it will be detected from IP address
by [wttr.in](https://wttr.in)
* `!weather <location>` - Reply with the location for the specified `<location>`
where `<location>` can be an airport code, or a city
* `!weather <location> u:[u|m|M]` - As above, but specify unit of measure (see
below)
* `!weather <location> l:[language code]` - current weather and forecast in the
specified language; \
available languages are listed on <https://wttr.in/:translation>
* `!moon` - Display lunar phase information

### Units

The unit is directly passed to the wttr.in, so the option specified must match
what wttr.in expects.

Valid units are as follows:

u - USCS (used by default in US)

m - metric (SI) (used by default everywhere except US)

M - metric (SI), but show wind speed in m/s
* `u` - USCS (used by default in US)
* `m` - metric (SI) (used by default everywhere except US)
* `M` - metric (SI), but show wind speed in m/s

(taken from https://github.com/chubin/wttr.in)


## Examples

### !weather
### `!weather`

Entering `!weather` in the chat will display the default server location setting
and display the single-line version of the weather from wttr.in.

![oneline](https://raw.githubusercontent.com/kellya/maubot-weather/develop/docs/images/weather_oneline.png)

If the `show_image` setting is `true` in the settings, the bot will return the
png image of the current weather with the forecast

![image_weather_oneline](https://raw.githubusercontent.com/kellya/maubot-weather/develop/docs/images/show_image_true.png)

### !moon
### `!moon`

Entering the `!moon` command in the chat will display a oneline version of the
lunar phase:

![image_moon](https://raw.githubusercontent.com/kellya/maubot-weather/develop/docs/images/moon.png)


## Installation

1. Download the current `com.arachnitech.weather-vX.Y.Z.mbp` file from the
Expand All @@ -70,6 +76,7 @@ If you would like to mess with the source code to add your own stuff, or clean
up some python atrocity I have committed, please clone/fork this repo and have at it.

I have built everything using poetry, so the easiest path is:

1. clone/fork the repo
2. run `poetry shell`
3. run `poetry install` to add all the dependent packages
Expand Down
18 changes: 12 additions & 6 deletions base-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# Specify a location to use when just !weather is used
default_location: Columbus, Oh
# If the location is not specified, it will be detected by wttr.in from the IP
# address.
default_location:

# default units to use. This is directly passed to wttr.in, so it must be one of:
# Default units to use. This is directly passed to wttr.in, so it must be one of:
# m - metric (SI)
# u - US units (USCS)
# M - metric (SI), but wind in m/s
# blank will automatically determin units based on source IP
# M - metric (SI), but wind speed unit is m/s
# Blank will automatically determine units based on source IP
default_units:

# show a link to the wttr.in page
# The default language to use for weather reports.
# Available languages are listed here: https://wttr.in/:translation
default_language:

# Show a link to the wttr.in page
show_link: false

# display the image of the forecast
# Display the image of the forecast
show_image: false
2 changes: 1 addition & 1 deletion maubot.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
maubot: 0.1.0
id: com.arachnitech.weather
version: "0.3.1"
version: "0.4.0"
license: MIT
modules:
- weather
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "maubot-weather"
version = "0.3.1"
version = "0.4.0"
description = "A maubot bot to get the weather from wttr.in and post to a matrix channel"
authors = ["Alex Kelly <[email protected]>"]
license = "MIT"
Expand Down
Loading

0 comments on commit c07a52c

Please sign in to comment.