pub fn run(&mut self) {
        let adapters_len = self.adapters.len();
        let handlers_len = self.handlers.len() + self.addressed_handlers.len();

        assert!(adapters_len > 0);
        assert!(handlers_len > 0);

        println!("Chatbot: {} adapters", adapters_len);
        println!("Chatbot: {} handlers", handlers_len);

        let (incoming_tx, incoming_rx) = channel();

        for adapter in &mut self.adapters {
            adapter.process_events(incoming_tx.clone());
        }

        loop {
            // Get message from adapter
            let msg = match incoming_rx.recv() {
                Ok(msg) => msg,
                Err(_) => break
            };

            let mut addressed = false;

            // TODO this should only check the source adapter
            for adapter in &self.adapters {
                if adapter.addresser().is_match(msg.get_contents()) {
                    addressed = true;
                }
            }

            // Only dispatch to addressed handlers when bot is addressed
            if addressed {
                dispatch(&self.addressed_handlers, &msg);
            }

            // Always dispatch to global handlers
            dispatch(&self.handlers, &msg);
        }

        println!("chatbot shutting down");
    }
/// Start processing messages
///
/// Call process_events on all of the adapters and `recv` on the `IncomingMessage` channel.
/// Distribute IncomingMessages to list of handlers.
Start processing messages
Call process_events on all of the adapters and `recv` on the `IncomingMessage` channel.
Distribute IncomingMessages to list of handlers.
Start processing messages Call process_events on all of the adapters and ` recv ` on the ` IncomingMessage ` channel . Distribute IncomingMessages to list of handlers .
pub fn run(&mut self) {
        let adapters_len = self.adapters.len();
        let handlers_len = self.handlers.len() + self.addressed_handlers.len();
        assert!(adapters_len > 0);
        assert!(handlers_len > 0);
        println!("Chatbot: {} adapters", adapters_len);
        println!("Chatbot: {} handlers", handlers_len);
        let (incoming_tx, incoming_rx) = channel();
        for adapter in &mut self.adapters {
            adapter.process_events(incoming_tx.clone());
        }
        loop {
            // Get message from adapter
            let msg = match incoming_rx.recv() {
                Ok(msg) => msg,
                Err(_) => break
            };
            let mut addressed = false;
            // TODO this should only check the source adapter
            for adapter in &self.adapters {
                if adapter.addresser().is_match(msg.get_contents()) {
                    addressed = true;
                }
            }
            // Only dispatch to addressed handlers when bot is addressed
            if addressed {
                dispatch(&self.addressed_handlers, &msg);
            }
            // Always dispatch to global handlers
            dispatch(&self.handlers, &msg);
        }
        println!("chatbot shutting down");
    }
pub fn run ( & mut self ) { let adapters_len = self . adapters . len ( ) ; let handlers_len = self . handlers . len ( ) + self . addressed_handlers . len ( ) ; assert ! ( adapters_len 0 ) ; assert ! ( handlers_len 0 ) ; println ! ( " " adapters_len ) ; println ! ( " " handlers_len ) ; let ( incoming_tx , incoming_rx ) = channel ( ) ; for adapter in & mut self . adapters { adapter . process_events ( incoming_tx . clone ( ) ) ; } loop { // Get message from adapter let msg = match incoming_rx . recv ( ) { Ok ( msg ) => msg , Err ( _ ) => break } ; let mut addressed = false ; // TODO this should only check the source adapter for adapter in & self . adapters { if adapter . addresser ( ) . is_match ( msg . get_contents ( ) ) { addressed = true ; } } // Only dispatch to addressed handlers when bot is addressed if addressed { dispatch ( & self . addressed_handlers , & msg ) ; } // Always dispatch to global handlers dispatch ( & self . handlers , & msg ) ; } println ! ( " " ) ; }
Start processing messages
Call process_events on all of the adapters and `recv` on the `IncomingMessage` channel.
Start processing messages Call process_events on all of the adapters and ` recv ` on the ` IncomingMessage ` channel .
&mut self
&mut self