Refactor event loop
Most notably, I refactored EventLoop
to store all update handlers (except commands, as they're stored a bit differently) in one TypeMap
. Not only this makes for more maintainable code, this already reduced EventLoop
's size from 1328 bytes to 208 (as previously we had a separate Vec
for each possble update).
Storing Handlers<Context>
in a TypeMap
doesn't work well with before_update
and after_update
, as they use the same context. Since we planned to get rid of them anyway as per #56 (closed), I replaced them with any_update
.
A few other changes:
- Improve documentation;
- Refactor the
handler!
macro in order to reduce code lines further by making its invocation more compact.