Commit Graph

238 Commits

Author SHA1 Message Date
projectmoon 514ac84e73 Encapsulate config with Arc. Further bot code cleanup.
Only expose config settings via methods on the Config struct. This
allows default value handling to live entirely inside the config code,
solves various borrowing issues with the "create default bot config
value" solution, and allows us to avoid cloning the bot config values.
The downside is that the config must now be in an Arc since its
ownership is shared in multiple places and the matrix SDK requires
thread-safe types (perhaps in the future we re-compose traits and use
Rc for config instead).

This commit also further cleans up and splits up the bot code for the
matrix connection, notably making the main message event handler
smaller by splitting out the "should we process the message" checks
into a separate function.
2020-10-03 20:45:14 +00:00
projectmoon 938107feae Implement Actix for state, refactor bot code.
Instead of using an Arc Mutex for state management embedded directly
into the bot, utilize actor pattern, with the idea that this will be
much more useful than simply logging a message once in the future.

This also refactors the bot code so that instead of a single run_bot
function, the DiceBot struct now has a run() method attached to it.
This also necessitated changes and cleanup to the dicebot main, which
is for the better anyhow.

The error and config types are also now in their own files, and
implemented for more in-depth use cases.
2020-10-03 20:45:14 +00:00
projectmoon a5ec5c1e12 Release 0.6.0 2020-09-27 13:04:13 +00:00
projectmoon 564515e22f Remove commented rustup init in Dockerfile. 2020-09-27 13:01:49 +00:00
projectmoon f84cc16cf4 Update readme for new ignore message settings. 2020-09-27 12:59:31 +00:00
projectmoon f844b09213 Recover from potentially but unlikely poisioned mutexes. 2020-09-27 09:44:59 +00:00
projectmoon 620bea0521 Only use one instance of state instead of cloning it everywhere. 2020-09-27 09:44:59 +00:00
projectmoon 624c748583 Add useful logging of skipping commands.
This commit lays the groundwork for a stateful dicebot, instead of one
that only responds to commands. It now maintains a simple state
machine, used to store the current state of the bot. Currently, it
only cares about whether or not the message about skipping old
messages was logged.
2020-09-27 09:44:59 +00:00
projectmoon 6d49c9e16c Fall back to 15 minutes if oldest message age not specified.
This makes the oldest message age setting optional, in additon to the
entire bot config (for now). If the oldest message age is not
specified (or if the entire bot config is missing), it will default to
15 minutes.
2020-09-27 09:44:59 +00:00
projectmoon fabda911fd Ignore messages that are too old. 2020-09-27 09:44:59 +00:00
projectmoon 92e4a7c29b Rote die roll now respects dice pool success_on property.
Fixes #5.
2020-09-26 14:04:12 +00:00
projectmoon e391deb278 Update cargo.lock for 0.5.2 2020-09-26 13:49:58 +00:00
projectmoon 908507c28c Update readme for new docker image. 2020-09-26 13:25:26 +00:00
projectmoon d0e6ffdc43 Switch to Github container registry. 2020-09-25 22:32:24 +00:00
projectmoon fafae6175b Update to latest matrix SDK; dynamic libolm; Dockerfile cleanup.
Updates to the latest matrix SDK, which has a new version of olm-sys
(must be dynamically linked at the moment). Also cleans up the
Dockerfile to remove rustup because Void has reached Rust 1.46.0, for
a faster build.
2020-09-25 22:31:11 +00:00
projectmoon 06ff6562c1 Add more tests for handling weird input. 2020-09-01 08:17:59 +00:00
projectmoon 33c41bce7e Update readme for automated Docker builds. 2020-09-01 08:11:19 +00:00
projectmoon f3f5846826 Fix command parser returning non-commands/empty messages as errors.
This behavior became broken again after switching away from the
macro-based command parsing. The bot would return any non !command
message as an error, which would cause it to read more messages, and
return those as errors, until finally the matrix SDK would throw up.

