Factorion
A library to create factorion-bots, contains logic for parsing, calculation, and formatting.
Usage
You can use the given abstraction for comments in [comment]:
use ;
use Consts;
// You need to define constants first
let consts = default;
// Construct a comment from the text, metadata (generic), commands and maximum comment length
let comment: = new;
// Here we just checked if it might contain a factorial and put things in the correct form.
// Now to parse and extract any calculations
let comment: = comment.extract;
// Do all extracted calculations.
let mut comment: = comment.calc;
// Set flag, so a user will be notified (used when summoning on someone else)
comment.notify = Some;
// Format the reply
let reply = comment.get_reply;
// Metadata is retained throughout
assert_eq!;
// Useful status
assert_eq!;
// Good looking reply (reddit markdown formatting).
assert_eq!;
Or manually do the steps:
use ;
// You need to define constants first
let consts = default;
let locale = consts.locales.get.unwrap;
// Parse the text for calculations
let calculations: = parse;
// These are given in an intemediate format for delayed calculation
assert_eq!;
// Calculate that
let mut results: = calculations.into_iter.flat_map.filter_map.collect;
// The result is given in another format.
assert_eq!;
let result = results.remove;
let mut formatted = Stringnew;
// Write the formatted result to a string (for efficiency). We don't want to shorten anything below that huge number
result.format.unwrap;
assert_eq!;