Age | Commit message (Collapse) | Author |
|
Add our `Bot` monad to the rest of the plugins:
* Factorial
* GitRemoteSetOrigin
* Help
The only problem is with the Help plugin. Still trying to figure out how
to set up my list comprehension so that it works with the `Bot`-wrapped
`Plugin` list.
|
|
A new field that says whether this plugin should only respond via a
private query message to the user instead of responding on the channel
the message was sent from.
This is needed for the Help plugin, which shouldn't flood channels with
lots of extraneous output. Instead, the Help plugin should send the list
of commands directly to the user.
Since most of the time we don't want this behaviour, encode a default of
`False` on the field so that most plugins don't have to define it
manually. This necessitates changing the constructors to use the default
`Plugin` instead.
|
|
Let users know how much factorial they can calculate.
|
|
The `Integer` type has arbitrary precision. This is why the function was
working fine in GCHi but overflowing when I was testing the bot. Use
`Integer` to get the real values we want.
https://stackoverflow.com/questions/36355757/large-numbers-become-negative-in-haskell
Also add a little extra error handling to deal with unexpected numbers.
Now that I think about it, the regex parser isn't going to handle
negative numbers, so we're good on that front. Set an upper bound so we
don't end up spending a lot of time trying to calculate numbers and
potentially segfault if huge numbers are given.
|
|
Apparently that's short for `Enum a, Num a`.
|
|
This plugin calculates factorials. It's not super optimised, but works
for small inputs.
Adds the 'text-show' plugin to convert the resulting integer to a
`Data.Text` to be returned by the plugin action.
At first I had tried /^\d+!$/ for the regex match, but that produced
this error:
sorbot/src/Plugin/Factorial.hs:14:24: error:
lexical error in string/character literal at character 'd'
Tried to fix that by using /^\\d+!$/, but that didn't match anything.
Then tried a long-form character class, /^[:digit:]+!$/, which TDFA
implies it supports, but a quick look at the code seems to indicate that
those parts were removed or commented out. Not sure what was going on
with that. So instead went for the remaining solution, a `0-9` character
class.
|