Ejemplo n.º 1
0
        /// <summary>
        /// Handles the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="room"></param>
        public void Handle(Message message, Room room)
        {
            // Check bot can handle this message
            if (!CanHandle(message, room))
            {
                return;
            }

            // Check for aliases
            if (AliasService.IsAlias(message.Body))
            {
                message.Body = AliasService.GetAlias(message.Body);
            }

            // Remove Alias bypass
            if (message.Body.StartsWith("!"))
            {
                message.Body = message.Body.Substring(1);
            }

            var handled = false;

            // Check each handler
            foreach (var handler in Handlers)
            {
                if (!handler.CanHandle(message))
                {
                    continue;
                }

                handler.Receive(message, room);

                handled = true;

                break;
            }

            if (!handled)
            {
                HipChatService.Say(room, "I didn't understand: {0}", message.Body);
            }
        }
Ejemplo n.º 2
0
 public void SetUp()
 {
     service = Create<AliasService>();
 }
Ejemplo n.º 3
0
 public void SetUp()
 {
     service = Create <AliasService>();
 }