File tree 1 file changed +23
-3
lines changed
src/EleCho.GoCqHttpSdk/Message 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,27 @@ namespace EleCho.GoCqHttpSdk.Message
9
9
/// </summary>
10
10
public record class CqAtMsg : CqMsg
11
11
{
12
+ /// <summary>
13
+ /// 消息类型: @
14
+ /// </summary>
12
15
public override string MsgType => Consts . MsgType . At ;
13
16
14
17
/// <summary>
15
18
/// 说明: @的 QQ 号, all 表示全体成员
16
19
/// 可能的值: QQ 号, all
17
20
/// </summary>
18
- public long QQ { get ; set ; }
21
+ public long QQ { get ; set ; } = - 1 ;
19
22
23
+ /// <summary>
24
+ /// 名称
25
+ /// </summary>
20
26
public string ? Name { get ; set ; }
21
27
28
+ /// <summary>
29
+ /// 是 AT 全体成员
30
+ /// </summary>
31
+ public bool IsAtAll { get ; set ; }
32
+
22
33
internal CqAtMsg ( )
23
34
{ }
24
35
@@ -27,19 +38,28 @@ public CqAtMsg(long qq)
27
38
QQ = qq ;
28
39
}
29
40
41
+ /// <summary>
42
+ /// 获取 AT 所有人的消息段
43
+ /// </summary>
44
+ public static CqAtMsg AtAll => new CqAtMsg ( ) { IsAtAll = true } ;
45
+
30
46
internal override void ReadDataModel ( CqMsgDataModel ? model )
31
47
{
32
48
CqAtMsgDataModel ? m = model as CqAtMsgDataModel ;
33
49
if ( m == null )
34
50
throw new ArgumentException ( ) ;
35
51
36
- QQ = long . Parse ( m . qq ) ;
52
+ if ( long . TryParse ( m . qq , out long _qq ) )
53
+ QQ = _qq ;
54
+ else if ( m . qq . Equals ( "all" , StringComparison . OrdinalIgnoreCase ) )
55
+ IsAtAll = true ;
56
+
37
57
Name = m . name ;
38
58
}
39
59
40
60
internal override CqMsgDataModel ? GetDataModel ( )
41
61
{
42
- return new CqAtMsgDataModel ( QQ . ToString ( ) , Name ) ;
62
+ return new CqAtMsgDataModel ( IsAtAll ? "all" : QQ . ToString ( ) , Name ) ;
43
63
}
44
64
}
45
65
}
You can’t perform that action at this time.
0 commit comments