コード例 #1
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>());
     }
 }
コード例 #2
0
 /// <summary>
 ///     添加运行日志
 /// </summary>
 /// <param name="api"></param>
 /// <param name="logType">日志类型</param>
 /// <param name="content">日志内容</param>
 /// <returns></returns>
 public static int AddLog(this ICoolQApi api, CoolQLogLevel logType, string content)
 {
     return(api.AddLog((int)logType, logType, content));
 }