public bool IsOnline() { string str = ThirdPartAPIs._get_with_cookies("https://api.bilibili.com/x/web-interface/nav", Cookies); JObject jb = (JObject)JsonConvert.DeserializeObject(str); return(jb.Value <int>("code") == 0); }
public PrivSessionManager(ThirdPartAPIs sess) { this.sess = sess; followed_sessions = new List <PrivMessageSession>(); unfollowed_sessions = new List <PrivMessageSession>(); group_sessions = new List <PrivMessageSession>(); }
public PrivMessage(JToken json, ThirdPartAPIs sess) { recieiver_id = json.Value <int>("receiver_id"); timestamp = json.Value <int>("timestamp"); talker = BiliUser.getUser(json.Value <int>("sender_uid"), sess); msgtype = json.Value <int>("msg_type"); msg_seqno = json.Value <int>("msg_seqno"); msg_key = json.Value <long>("msg_key"); object jobjdes = JsonConvert.DeserializeObject(json.Value <string>("content")); try { if (jobjdes.GetType() != json.GetType()) { content = jobjdes.ToString(); } else { content_json = (JObject)jobjdes; content = content_json.Value <string>("content"); } } catch { content = jobjdes.ToString(); } }
/// <summary> /// 会话管理器 /// </summary> public PrivSessionManager(IAuthBase auth) { sess = new ThirdPartAPIs(auth.GetLoginCookies()); followed_sessions = new List <PrivMessageSession>(); unfollowed_sessions = new List <PrivMessageSession>(); group_sessions = new List <PrivMessageSession>(); }
/* * { * "timestamp":该属性值被生成时的时间戳(Java 时间戳格式,即自 1970-01-01 00:00:00 UTC 至今经过的毫秒数), * "profileId":"角色 UUID(无符号)", * "profileName":"角色名称", * "textures":{ // 角色的材质 * "材质类型(如 SKIN)":{ // 若角色不具有该项材质,则不必包含 * "url":"材质的 URL", * "metadata":{ // 材质的元数据,若没有则不必包含 * "键":"值" * // ,...(可以有更多) * } * } * // ,...(可以有更多) * } * } */ public SkinHandler(string puuid, string pname, List <Texture> textures) { timestamp = GetTimeStamp(); profileId = puuid; profileName = pname; this.textures = textures; trusted_source = ThirdPartAPIs.getTrustedSkinServer(); }
public PrivMessageSession(int targetuid, ThirdPartAPIs sess) { this.sess = sess; talker_id = targetuid; CookieCollection ck = sess.CookieContext; uid = int.Parse(ck["DedeUserID"].Value); isGroup = false; }
/// <summary> /// 返回值包括生成二维码和后续登录所需的全部信息。 /// </summary> /// <returns>OAuthKey和登录链接</returns> public LoginQRCode GetNewQRItem() { JObject jb = (JObject)JsonConvert.DeserializeObject(ThirdPartAPIs._get(URL_GETKEY)); if (jb.Value <int>("code") != 0) { throw new ApiRemoteException(jb); } return(new LoginQRCode { ScanUrl = jb["data"].Value <string>("url"), OAuthKey = jb["data"].Value <string>("oauthKey") }); }
public static PrivMessageSession openSessionWith(int taruid, ThirdPartAPIs sess) { string rtv = sess._get_with_cookies("https://api.vc.bilibili.com/session_svr/v1/session_svr/session_detail?talker_id=" + taruid + "&session_type=1"); JObject raw_json = (JObject)JsonConvert.DeserializeObject(rtv); if (raw_json.Value <int>("code") == 0) { return(new PrivMessageSession(raw_json["data"], sess)); } else { return(new PrivMessageSession(taruid, sess)); } }
/// <summary> /// 获取二维码状态 /// </summary> /// <param name="qr">二维码信息</param> /// <returns>二维码状态</returns> public QRState GetQRState(LoginQRCode qr) { var res = ThirdPartAPIs._post_cookies(URL_STATUS, new Dictionary <string, string>() { { "oauthKey", qr.OAuthKey }, { "gourl", "https://www.bilibili.com/" } }); JObject jb = (JObject)JsonConvert.DeserializeObject(res.Result); try { switch (jb.Value <int>("data")) { case -4: return(QRState.WaitingForScan); case -5: return(QRState.WaitingForAccept); case -2: case -1: return(QRState.Expired); default: throw new UnexpectedResultException(jb.ToString(), "Unexpected QRCode state"); } } catch (UnexpectedResultException e) { throw; } catch (Exception) { if (jb.Value <bool>("status")) { Cookies = res.Cookies; LoggedIn = IsOnline(); if (!LoggedIn) { throw new AuthenticateFailedException(jb); } return(QRState.LoggedIn); } else { throw new UnexpectedResultException(jb.ToString()); } } }
public static bool CheckSkinSourceTrusted(string url) { try { string[] trusted_sourcE = ThirdPartAPIs.getTrustedSkinServer(); Uri u = new Uri(url); string domain = u.Host; foreach (string trusted in trusted_sourcE) { if (domain.Contains(trusted)) { return(true); } } return(false); } catch { return(false); } }
public ManagementWindow() { InitializeComponent(); uinfo = new Dictionary <string, UserInfo>(); api = new ThirdPartAPIs(Program.biliauth.Cookies); procqueue = new Queue <DanmakuModel>(); new Thread(new ThreadStart(() => { while (rrun) { while (rrun && procqueue.Count == 0) { Thread.Sleep(1); } if (!rrun) { break; } ProcessDanmaku(procqueue.Dequeue()); } })).Start(); }
public async Task HandleMessageAsync(IMiraiHttpSession session, IGroupApplyEventArgs e) { if (!DataBase.me.IsGroupRelated(e.FromGroup)) { return; } if (DataBase.me.isUserBlacklisted(e.FromQQ)) { MainHolder.broadcaster.BroadcastToAdminGroup("入群的用户 " + e.NickName + "(" + e.FromQQ + ") 存在于黑名单中,自动拒绝。"); await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "您被设置不能加入任何粉丝群。"); return; } switch (DataBase.me.isUserTrusted(e.FromQQ)) { case 1: DataBase.me.removeUserTrustlist(e.FromQQ); MainHolder.broadcaster.BroadcastToAdminGroup("入群的用户 " + e.NickName + "(" + e.FromQQ + ") 受到单次信任,同意入群。\n该次信任已被移除。"); goto case 9; //显式允许直接进入下一个case case 0: MainHolder.broadcaster.BroadcastToAdminGroup("入群的用户 " + e.NickName + "(" + e.FromQQ + ") 受到永久信任,同意入群。"); goto case 9; //显式允许直接进入下一个case case 9: await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Allow); return; } int qqlevel = -1; if (e.FromGroup != 964206367) { qqlevel = ThirdPartAPIs.getQQLevel(e.FromQQ, 2); if (qqlevel < 0) { Thread.Sleep(2000); qqlevel = ThirdPartAPIs.getQQLevel(e.FromQQ, 2); } if (qqlevel < 0) { MainHolder.broadcaster.BroadcastToAdminGroup("入群的用户 " + e.NickName + "(" + e.FromQQ + ") 等级查询失败(try3,2s,try3),已提示重新申请"); await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "等级查询失败,请重新申请入群"); return; } else if (qqlevel < 16) { MainHolder.broadcaster.BroadcastToAdminGroup("入群的用户 " + e.NickName + "(" + e.FromQQ + ") 等级过低(" + qqlevel + "<16), 拒绝"); await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "您的QQ等级过低, 如有疑问请联系管理"); return; } } if (DataBase.me.isCrewGroup(e.FromGroup)) { //是舰长群 CrewChecker cr = new CrewChecker(); if (DataBase.me.isUserBoundedUID(e.FromQQ)) //舰长绑定 { var uid = DataBase.me.getUserBoundedUID(e.FromQQ); if (DataBase.me.isBiliUserGuard(uid)) { await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Allow); MainHolder.broadcaster.BroadcastToAdminGroup(e.FromQQ + "\n!正在加入舰长群(" + qqlevel + ">=16)\n是舰长,同意"); } else { await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "没有您的大航海数据,如有疑问请联系管理。"); MainHolder.broadcaster.BroadcastToAdminGroup(e.FromQQ + "\n!正在加入舰长群\n不是舰长,拒绝"); } } else { await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "您的QQ没有绑定任何UID,如有疑问请联系管理。"); MainHolder.broadcaster.BroadcastToAdminGroup(e.FromQQ + "\n!正在加入舰长群\n未知QQ,拒绝"); } return; } else { var groups = DataBase.me.whichGroupsAreTheUserIn(e.FromQQ); if (groups.Count > 1) { string gps = ""; foreach (long group in groups) { gps += DataBase.me.getGroupName(group) + "(" + group + ")\n"; } MainHolder.broadcaster.BroadcastToAdminGroup(e.NickName + "(" + e.FromQQ + ") 加入群 " + e.FromGroupName + "(" + e.FromGroup + ") \n,自动拒绝。\n该用户同时加入以下群聊:\n" + gps); await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "已加入其它粉丝群 如有疑问请联系管理"); return; } } { //await MainHolder.session.HandleGroupApplyAsync(e, GroupApplyActions.Allow); MainHolder.broadcaster.BroadcastToAdminGroup(e.FromQQ + "\n不在黑名单,等级条件满足(" + qqlevel + ">=16)\n等待人工处理"); return; } }
public static string genNoSlashUUID(string id, out bool mojang) { return(ThirdPartAPIs.getNoSlashMCUUID(id, out mojang)); }
public PrivMessageSession(JToken json, ThirdPartAPIs sess) { this.sess = sess; init(json); }