Ejemplo n.º 1
0
        public static string Record(string msg)
        {
            if (!IsOpen())
            {
                return("未开启!");
            }
            string host = StrongString.GetRight(msg.Replace(" ", ""), "查询备案");

            if (!IsDomain(host))
            {
                return("查询失败,不是域名!");
            }
            byte[] data     = HttpWebClient.Post("http://whois.chinaz.com/ylz1.cn", Encoding.UTF8.GetBytes($"DomainName={host}&ws=&isforceupdate="));
            string str      = Encoding.UTF8.GetString(data);
            string regTrade = StrongString.Between(str, "注册商</div><div class=\"fr WhLeList-right\"><div class=\"block ball\"><span>", "</span>");

            if (str.Contains("未被注册或被隐藏") || str.Contains("站长工具暂不支持") || regTrade.Length > 200)
            {
                return("该域名未被注册或被隐藏!");
            }
            //string contact = StrongString.Between(str, "联系人</div><div class=\"fr WhLeList-right block ball lh24\"><span>", "</span>");
            //string email = StrongString.Between(str, "联系邮箱</div><div class=\"fr WhLeList-right block ball lh24\"><span>", "</span>");
            string createDate = StrongString.Between(str, "创建时间</div><div class=\"fr WhLeList-right\"><span>", "</span>");
            string deadline   = StrongString.Between(str, "过期时间</div><div class=\"fr WhLeList-right\"><span>", "</span>");
            string state      = StrongString.Between(str, "状态</div><div class=\"fr WhLeList-right clearfix\"><p class=\"lh30 pr tip-sh\"><span>", "(");
            string dns        = StrongString.Between(str, "DNS</div><div class=\"fr WhLeList-right\">", "</div>").Replace("<br/>", "、");

            //return $"域名:{host}\n注册商:{regTrade}\n联系人:{contact}\n联系邮箱:{email}\n创建时间:{createDate}\n到期时间:{deadline}\n状态:{state}\ndns:{dns}";
            return($"域名:{host}\n注册商:{regTrade}\n创建时间:{createDate}\n到期时间:{deadline}\n状态:{state}\ndns:{dns}");
        }
Ejemplo n.º 2
0
        public static string Ping(string msg)
        {
            if (!IsOpen())
            {
                return("未开启!");
            }
            string    ip       = StrongString.GetRight(msg.Replace(" ", ""), "ping");
            Ping      p        = new Ping();
            PingReply reply    = p.Send(ip);
            bool      isDomain = IsDomain(ip);

            //获取地址
            byte[] data    = HttpWebClient.Get($"https://www.ip.cn/?ip={reply.Address}");
            string str     = Encoding.UTF8.GetString(data);
            string address = StrongString.Between(str, "所在地理位置:<code>", "</code>");
            string result  = (isDomain ? $"域名:{ip}\n" : "") +
                             $"IP:{reply.Address}\n延迟:{reply.RoundtripTime}ms\n地址:{address}\n当前时间:{DateTime.Now}";

            return(result);
        }
Ejemplo n.º 3
0
        public static string Reply(string msg, long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(string.Empty);
                //return CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛";
            }

            //检查是否开始
            if (ps.Flag == "")
            {
                return(string.Empty);
                //return CQApi.CQCode_At(uid) + "飞花令还未开始!" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!";
            }

            //检查是否参加
            bool isJoin = false;

            foreach (var tmp in ps.Players)
            {
                if (tmp.Uid == uid)
                {
                    isJoin = true;
                    break;
                }
            }
            if (isJoin == false)
            {
                return(string.Empty);
                //return CQApi.CQCode_At(uid) + "你未参加本次飞花令比赛!";
            }

            //检查当前轮玩家
            int index = ps.LastPlayerIndex + 1;

            if (index >= ps.Players.Count)
            {
                index = 0;
            }
            if (ps.Players[index].Uid != uid)
            {
                return(string.Empty);
                //return CQApi.CQCode_At(uid) + "还未轮到你回复!\n现在请" + CQApi.CQCode_At(ps.Players[index].Uid) + "回复";
            }

            //判断语句是否包含关键字
            msg = msg.Replace(" ", "");
            string verse = msg.StartsWith("飞花令回复") ? StrongString.GetRight(msg, "飞花令回复") : msg;

            if (verse.Length < 4 || verse.Length > 8 || verse.Contains(ps.Flag) == false)
            {
                return(string.Empty);
                //return CQApi.CQCode_At(uid) + $"诗句不包含【{ps.Flag}】!";
            }

            //检查语句是否重复;
            bool isRepeat = false;

            foreach (var tmp in ps.Verses)
            {
                if (tmp == verse)
                {
                    isRepeat = true;
                    break;
                }
            }
            if (isRepeat == true)
            {
                return(CQApi.CQCode_At(uid) + "该诗句已经有人说过了!");
            }

            //检查是否正确诗句
            PoemData pd = PoemData.VerseIsExist(verse);

            if (pd == null)
            {
                return(CQApi.CQCode_At(uid) + "诗句数据库不包含该诗句!");
            }

            //加入回复
            ps.Verses.Add(verse);
            ps.Players[index].AllVerse.Add(verse);
            ps.Players[index].Score++;
            ps.Players[index].Verse = verse;
            ps.LastPlayerIndex      = index;

            int nextIndex = ps.LastPlayerIndex + 1;

            if (nextIndex >= ps.Players.Count)
            {
                nextIndex = 0;
            }
            return(CQApi.CQCode_At(uid) +
                   $"回复成功!\n{CQApi.CQCode_At(uid)}积分+1,当前积分{ps.Players[ps.LastPlayerIndex].Score}\n“{verse}”出自{pd.Info}" +
                   $"\n现在请{CQApi.CQCode_At(ps.Players[nextIndex].Uid)}回复\n(直接回复诗句即可)\n(PS:如果暂时想不出来,请回复【飞花令跳过】)");
        }