aji / miau

cat
0 stars 0 forks source link

Add an IRC message handling framework #5

Open aji opened 9 years ago

aji commented 9 years ago

Right now a single match is used, which is good enough for the moment. However, a more robust framework for registering IRC command handlers should be implemented.

For the framework to be considered complete, it must meet the following requirements:

BlacklightShining commented 8 years ago

My immediate response to this is to a field tocore::Bot to store handlers (a HashMap<Vec<u8>, Vec<Handler>>?) and provide some kind of interface to let other modules add (and remove?) them. And the last requirement seems pretty easy; Handlers could have Fns that take mutable references to the EventedCtl and Reactor.

aji commented 8 years ago

yeah, passing a mutable reference to the EventedCtl is possible, but only because Bot has both &mut self and &mut EventedCtl as arguments to on_line. the sneaky problem with this (and part of why EventedCtl etc. exists) is because when one struct is inside of another, you can't pass mutable references to both without upsetting the borrow checker. that's why Bot is not inside of EventedCtl, and vice versa.

BlacklightShining commented 8 years ago

…hmm, the Reactor is local to Bot::run(). I think that's gonna have to change if we want to lend it to handlers…could we make it a Bot field, too?

aji commented 7 years ago

this is blocking all the interesting work, so I'll try to get to it this weekend

aji commented 7 years ago

this is sort of handled in the nonsense here now https://github.com/aji/miau/blob/master/src/network.rs#L110-L142

miles ahead of what we had before