feat: send live msg

This commit is contained in:
bggRGjQaUbCoE
2024-11-03 20:45:41 +08:00
parent 0fbfb01b3d
commit 0e5f08b23c
4 changed files with 124 additions and 3 deletions

View File

@@ -283,6 +283,8 @@ class Api {
static const String liveRoomInfo =
'${HttpString.liveBaseUrl}/xlive/web-room/v2/index/getRoomPlayInfo';
static const String sendLiveMsg = '${HttpString.liveBaseUrl}/msg/send';
// 直播间详情 H5
static const String liveRoomInfoH5 =
'${HttpString.liveBaseUrl}/xlive/web-room/v1/index/getH5InfoByRoom';

View File

@@ -1,5 +1,7 @@
import 'package:PiliPalaX/common/constants.dart';
import 'package:PiliPalaX/http/loading_state.dart';
import 'package:PiliPalaX/models/live/danmu_info.dart';
import 'package:dio/dio.dart';
import '../models/live/item.dart';
import '../models/live/room_info.dart';
import '../models/live/room_info_h5.dart';
@@ -25,6 +27,49 @@ class LiveHttp {
}
}
static Future sendLiveMsg({
roomId,
msg,
}) async {
dynamic csrf = await Request.getCsrf();
var res = await Request().post(
Api.sendLiveMsg,
data: {
'bubble': 0,
'msg': msg,
'color': 16777215,
'mode': 1,
'room_type': 0,
'jumpfrom': 71000,
'reply_mid': 0,
'reply_attr': 0,
'replay_dmid': '',
'statistics': Constants.statistics,
'reply_type': 0,
'reply_uname': '',
'fontsize': 25,
'rnd': DateTime.now().millisecondsSinceEpoch ~/ 1000,
'roomid': roomId,
'csrf': csrf,
'csrf_token': csrf,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data'],
};
} else {
return {
'status': false,
'msg': res.data['message'],
};
}
}
static Future liveRoomInfo({roomId, qn}) async {
var res = await Request().get(Api.liveRoomInfo, data: {
'room_id': roomId,