-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLiveManagement.cs
98 lines (90 loc) · 3.06 KB
/
LiveManagement.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
namespace BiliApi
{
/// <summary>
/// Bilibili直播间管理工具类
/// </summary>
public class LiveManagement
{
private readonly BiliLiveRoom blr;
private BiliSession sess;
public LiveManagement(BiliLiveRoom blr)
{
this.blr = blr;
this.sess = blr.sess;
}
[Obsolete("B站官方已停用禁言时长功能,所有封禁将是永久的", false)]
public bool banUID(long uid, int len)
{
return banUID(uid);
}
public bool banUID(long uid)
{
string result = sess.banUIDfromroom(blr.roomid, uid);
JObject jb = (JObject)JsonConvert.DeserializeObject(result);
return (jb.Value<int>("code") == 0);
}
public bool debanBID(int bid)
{
string result = sess.debanBIDfromroom(blr.roomid, bid);
JObject jb = (JObject)JsonConvert.DeserializeObject(result);
return (jb.Value<int>("code") == 0);
}
public List<BiliBannedUser> getBanlist()
{
List<BiliBannedUser> reslist = new List<BiliBannedUser>();
JObject jb;
int page = 1;
do
{
string result = sess.getRoomBanlist(blr.roomid, page);
if (result == null)
{
break;
}
jb = (JObject)JsonConvert.DeserializeObject(result);
if (jb == null || jb["data"] == null)
{
break;
}
foreach (JToken jt in jb["data"])
{
DateTime ctime = jt.Value<DateTime>("ctime");
DateTime be = jt.Value<DateTime>("block_end_time");
DateTime msgt;
try
{
msgt = jt.Value<DateTime>("msg_time");
}
catch
{
msgt = jt.Value<DateTime>("ctime");
}
BiliBannedUser b = new BiliBannedUser()
{
banreason = new BanReason
{
message = jt.Value<string>("msg"),
messagetime = msgt
},
uid = jt.Value<long>("uid"),
id = jt.Value<long>("id"),
op = jt.Value<long>("adminid"),
optime = ctime,
endtime = be,
len = (int)(be - ctime).TotalHours,
opname = jt.Value<string>("admin_uname"),
uname = jt.Value<string>("uname")
};
reslist.Add(b);
}
page++;
} while (jb["data"].Count() > 0);
return reslist;
}
}
}