コード例 #1
0
ファイル: Core.cs プロジェクト: nakeliss/CQGuguBot
        void SendSetu(S2J s2j, string msgtype, long id)
        {
            string urlSetu = @"https://api.lolicon.app/setu/?r18=2";

            try
            {
                string s = GetResponseString(CreateGetHttpResponse(urlSetu));
                Debug.WriteLine(s);
                JObject o       = JObject.Parse(s);
                string  url     = (string)o["data"][0]["url"];
                string  msgat   = @"[CQ:at,qq=" + s2j.user_id + "]";
                string  msginfo = @"[PID:" + (string)o["data"][0]["pid"] + "][URL:" + url + "]";
                if (msgtype == "send_private_msg")
                {
                    MsgSend(msgtype, msginfo, id);
                }
                else
                {
                    MsgSend(msgtype, msgat + msginfo, id);
                }
                MsgSend(msgtype, "[CQ:image,file=" + url + "]", id);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
コード例 #2
0
ファイル: Core.cs プロジェクト: nakeliss/CQGuguBot
        /// <summary>
        /// 消息解析类
        /// </summary>
        /// <param name="msg"></param>
        public void MsgParsing(string msg)
        {
            S2J    s2j     = JsonConvert.DeserializeObject <S2J>(msg);
            string msgtype = null;
            long   id      = 0;

            if (s2j.message_type == "private")
            {
                msgtype = "send_private_msg";
                id      = s2j.user_id;
            }
            else if (s2j.message_type == "group")
            {
                msgtype = "send_group_msg";
                id      = s2j.group_id;
            }
            else if (s2j.message_type == "discuss")
            {
                msgtype = "send_discuss_msg";
                id      = s2j.discuss_id;
            }

            if (s2j.message == null)
            {
            }


            if (s2j.message != null)//开始套娃
            {
                try
                {
                    //搜图
                    string regImageSearch = @"^(\[CQ:at,qq=" + loginAccont.ToString() + @"\]\s\[CQ:image)";
                    if (Regex.IsMatch(s2j.message, regImageSearch) && Is_imageSearch_On)
                    {
                    }
                }
                catch (Exception)
                {
                }

                //setu
                if (((Regex.IsMatch(s2j.message, regSetu) || Regex.IsMatch(s2j.message, regSetu1))) && (Is_setu_On))
                {
                    if (wlsetu_g.Length == 0 || wlsetu_u.Length == 0 || wlsetu_d.Length == 0 || wlsetu_g.Contains(id) || wlsetu_u.Contains(id) || wlsetu_d.Contains(id))
                    {
                        SendSetu(s2j, msgtype, id);
                    }
                    else
                    {
                        MsgSend(msgtype, "不被允许的操作", id);
                    }
                }
            }
        }