コード例 #1
0
ファイル: HandlerService.cs プロジェクト: Olezhka/Hipbot
        /// <summary>
        /// Determines whether this instance can handle the specified message in the room.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="room">The room.</param>
        /// <returns>
        ///   <c>true</c> if this instance can handle the specified room; otherwise, <c>false</c>.
        /// </returns>
        private bool CanHandle(Message message, Room room)
        {
            var canHandle = message.Body != null;

            // Check message is not one-on-one message
            if (!room.IsChat)
            {
                // Check message is addressed to this bot
                if (!NicknameService.IsAddressedToMe(message))
                {
                    canHandle = false;
                }

                // Strip Bot name from message
                if (message.Body == null)
                {
                    return(false);
                }

                var index = message.Body.IndexOf(" ");
                message.Body = message.Body.Substring(index + 1);
            }

            return(canHandle);
        }
コード例 #2
0
ファイル: NicknameServiceTest.cs プロジェクト: Olezhka/Hipbot
 public void SetUp()
 {
     service = Create<NicknameService>();
 }
コード例 #3
0
 public void SetUp()
 {
     service = Create <NicknameService>();
 }