mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-21 03:15:14 +08:00
live dm action
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,30 +1,60 @@
|
||||
import 'package:PiliPlus/models/model_owner.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_danmaku/live_emote.dart';
|
||||
import 'package:PiliPlus/pages/danmaku/danmaku_model.dart';
|
||||
|
||||
class DanmakuMsg {
|
||||
late String name;
|
||||
late Object uid;
|
||||
late String text;
|
||||
Map<String, BaseEmote>? emots;
|
||||
BaseEmote? uemote;
|
||||
final String name;
|
||||
final Object uid;
|
||||
final String text;
|
||||
final Map<String, BaseEmote>? emots;
|
||||
final BaseEmote? uemote;
|
||||
final LiveDanmaku extra;
|
||||
final Owner? reply;
|
||||
|
||||
DanmakuMsg({
|
||||
const DanmakuMsg({
|
||||
required this.name,
|
||||
required this.uid,
|
||||
required this.text,
|
||||
this.emots,
|
||||
this.uemote,
|
||||
required this.extra,
|
||||
this.reply,
|
||||
});
|
||||
|
||||
DanmakuMsg.fromPrefetch(Map<String, dynamic> obj) {
|
||||
factory DanmakuMsg.fromPrefetch(Map<String, dynamic> obj) {
|
||||
final user = obj['user'];
|
||||
name = user['base']['name'];
|
||||
uid = user['uid'];
|
||||
text = obj['text'];
|
||||
emots = (obj['emots'] as Map<String, dynamic>?)?.map(
|
||||
(k, v) => MapEntry(k, BaseEmote.fromJson(v)),
|
||||
);
|
||||
final uid = user['uid'];
|
||||
BaseEmote? uemote;
|
||||
if ((obj['emoticon']?['emoticon_unique'] as String?)?.isNotEmpty == true) {
|
||||
uemote = BaseEmote.fromJson(obj['emoticon']);
|
||||
}
|
||||
final checkInfo = obj['check_info'];
|
||||
Owner? reply;
|
||||
if (obj['reply'] case final Map map) {
|
||||
final replyMid = map['reply_mid'];
|
||||
if (replyMid != null && replyMid != 0) {
|
||||
reply = Owner(
|
||||
mid: replyMid,
|
||||
name: map['reply_uname'],
|
||||
);
|
||||
}
|
||||
}
|
||||
return DanmakuMsg(
|
||||
name: user['base']['name'],
|
||||
uid: uid,
|
||||
text: obj['text'],
|
||||
emots: (obj['emots'] as Map<String, dynamic>?)?.map(
|
||||
(k, v) => MapEntry(k, BaseEmote.fromJson(v)),
|
||||
),
|
||||
uemote: uemote,
|
||||
extra: LiveDanmaku(
|
||||
id: obj['id_str'],
|
||||
mid: uid,
|
||||
dmType: obj['dm_type'],
|
||||
ts: checkInfo['ts'],
|
||||
ct: checkInfo['ct'],
|
||||
),
|
||||
reply: reply,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user