Example #1
0
        public static List <GroupInfo> GetGroupList2(ICoolQApi api)
        {
            List <GroupInfo> list = new List <GroupInfo>();

            try
            {
                //CQLogger.GetInstance().AddLog(string.Format("[↓][帐号] 取群列表", new object[0]));
                string          url             = "http://qun.qq.com/cgi-bin/qun_mgr/get_group_list";
                var             postData        = new Dictionary <string, string>();
                XJHTTP          xJHTTP          = new XJHTTP();
                CookieContainer cookieContainer = xJHTTP.StringToCookie("qun.qq.com", api.GetCookies());


                postData.Add("bkn", api.GetCsrfToken().ToString());
                HttpResults httpResults = xJHTTP.PostHtml(url, "http://qun.qq.com/member.html", "bkn=" + api.GetCsrfToken().ToString(), false, cookieContainer, 15000);

                string sourceString = httpResults.Html;
                MyLogUtil.ToLog(httpResults.Html);
                var                     strReg     = "{\"gc\":([1-9][0-9]{4,10}),\"gn\":\"(.*?)\",\"owner\":([1-9][0-9]{4,10})}";
                Regex                   reg        = new Regex(strReg);
                MatchCollection         matches    = reg.Matches(sourceString);
                MyJsonUtil <GroupInfo2> myJsonUtil = new MyJsonUtil <GroupInfo2>();
                foreach (Match match in matches)
                {
                    GroupInfo2 g = myJsonUtil.parseJsonStr(match.Value);
                    list.Add(new GroupInfo(g.gn, g.gc, g.owner));
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                MyLogUtil.ErrToLog("获取群列表出现错误,原因:" + ex);
            }
            return(list);
        }
Example #2
0
 protected CqpApiMahuaCommandHandlerBase(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
 {
     CoolQApi = coolQApi;
     _cqpAuthCodeContainer = cqpAuthCodeContainer;
 }
Example #3
0
        public static List <GroupInfo> GetGroupList(ICoolQApi api)
        {
            string content = api.CQ_getGroupList();

            MyLogUtil.ErrToLog("获取的群信息:" + content);
            return(ParseGroupList(content));
        }
Example #4
0
 public QqProvider(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer authCodeContainer)
 {
     _coolQApi          = coolQApi;
     _authCodeContainer = authCodeContainer;
 }
Example #5
0
        public MainPlugin(ICoolQApi coolQApi) : base(coolQApi)
        {
            try
            {
                //这里调用的话,会报authCode错误,

                /*
                 * CacheData.LoginQQ = coolQApi.GetLoginQQ();
                 * CacheData.LoginNick = coolQApi.GetLoginNick();
                 * MyLogUtil.ToLogFotTest(CacheData.LoginQQ + "_" + CacheData.LoginNick);
                 */
                //先判断当前电脑是否有合适的.net版本
                if (!MyDotNetFrameworkUtil.IsSupportedRuntimeVersion())
                {
                    IsSupportedRuntimeVersion = false;

                    new RuntimeVerForm().Show();

                    return;
                }
                else
                {
                    IsSupportedRuntimeVersion = true;
                    CacheData.CoolQApi        = coolQApi;
                    //酷q登录成功后,进入软件登录页面
                    new login().Show();
                }
            }
            catch (Exception ex)
            {
                MyLogUtil.ErrToLog("不可预知的异常,原因:" + ex);
                MessageBox.Show("不可预知的异常,请查看错误日志");
            }
        }
 public MyPlugin(ICoolQApi coolQApi) : base(coolQApi)
 {
     frmLogin = new www._52bang.site.tk.yinliu.FrmLogin(this);
     frmLogin.Show();
     //mainForm = new MainForm(CoolQApi);
     //mainForm.Show();
 }
 public MahuaApi(ICoolQApi coolQApi, ICqpAuthCodeContainer cqpAuthCodeContainer,
                 IGroupMemberInfoSerializer groupMemberInfoSerializer, IGroupInfoSerializer groupInfoSerializer)
 {
     _coolQApi                  = coolQApi;
     _cqpAuthCodeContainer      = cqpAuthCodeContainer;
     _groupMemberInfoSerializer = groupMemberInfoSerializer;
     _groupInfoSerializer       = groupInfoSerializer;
 }
Example #8
0
 public GetGroupMemebersWithModelApiMahuaCommandHandler(
     IGroupMemberInfoSerializer groupMemberInfoSerializer,
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
     _groupMemberInfoSerializer = groupMemberInfoSerializer;
 }
        public MainController(ICoolQApi coolQApi) : base(coolQApi)
        {
            cc = new ChatController();

            cc.outputQQEvent = new ChatController.sendQQChatMessage(printOutput);
            //cc.outputEvent = new ChatController.sendChatMessageDelegate(printOutput);
            cc.start();
        }
 public SendDiscussMessageApiMahuaCommandHandler(
     CqpMessageCancelToken.Factory factory,
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
     _factory = factory;
 }
Example #11
0
        /// <summary>
        /// 获取qq群列表
        /// </summary>
        /// <param name="api"></param>
        /// <returns></returns>
        public static List <MyModel.GroupInfo> GetGroupList(ICoolQApi api)
        {
            string content = api.CQ_getGroupList();
            List <MyModel.GroupInfo> list = ParseGroupList(content);

            //缓存当前加载的群列表
            CacheData.CurrentGroupList = list;
            return(list);
        }
 public CqpMessageCancelToken(
     long messageId,
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
 {
     MessageId             = messageId;
     _coolQApi             = coolQApi;
     _cqpAuthCodeContainer = cqpAuthCodeContainer;
 }
Example #13
0
        public static void SetCoolCookies(this IRestRequest restRequest, ICoolQApi api)
        {
            var cookies = api.GetCookies();

            foreach (var s in cookies.Split(';').Select(x => x.Trim()))
            {
                var nameValue = s.Split('=');
                restRequest.AddCookie(nameValue[0], nameValue[1]);
            }
        }
Example #14
0
        /// <summary>
        /// 获取群成员,并缓存
        /// </summary>
        /// <param name="api"></param>
        /// <param name="groupId"></param>
        /// <returns></returns>
        public static List <GroupMemberInfoWithBocai> GetGroupMemberListAndCache(ICoolQApi api, long groupId)
        {
            List <GroupMemberInfoWithBocai>                        list   = new List <GroupMemberInfoWithBocai>();
            Dictionary <long, GroupMemberInfoWithBocai>            keyVal = new Dictionary <long, GroupMemberInfoWithBocai>();
            ModelWithSourceString <IEnumerable <GroupMemberInfo> > result = CoolApiExtensions.GetGroupMemberList(api, groupId);
            IEnumerable <GroupMemberInfo> iterator = result.Model;

            if (iterator != null)
            {
                foreach (GroupMemberInfo memberInfo in iterator)
                {
                    GroupMemberInfoWithBocai groupMemberInfoWithBocai = new GroupMemberInfoWithBocai(memberInfo, list.Count);

                    //增加短名字
                    //===================2018-02===================
                    string shortName = "";// Regex.Replace(g.NickName, @"\[[^\]]*?\]", "");
                    shortName = function.filtetStingSpecial(groupMemberInfoWithBocai.GroupMemberBaseInfo.NickName);
                    //===================2018-02===================


                    shortName = shortName.Replace("'", "").Replace("/", "").Replace("\\", "").Replace("\"", "").Replace(".", "");
                    bool isHanzi = false;
                    for (int ii = 0; ii < shortName.Length; ii++)
                    {
                        if ((int)shortName[ii] > 127)
                        {
                            //是汉字
                            isHanzi = true;
                            break;
                        }
                    }
                    if (isHanzi)
                    {
                        shortName = shortName.Length > 2 ? shortName.Substring(0, 2) : shortName;
                    }
                    else
                    {
                        shortName = shortName.Length > 4 ? shortName.Substring(0, 4) : shortName;
                    }

                    groupMemberInfoWithBocai.NickNameShort = shortName;

                    list.Add(groupMemberInfoWithBocai);
                    keyVal.Add(memberInfo.Number, groupMemberInfoWithBocai);
                }
            }

            CacheData.GroupMemberInfoList = list;
            CacheData.GroupMemberInfoDic  = keyVal;
            return(list);
        }
 public MyPlugin(ICoolQApi coolQApi) : base(coolQApi)
 {
     //获取本地配置
     systemConfigJson = MySystemUtil.GetSystemConfigJson();
     if (systemConfigJson == null)
     {
         MessageBox.Show("不能加载" + MySystemUtil.GetSystemConfigJsonPath() + ",请重启");//程序即将退出
     }
     else
     {
         mainForm = new MainForm();
         mainForm.Show();
         mainForm.setCoolQApi(CoolQApi);
     }
 }
Example #16
0
        /// <summary>
        ///     取群成员信息(支持缓存)
        /// </summary>
        /// <param name="api">api</param>
        /// <param name="groupId">目标群</param>
        /// <param name="qqId">目标QQ</param>
        /// <param name="cache">是否缓存</param>
        /// <returns></returns>
        public static ModelWithSourceString <GroupMemberInfo> GetGroupMemberInfoV2(this ICoolQApi api,
                                                                                   long groupId, long qqId,
                                                                                   bool cache)
        {
            var data   = api.GetGroupMemberInfoV2AsString(groupId, qqId, cache);
            var source = Convert.FromBase64String(data);
            var re     = new ModelWithSourceString <GroupMemberInfo>
            {
                SourceString = data
            };
            GroupMemberInfo gm = new GroupMemberInfo();

            if (ConvertAnsiHexToGroupMemberInfo(source, ref gm))
            {
                re.Model = gm;
            }
            return(re);
        }
        public MainForm(ICoolQApi coolQApi, String ret, String loginUserName) : this(ret, loginUserName)
        {
            this.coolQApi = coolQApi;
            promptForm    = new PromptForm();


            InitializeComponent();

            //正在加载请稍后
            initForm = new InitForm();
            initForm.ShowInfo("正在加载配置信息...");
            //初始化配置
            InitConfig();
            initForm.ShowInfo("正在重新渲染UI...");
            ReloadPaint();

            //Thread.Sleep(2000);
            initForm.Hide();
        }
Example #18
0
 /// <summary>
 /// 获取群列表
 /// </summary>
 /// <param name="api"></param>
 /// <returns></returns>
 public static IEnumerable <GroupInfo> GetGroupList(this ICoolQApi api)
 {
     try
     {
         var client      = new RestClient("http://qun.qq.com/cgi-bin/qun_mgr/get_group_list");
         var restRequest = new RestRequest();
         restRequest.AddParameter("bkn", api.GetCsrfToken().ToString(), ParameterType.GetOrPost);
         restRequest.SetAccept();
         restRequest.SetUserAgent();
         restRequest.SetReferer("http://qun.qq.com/member.html");
         restRequest.SetCoolCookies(api);
         var restResponse = client.Post(restRequest);
         var re           = JsonConvert.DeserializeObject <GetGroupListResult>(restResponse.Content).GroupInfos;
         return(re);
     }
     catch (Exception e)
     {
         api.AddLog(CoolQLogLevel.Fatal, $"获取群列表发生异常:{e.Message}");
         return(Enumerable.Empty <GroupInfo>());
     }
 }
Example #19
0
 public SetBanAllGroupMembersOptionApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
Example #20
0
 public GetLoginNickApiMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
Example #21
0
 public AcceptGroupJoiningInvitationApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
Example #22
0
 public Plugin(ICoolQApi coolQApi) : base(coolQApi)
 {
     m_API = coolQApi;
 }
 public PocketPlugins(ICoolQApi coolQApi) : base(coolQApi)
 {
     Api = CoolQApi;
 }
Example #24
0
 public RejectFriendAddingRequestApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
Example #25
0
 public RemoveBanGroupMemberApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
Example #26
0
 public EnableGroupAdminApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
 public SendGroupMessageApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
 internal void setCoolQApi(ICoolQApi coolQApi)
 {
     this.coolQApi = coolQApi;
 }
 public SetGroupMemberCardApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }
 public LeaveDiscussApiMahuaMahuaCommandHandler(
     ICoolQApi coolQApi,
     ICqpAuthCodeContainer cqpAuthCodeContainer)
     : base(coolQApi, cqpAuthCodeContainer)
 {
 }