Command parser now more properly handles empty messages and
non-commands, but we also simply abort processing if the incoming
message doesn't start with an exclamation point.
2020-08-31 23:33:46 +00:00
projectmoon 16a9aeebcd Only run Docker CI stages when necessary.
Instead of building the image all the time, and only pushing if
necessary.
2020-08-31 22:30:44 +00:00
projectmoon ae6922dd6c Correct image name. 2020-08-31 22:06:35 +00:00
projectmoon 0388daa8ac Fix docker push for master 2020-08-31 21:40:42 +00:00
projectmoon 374f426961 Switch to docker hub because github packages is useless. 2020-08-31 21:35:19 +00:00
projectmoon b90f1fe92a No point in building docker image only to build it again. 2020-08-31 20:57:47 +00:00
projectmoon 4ff8e95640 One CI pipeline for build, test, docker push. 2020-08-31 20:48:46 +00:00
ProjectMoon 0d16d9f2cd
Add GitHub CI Docker build 2020-08-31 20:24:57 +00:00
ProjectMoon 1e5331a7ee
Add rust github CI 2020-08-31 20:18:49 +00:00
projectmoon 8803b83ddb Remove useless trim function and unnecessary uses of eat_whitespace. 2020-08-31 20:16:43 +00:00
projectmoon da0819745a Switch to non-macro nom parser with better text handling.
By using the alpha1 function in complete mode, we are able to handle
arbitrary single-word commands (e.g. "!help") and proprly map the
remaining input to an empty string.
2020-08-31 00:07:56 +00:00
projectmoon 1f5c6d7553 Actually only trim the start and end of the string.
Be careful what you find on Stack Overflow, kids.
2020-08-31 00:05:40 +00:00
projectmoon d36a38d16f Basic documentation for the !help command. 2020-08-30 22:17:33 +00:00
projectmoon 0a2c5d5ce6 Remove editor-specific configuraton for vscode. 2020-08-30 22:15:46 +00:00
projectmoon 531844fbb7 Implement basic, not-well-formatted help. 2020-08-30 21:54:01 +00:00
projectmoon 8484e9ffde Allow extraneous whitespace at the end of command input. 2020-08-30 21:45:42 +00:00
projectmoon 32573d2e7c Update version to 0.5.0, and update license copyright. 2020-08-29 13:08:55 +00:00
projectmoon 16b5a3a51a Chance die should only succeed on 10. Added no-explode rolls. 2020-08-28 21:47:09 +00:00
projectmoon dfa96f51bd Update matrix SDK to latest master. 2020-08-28 21:10:59 +00:00
projectmoon bfc25ca30e Update readme documentation. 2020-08-28 21:06:57 +00:00
projectmoon e85196e105 Change readme header. 2020-08-28 00:42:56 +00:00
projectmoon 940e83077a Version 0.4.0: limit display of large dice pools, basic logging. 2020-08-28 00:37:39 +00:00
projectmoon 5983592eb3 Limit large the display of large dice pools. 2020-08-28 00:30:28 +00:00
projectmoon 54a3cc0880 Add basic logging to the dice bot. 2020-08-28 00:13:04 +00:00
projectmoon f0a1fe53fc Move CofD dice rolling into dice.rs file under cofd/ 2020-08-27 23:56:19 +00:00
projectmoon 18a05ebd7c Add auto-join, adapted from matrix SDK examples. 2020-08-27 23:50:32 +00:00
jeff 12fdc2a1c9 Add tar files to gitignore 2020-08-27 19:49:21 +00:00
projectmoon e8ce058e5d Properly format dramatic failures. 2020-08-27 19:49:21 +00:00
projectmoon 33ac91063b Set cache dir to something more accessible. 2020-08-27 19:49:21 +00:00
jeff f3de145663 New Dockerfile to work with glibc. 2020-08-27 19:49:21 +00:00
jeff 0eb181a7a9 Clean up dependencies and upgrade to 0.3.0 after matrix SDK port. 2020-08-27 00:05:19 +00:00
jeff 6572e1d04e Port dice bot to use matrix-rust-sdk.
This gives us many things for free, like automated state management,
no need to declare special API structs and use HTTP requests directly,
and most importantly: ENCRYPTION!
2020-08-26 23:53:30 +00:00
jeff 0f41acd078 gitignore updates 2020-08-23 21:24:04 +00:00