Files
yusheng-php/application/api/model/Chat.php

132 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\model;
use think\Db;
use think\Log;
use think\Model;
class Chat extends Model
{
//腾讯IM发送消息
public function sendMsg($type,$roomId,$content,$userId = 0)
{
// /// 系统消息
// QXRoomMessageTypeSystem = 1000,
// /// 用户进入房间
// QXRoomMessageTypeJoin = 1001,
// /// 用户退出房间
// QXRoomMessageTypeQuit = 1002,
// /// 用户上麦
// QXRoomMessageTypeUpSeat = 1003,
// /// 用户下麦
// QXRoomMessageTypeDownSeat = 1004,
// /// 房间收到礼物
// QXRoomMessageTypeGift = 1005,
// /// 设置管理员
// QXRoomMessageTypeSetManage = 1006,
// /// 设置主持
// QXRoomMessageTypeSetCompere = 1007,
// /// 禁麦/解禁
// QXRoomMessageTypeSeatMute = 1008,
// /// 锁麦/解除锁麦
// QXRoomMessageTypeSeatLock = 1009,
// /// 踢出房间
// QXRoomMessageTypeTakeOff = 1011,
// /// 房间类型发生变化
// QXRoomMessageTypeRoomTypeChanged = 1012,
// /// 申请点歌/切歌/同意点歌
// QXRoomMessageTypeSwicthSong = 1013,
//房间上麦模式改变
// UpRoomPItType = 1014,
//pk房数值变化
// PkRoomVaule = 1015,
//禁言,禁麦。解禁
// SeatMute = 1016,
//删除管理员
// DeleteManager = 1017,
// 删除主持
// DeleteCompere = 1018,
//K歌房送礼后魅力变化 排序变化
// KRoomGiftChange = 1019,
//修改房间信息
// ModifyRoomInfo = 1020,
//清除房间魅力
// ClearRoomCharm = 1021,
//拍卖者被抱上麦
// AuctionerUpSeat = 1022,
//拍卖者选完关系(拍卖开始)
// AuctionerSelectRelation = 1023,
//参与竞拍
// RoomAuctionJoin = 1024,
//竞拍结束
// RoomAuctionEnd = 1025,
//拍卖延时
// RoomAuctionDelay = 1026,
//竞拍类型转换
// RoomAuctionTypeChange = 1027,
//cp房送礼物推送心动值
// KRoomGiftChange = 1028,
//PK房发起邀请
// RoomAuctionPK = 1029,
//房间PK 拒绝和同意
// RoomAuctionPK = 1030,
//房间PK 开始
// RoomAuctionPK = 1031,
//房间PK 结束
// RoomAuctionPK = 1032,
//房间PK 断开
// RoomAuctionPK = 1033,
//申请上麦
// RoomApplyOnPit = 1034,
//用户修改信息
// ModifyUserInfo = 1035,
//房间在线人数
// RoomOnlineNumber = 1036,
//房间PK 失败者在惩罚阶段提前申请断开链接
// RoomAuctionPK = 1037,
//送盲盒礼物推送文字消息
// RoomGiftBlindBox = 1038,
$text = [
'MsgType' => $type,
'RoomId' => $roomId,
'Text' => $content
];
$data = model('api/Tencent')->send_group_system_notification('room'.$roomId,json_encode($text));
if($data['code'] == 0){
Log::record("腾讯发送群消息:".$data['msg'].$type,"info");
}else{
Log::record("腾讯发送群消息:".$data['msg'].$type,"info");
}
}
//指定用户发送给谁单聊消息
public function sendMsgToUser($userId,$ToUserId,$content,$type = 2000)
{
//type 2000 发起PK
/*
* $text = [
'SendUserId' => $create_user_id,//发送者id
'SendUserName' => db::name('user')->where('id', $create_user_id)->value('nickname'),//发送者昵称
'RoomId' => $room_id_a,//发起者所在房间id
'AcceptRoomId' => $room_id_b,//接受者所在房间id
'Text' => 'PK邀请',
];
*/
$text = [
'MsgType' => $type,
'ToUserId' => $ToUserId,
'Text' => $content
];
//谁发送给谁什么消息是否同步到发送者1是2否消息是否只下发给在线用户 1 是0 否
model('Tencent')->user_sendmsg($userId,$ToUserId,json_encode($text),2,1);
}
}