Exemplo n.º 1
0
        /// <summary>
        /// 签到
        /// </summary>
        /// <returns>酷Q消息码</returns>
        public int Check()
        {
            User Sender = User;

            if (Sender.IsCheckin == true)
            {
                MessageSendHelper.Send(Sender, Sender.AT + "你已经签到过了哦!");
                return(1);
            }

            int    randomLoveca = 0, randomMandarinPoints = 0;
            string rewardCheckin = "";

            randomLoveca         = new Random().Next(1, 6);
            randomMandarinPoints = new Random().Next(50, 200);
            rewardCheckin        = "[CQ:image,file=UI/Items/Loveca.png] +" + randomLoveca + "\n[CQ:image,file=UI/Items/MardarinPoint.png] +" + randomMandarinPoints;
            if (DateTime.Now.Hour == 7 || DateTime.Now.Hour == 19)
            {
                randomLoveca         = randomLoveca * 5;
                randomMandarinPoints = randomMandarinPoints * 5;
                rewardCheckin        = rewardCheckin + "\n当前时间奖励翻倍!";
            }
            Sender.Loveca        = Sender.Loveca + randomLoveca;
            Sender.MandarinPoint = Sender.MandarinPoint + randomMandarinPoints;

            Sender.Checkin();

            Sender.Send(Sender.AT + "\n" + rewardCheckin);

            return(1);
        }
Exemplo n.º 2
0
        public static int Auto(User Sender, string Msg)
        {
            try
            {
                string songName = "";

                if (Msg.Length == 4)
                {
                    MessageSendHelper.Send(Sender, Sender.AT + "请输入歌名!");
                    return(1);
                }

                songName = Msg.Replace("网易点歌", "");


                string    postString = "s=" + songName + "&limit=1&type=1";
                byte[]    postData   = Encoding.UTF8.GetBytes(postString);
                string    url        = "http://music.163.com/api/search/get/";              //地址
                WebClient webClient  = new WebClient();
                webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); //采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可
                byte[] responseData = webClient.UploadData(url, "POST", postData);          //得到返回字符流
                string srcString    = Encoding.UTF8.GetString(responseData);                //解码

                Model model = null;
                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(srcString)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(Model));
                    model = (Model)deseralizer.ReadObject(ms);
                }

                Sender.Send("[CQ:music,id=" + model.result.songs[0].id.ToString() + ",type=163]");
                return(1);
            }
            catch (Exception)
            {
                Sender.Send(Sender.AT + "点歌失败!\n请确认名称是否正确,如果有重名歌曲请加上 -歌手名称 再试试!");
            }

            return(1);
        }