Commit Graph

221 Commits

Author SHA1 Message Date
projectmoon d42e075c5c Update dependencies.
continuous-integration/drone/push Build is passing Details
2021-02-07 21:58:22 +00:00
projectmoon b0707dff05 bot: Move multi-failure response join() call into the format!().
continuous-integration/drone/push Build is passing Details
2021-02-07 21:42:32 +00:00
projectmoon 304c91c69d Rename CommandResult to ExecutionResult
continuous-integration/drone/push Build is passing Details
2021-02-07 21:39:21 +00:00
projectmoon 94be4d2578 Avoid key clone when deleting variables. Minor db code cleanup.
continuous-integration/drone/push Build is passing Details
2021-02-07 21:16:58 +00:00
projectmoon 14f8bc8b39 Reuse device ID generated by matrix SDK after first login.
continuous-integration/drone/push Build is passing Details
Adds new db tree for simple global state values (which also lays
foundation for other stuff), and stores device ID in that tree after
first login. The ID is then reused on subsequent runs of the
application.

This is simpler than storing device ID in config file.

Fixes #9.
2021-02-07 14:21:28 +00:00
projectmoon 7db639f16c Update cargo.lock for 0.9.0 2021-02-07 14:21:21 +00:00
projectmoon b3cd7266e4 Version 0.9.0. Bug fix release.
continuous-integration/drone/push Build is passing Details
- Properly reject large numbers outside bounds of i32 when rolling dice.
 - Avoid unnecessary clone of error message when calculating dice amounts.
 - Allow up to 50 commands to be executed per message.
 - Show failed commands with errors when executing multiple commands.
 - Properly format dice plurality when rolling CofD dice pools.
 - Use 'username pills' instead of raw user ID in response messages.
 - Update matrix SDK to latest.
 - General code reorganization for better maintainability.
2021-02-04 19:37:22 +00:00
projectmoon 12b7d355d2 Docker image is 'tiny', not 'glibc-tiny'. Update to 0.8.0.
continuous-integration/drone/push Build is passing Details
2021-02-04 18:56:15 +00:00
projectmoon 3c177dc304 Always point to glibc-tiny, not glibc.
continuous-integration/drone/push Build is failing Details
2021-02-03 23:33:59 +00:00
projectmoon f6099c657e Always point to glibc image for Docker build.
continuous-integration/drone/push Build is passing Details
2021-02-03 23:32:45 +00:00
projectmoon 932e06ad91 Fix database error name. Improve dice number conversion error message.
continuous-integration/drone/push Build is passing Details
2021-02-03 23:27:47 +00:00
projectmoon b7ccd4e7ad Refactor dice amount parser to reusable parsers.
This follows the example in the Combine documentation to use impl
trait return types so we can isolate the parsers into their own
functions.
2021-02-03 23:27:14 +00:00
projectmoon b32b761f82 Update combine and dependencies. 2021-02-03 23:23:15 +00:00
projectmoon 9a5a18268c Parsing huge numbers are now errors, not variables.
Fixed the dice amount parsing code to propagate a parsing result
through the parser, while properly handling string to i32 conversion.
We now only attempt to convert to i32 if all characters in the
expression are numeric.

This commit also refactors the dice parsing by moving most of the
parsing closures into separate functions, which makes the parsing
function itself more readable. Some variable names were also changed,
for further clarity.

Fixes #21.
2021-02-03 23:23:03 +00:00
projectmoon f5a8e16ce0 Slight refactor of calculate_dice_amount. Lazy error handling.
continuous-integration/drone/push Build is passing Details
Use unwrap_or_else instead of unwrap_or to prevent unnecessary error
string creation. Also some changes to make the code a bit more
readable.
2021-02-02 22:02:43 +00:00
projectmoon 7512ca0694 Allow up to 50 commands per message.
continuous-integration/drone/push Build is passing Details
If the amount of commands in a single message is greater, the bot will
now return an error. Includes slight refactoring of command execution
code to make use of streams for async iter-like mapping of the command
list.

Fixes #24.
2021-02-02 21:45:59 +00:00
projectmoon 3faca6a2df Update dependencies.
continuous-integration/drone/push Build is passing Details
2021-02-02 20:21:31 +00:00
projectmoon 042ecc40e0 Properly format dice plurality in CofD dice pools.
continuous-integration/drone/push Build is passing Details
Fixes #30.
2021-01-31 14:57:18 +00:00
projectmoon df54e6555a Use 'username bubbles' in responses instead of straight user ID.
continuous-integration/drone/push Build is passing Details
2021-01-31 14:46:53 +00:00
projectmoon b3c4d8a38c Centralize plain text formatting at point of message sending.
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
Instead of relying on all parts of the application to construct both
HTML and plain-text responses, we now construct only HTML responses,
and convert the HTML to plain text right before sending the message to
Matrix.

This is a first iteration, because the plain text has a few extra
newlines than it should, created by use of nested <p> tags.
2021-01-31 14:12:09 +00:00
projectmoon a4e66a0ca6 Basic output for multiple command failures.
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is passing Details
Also replace newlines with <br/>s in HTML output.
2021-01-31 08:15:22 +00:00
projectmoon d0c6ca3de8 Print out how many commands failed in a multi-command scenario.
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
The number of failing commands are now printed out when at least one
command in a multi-command execution fails. This commit does not
introduce printing out WHICH commands failed, nor their error
messages.

