Johannes Löthberg 27e7d6a9ac Aka: Add web UI (#1373)
* utils.web: Import html escaping functions

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* Aka: Add web interface for browsing Akas

Fixes #1226.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* httpserver: Actually handle KeyError in unhook

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* test: FakeHTTPConnection: Don't decode data in send

BaseHTTPRequestHandler expects to get bytes, so we can't decode the sent
data.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* test: HTTPPluginTestCase: Use BytesIO instead of StringIO

BaseHTTPRequestHandler expects bytes, not strings.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* test: HTTPPluginTestCase: Rewind wfile to 0 before reading the response

Otherwise the read pointer is at the end of the file.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>

* Aka: Add basic web UI tests

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2019-10-10 17:27:34 +02:00
..
2013-07-23 21:02:06 +02:00
2016-01-27 14:04:58 +01:00
2019-10-10 17:27:34 +02:00
2014-12-20 14:37:27 +01:00
2019-10-10 17:27:34 +02:00
2019-10-10 17:27:34 +02:00

This plugin allows the user to create various aliases (known as "Akas", 
since Alias is the name of another plugin Aka is based on) to other 
commands or combinations of other commands (via nested commands).  
It is a good idea to always quote the commands that are being aliased so 
that any nested commands are not immediately run.

Basic usage
-----------

### Alias

Add an aka, Alias, which eases the transitioning to Aka from Alias.

First we will load Alias and Aka.

```
<jamessan> @load Alias
<bot> jamessan: The operation succeeded.
<jamessan> @load Aka
<bot> jamessan: The operation succeeded.

```

Then we import the Alias database to Aka in case it exists and unload 
Alias.

```
<jamessan> @importaliasdatabase
<bot> jamessan: The operation succeeded.
<jamessan> @unload Alias
<bot> jamessan: The operation succeeded.
```

And now we will finally add the Aka `alias` itself.

```
<jamessan> @aka add "alias" "aka $1 $*"
<bot> jamessan: The operation succeeded.
```

Now you can use Aka as you used Alias before.

### Trout

Add an aka, trout, which expects a word as an argument

```
<jamessan> @aka add trout "reply action slaps $1 with a large trout"
<bot> jamessan: The operation succeeded.
<jamessan> @trout me
* bot slaps me with a large trout
```

This `trout` aka requires the plugin `Reply` to be loaded since it 
provides the `action` command.

### LastFM

Add an aka, `lastfm`, which expects a last.fm username and replies with 
their most recently played item.

```
@aka add lastfm "rss [format concat http://ws.audioscrobbler.com/1.0/user/ [format concat [web urlquote $1] /recenttracks.rss]]"
```

This `lastfm` aka requires the following plugins to be loaded: `RSS`, 
`Format` and `Web`.

`RSS` provides `rss`, `Format` provides `concat` and `Web` provides 
`urlquote`.

Note that if the nested commands being aliased hadn't been quoted, then
those commands would have been run immediately, and `@lastfm` would always
reply with the same information, the result of those commands.