Ejemplo n.º 1
0
        public override IResponseMessage OnTextRequest(RequestMessageText requestMessage)
        {
            var content = requestMessage.Content.Trim().ToLower();

            if (content == "help")
            {
                using (var manager = new ArticleManager())
                {
                    return(manager.GetHelp());
                }
            }
            if (content == "about")
            {
                using (var manager = new ArticleManager())
                {
                    return(manager.GetAbout());
                }
            }
            if (content == "top")
            {
                using (var manager = new ArticleManager())
                {
                    return(manager.GetTop());
                }
            }
            if (content == "next")
            {
                return(new ResponseMessageText("此命令功能尚未开发完成,请稍后再试"));
            }
            if (content == "tags")
            {
                using (var manager = new ArticleManager())
                {
                    return(manager.GetAllTags());
                }
            }
            if (content.Length == 8)
            {
                long publishDate;
                if (long.TryParse(content, out publishDate))
                {
                    using (var manager = new ArticleManager())
                    {
                        return(manager.GetByPublishDate(content));
                    }
                }
            }
            IResponseMessage responseForTag;

            using (var manager = new ArticleManager())
            {
                responseForTag = manager.GetByTag(content);
            }

            return(responseForTag ?? new ResponseMessageText("无此命令或关键字,请发送 help 来获得帮助"));
        }