There was also some minor refactoring to move command response
handling into their own functions (one for single response, one for
multiple) so that the code is more readable.
2021-01-30 22:13:06 +00:00
projectmoon 055bad3a46 Move a type on collect() to variable assignment
continuous-integration/drone/push Build is failing Details
2021-01-30 22:12:44 +00:00
projectmoon 16eb87e50f Convert command execution to use results.
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
2021-01-30 14:28:14 +00:00
projectmoon 1b0003ff1b Upgrade to Matrix SDK latest (Store Rewrite) and Tokio 1.0
continuous-integration/drone/push Build is passing Details
This upgrade introduces a handful of breaking changes in the Rust
Matrix SDK.
 - Some types have disappeared and changed name.
 - Some functions are no longer async.
 - Room display name now has a Result type instead of just returning
   the value.
 - Client state store has breaking changes (not really a big deal).

This required introduction of a new type to store room information
that we are interested in on the context struct. This new RoomContext
is required mostly due to unit tests, because it is no longer possible
to instantiate the Room type in the Matrix SDK.
2021-01-30 12:54:47 +00:00
projectmoon a4cdad4936 Update dependencies.
continuous-integration/drone/push Build is passing Details
2021-01-04 21:12:55 +00:00
projectmoon 297a8454f6 Avoid cloning when counting successes.
continuous-integration/drone/push Build is passing Details
2020-12-18 14:16:22 +00:00
projectmoon c9c80b974c Tests for dice pool formatting. 2020-12-17 21:14:43 +00:00
projectmoon eb42704380 Switch to into_iter instead of a non-consuming iterator.
continuous-integration/drone/push Build is passing Details
2020-12-17 21:06:43 +00:00
projectmoon f355fad06b Rename some variables for consistency.
continuous-integration/drone/push Build is passing Details
Fixes #50.
2020-12-17 20:59:29 +00:00
projectmoon 23cf9e6ba4 Show all rolls if we are below the max amount shown (15 dice).
continuous-integration/drone/push Build is passing Details
2020-12-17 20:54:01 +00:00
projectmoon aa28d8bec7 Actually add call of cthulhu documentation to the readme.
continuous-integration/drone/push Build is passing Details
2020-11-30 20:32:11 +00:00
projectmoon 62203edce8 Update readme for Call of Cthulhu, roadmap, and other stuff.
continuous-integration/drone/push Build is passing Details
2020-11-30 20:31:04 +00:00
projectmoon e177da9c25 Centralize record_room_information function.
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is failing Details
2020-11-30 19:53:26 +00:00
projectmoon a65084e04a Unit test for updating room info data.
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
2020-11-29 21:33:46 +00:00
projectmoon 979dc8ea34 Clearer test name for clearing room info. 2020-11-29 21:29:35 +00:00
projectmoon 0b2246cbd5 Unit tests for inserting and loading room info from db. 2020-11-29 21:29:13 +00:00
projectmoon 7e1abab66d Resync command now uses record_room_information.
continuous-integration/drone/push Build is passing Details
2020-11-29 21:18:41 +00:00
projectmoon 569ba4f2e0 Carry full room instance in context instead of just room id.
continuous-integration/drone/push Build is passing Details
2020-11-29 21:03:45 +00:00
projectmoon 118e4b00c7 Store room info when joining a room. 2020-11-29 17:06:04 +00:00
projectmoon c8c38ac1d4 Avoid nested map when retrieving room info from db.
continuous-integration/drone/push Build is passing Details
2020-11-29 16:55:23 +00:00
projectmoon 91cfc52e5b Change record_users_in_room to record_room_information.
continuous-integration/drone/push Build is passing Details
2020-11-29 14:02:40 +00:00
projectmoon 224f8cd0f1 Functions for storing RoomInfo in db. Refactor bot joins room event.
continuous-integration/drone/push Build is passing Details
Add get/insert functions for RoomInfo in the rooms db.

Move 'bot joins room' code to single method, so we can also record a
RoomInfo struct into the database.
2020-11-29 14:00:05 +00:00
projectmoon 68db038336 Properly avoid allocation for our_username in resync command.
continuous-integration/drone/push Build is passing Details
2020-11-23 19:54:20 +00:00
projectmoon 18352c8c19 Filter out our username when resyncing (with an allocation).
continuous-integration/drone/push Build was killed Details
2020-11-22 22:13:11 +00:00
projectmoon dda0d74f45 Implement resync command without filtering ourselves out.
continuous-integration/drone/push Build was killed Details
2020-11-22 21:30:24 +00:00
projectmoon f46b914239 Add matrix client to context. 2020-11-22 20:52:44 +00:00
projectmoon f352c90b6b Return error on unrecognized commands.
continuous-integration/drone/push Build is passing Details
2020-11-12 21:05:14 +00:00
projectmoon e251294b5f Only execute lines with commands.
continuous-integration/drone/push Build is passing Details
Fixes #45 and #46.
2020-11-12 20:22:09 +00:00
projectmoon 0e04e67f6e Log debug instead of trace for timestamp index inserts.
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
2020-11-10 20:37:14 +00:00