Copyright | (c) Henry J. Wylde, 2016 |
---|---|
License | BSD3 |
Maintainer | public@hjwylde.com |
Safe Haskell | None |
Language | Haskell2010 |
A response is used as a return result of calling the werewolf
binary. Each response has a list of
associated messages.
werewolf
was designed to be ambivalent to the playing chat client. The response-message structure
reflects this by staying away from anything that could be construed as client-specific. This
includes features such as emoji support.
Response
When a user sends a command to the werewolf
binary, a response is always returned.
The chat interface should then relay any messages
from the response. Whether or not the
command was valid (indicated by the ok
flag) is often irrelevant as the returned messages
will include errors to the user.
Common responses
Exit functions
exitWith :: MonadIO m => Response -> m a Source
Exits fast with the given response. The response is encoded as JSON, printed to stdout
and
then the program is exited with 0
(success).
The program always exits with success even if the response was a failure one. This is to distinguish between bad calls to the binary and bad commands to the werewolf engine.
Message
A message may be either public or private, indicated by it's to
field.
Each message contains a single text field. This field is permitted to contain special characters such as new lines and tabs.
publicMessage :: Text -> Message Source
Creates a public message with the given text.
privateMessage :: Text -> Text -> Message Source
privateMessage to message
Creates a private message to to
with the given text.
groupMessages :: [Text] -> Text -> [Message] Source
groupMessages tos message
Creates multiple private messages (1 to each recipient) with the given text.