1420 lines
93 KiB
Objective-C
1420 lines
93 KiB
Objective-C
//
|
||
// YMRoomMessageParser.m
|
||
// YUMI
|
||
//
|
||
// Created by YUMI on 2021/10/26.
|
||
//
|
||
|
||
#import "XPRoomMessageParser.h"
|
||
|
||
#import <NIMSDK/NIMSDK.h>
|
||
#import <Masonry/Masonry.h>
|
||
///Tool
|
||
#import "ThemeColor+Room.h"
|
||
#import "XPRoomMessageConstant.h"
|
||
#import "AccountInfoStorage.h"
|
||
#import "YUMIMacroUitls.h"
|
||
#import "XPGiftStorage.h"
|
||
#import "XPRoomFaceTool.h"
|
||
#import "TTPopup.h"
|
||
#import "Api+WishGift.h"
|
||
#import "NSArray+Safe.h"
|
||
#import "ClientConfig.h"
|
||
///Model
|
||
#import "XPMessageRemoteExtModel.h"
|
||
#import "AttachmentModel.h"
|
||
#import "GiftReceiveInfoModel.h"
|
||
#import "XPKickUserModel.h"
|
||
#import "MicroQueueModel.h"
|
||
#import "UserInfoModel.h"
|
||
#import "MicroStateModel.h"
|
||
#import "RoomInfoModel.h"
|
||
#import "DatingInfoModel.h"
|
||
#import "RoomFaceInfoModel.h"
|
||
#import "RoomFaceSendInfoModel.h"
|
||
#import "GuildSuperAdminInfoModel.h"
|
||
#import "RoomPKChooseUserModel.h"
|
||
#import "RoomPKInfoModel.h"
|
||
#import "CandyTreeResultModel.h"
|
||
#import "XPGiftBigPrizeModel.h"
|
||
#import "XPGiftCompoundModel.h"
|
||
#import "RoomSailingPrizeModel.h"
|
||
#import "XPOpenRedPacketModel.h"
|
||
#import "XPMessageInfoModel.h"
|
||
#import "XPRoomStarKitchenModel.h"
|
||
#import "TreasureFailryMessageModel.h"
|
||
#import "NetImageView.h"
|
||
|
||
#import "XPUserCardViewController.h"
|
||
#import "XPRoomTopicAlertView.h"
|
||
#import "XPRoomSendTextView.h"
|
||
#import "XPRoomPKResultView.h"
|
||
#import "XPWebViewController.h"
|
||
#import "XCCurrentVCStackManager.h"
|
||
#import "XPTreasureFairyViewController.h"
|
||
#import "PIGeneralPublicScreenModel.h"
|
||
@implementation XPRoomMessageParser
|
||
|
||
|
||
|
||
- (XPMessageInfoModel*)parseMessageAttribute:(NIMMessage *)message {
|
||
NIMMessageType messageType = message.messageType;
|
||
XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init];
|
||
|
||
if([message.messageObject isKindOfClass:[NIMCustomObject class]] ){
|
||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
|
||
if(attachment.isBroadcast == YES){
|
||
return [self makeCustomAttribute:message messageInfo:messageInfo];
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
switch (messageType) {
|
||
case NIMMessageTypeText:
|
||
{
|
||
XPMessageInfoModel *model = [self makeChatAttribute:message messageInfo:messageInfo];
|
||
return model != nil ? model : [XPMessageInfoModel new];
|
||
break;
|
||
}
|
||
case NIMMessageTypeTip:
|
||
{
|
||
XPMessageInfoModel *model = [self makeTipsAttribute:message messageInfo:messageInfo];
|
||
return model != nil ? model : [XPMessageInfoModel new];
|
||
break;
|
||
}
|
||
case NIMMessageTypeNotification:
|
||
{
|
||
XPMessageInfoModel *model = [self makeNotificationAttribute:message messageInfo:messageInfo];
|
||
return model != nil ? model : [XPMessageInfoModel new];
|
||
break;
|
||
}
|
||
case NIMMessageTypeCustom:
|
||
{
|
||
XPMessageInfoModel *model = [self makeCustomAttribute:message messageInfo:messageInfo];
|
||
return model != nil ? model : [XPMessageInfoModel new];
|
||
break;
|
||
}
|
||
default:
|
||
return [XPMessageInfoModel new];
|
||
}
|
||
}
|
||
|
||
- (NSString *)parseMessageBubble:(NIMMessage *)message {
|
||
XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]];
|
||
return model.iosBubbleUrl ? model.iosBubbleUrl : @"";
|
||
}
|
||
|
||
/// 用户公屏聊天
|
||
- (XPMessageInfoModel *)makeCustomAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel*)messageInfo{
|
||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||
XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]];
|
||
messageInfo.bubbleImageUrl = [self parseMessageBubble:message];
|
||
int first = attachment.first;
|
||
int second = attachment.second;
|
||
if (first == CustomMessageType_Gift) {///单人送
|
||
return [self createSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_AllMicroSend) {///全麦送 多人送
|
||
return [self createBatchMicroSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Room_Tip) {///分享/收藏房间
|
||
return [self createShareOrAttentionRoomAttribute:attachment sendInfo:model uid:message.from messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Kick_User || first == CustomMessageType_Queue) {
|
||
XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data];
|
||
return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Look_Love) {//糖果树
|
||
return [self createCandyTreeHighLevelAttribute:attachment messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Arrange_Mic) {
|
||
return [self createArrangeMicAttribute:attachment messageInfo:messageInfo];
|
||
}else if(first == CustomMessageType_Update_RoomInfo) {
|
||
return [self createRoomInfoUpdateAttribute:attachment messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Collection_Room) {
|
||
return [self createCollectRoomAttribute:attachment messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_RoomPlay_Dating) {
|
||
return [self createRoomDatingAttribute:attachment messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_Noble_VIP) {//贵族
|
||
return [self createNobleLevelAttribute:attachment messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_Face) {//贵族
|
||
return [self createRoomFaceAttribute:attachment messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_Tarot) {//塔罗
|
||
return [self createTarotAttribute:attachment messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_Anchor_FansTeam) {//粉丝团
|
||
return [self createAnchorFansTeamAttribute:attachment messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Hall_Super_Admin) {///超管踢人出房间
|
||
XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data];
|
||
return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_Room_PK) {///房内PK
|
||
return [self createRoomPKAttribute:attachment messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_LuckyBag) {///幸运礼物
|
||
return [self createRoomLuckyBigPrizeAttribute:attachment messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Gift_Compound) {///礼物合成
|
||
return [self createRoomGiftCompoundAttribute:attachment messageInfo:messageInfo];
|
||
} else if(first == CustomMessageType_Room_Sailing) {///航海
|
||
return [self createRoomSailingAttribute:attachment messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_OpenRedPacketSuccess) {
|
||
return [self createRedPacketAttribute:attachment messageInfo:messageInfo];
|
||
} else if (first == CustomMessageType_Treasure_Fairy) {
|
||
return [self createTreasureFairyAttribute:attachment messageInfo:messageInfo];
|
||
}else if (first == CustomMessageType_Room_Album) {
|
||
NSDictionary *userInfo = attachment.data[@"user"];
|
||
NSDictionary *userLevel = attachment.data[@"userLevel"];
|
||
if(userLevel != nil){
|
||
NSString *charmUrl = userLevel[@"charmUrl"];
|
||
NSString *experUrl = userLevel[@"experUrl"];
|
||
messageInfo.charmUrl = charmUrl;
|
||
messageInfo.experUrl = experUrl;
|
||
}
|
||
PIRoomPhotoAlbumItemModel *albumModel = [PIRoomPhotoAlbumItemModel modelWithDictionary:attachment.data[@"roomPhoto"]];
|
||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||
NSString * nick = @"";
|
||
if(userInfo != nil){
|
||
nick = [NSString stringWithFormat:@"%@:", userInfo[@"nick"]];
|
||
}
|
||
if ([message.from isEqualToString:uid]) {
|
||
nick = YMLocalizedString(@"XPRoomMessageParser0");
|
||
}
|
||
messageInfo.first = CustomMessageType_Room_Album;
|
||
messageInfo.nameText = nick;
|
||
messageInfo.albumModel = albumModel;
|
||
return messageInfo;
|
||
}else if(first == CustomMessageType_Guardian_Planet){
|
||
return [self createGuardianPlanetAttribute:attachment messageInfo:messageInfo];
|
||
}else if(first == CustomMessageType_General_Public_Screen){
|
||
return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo];
|
||
}
|
||
return nil;
|
||
}
|
||
|
||
/// @param message 消息的实体
|
||
- (XPMessageInfoModel*)makeChatAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||
XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]];
|
||
messageInfo.bubbleImageUrl = [self parseMessageBubble:message];
|
||
NSString * nick = [NSString stringWithFormat:@"%@:", ((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
|
||
if ([message.from isEqualToString:uid]) {
|
||
nick = YMLocalizedString(@"XPRoomMessageParser0");
|
||
}
|
||
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
|
||
if ([ClientConfig shareConfig].canOpen) {
|
||
///官方新用户
|
||
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser fromSayHelloChannel:model.fromSayHelloChannel]];
|
||
if ([self isCurrentRoomSuperAdmin:message.from]) {
|
||
[attribute appendAttributedString:[self createLocalImageAttribute:@"common_super_admin"]];
|
||
}
|
||
|
||
if (model.vipIcon) {//贵族icon
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
if (model.experUrl) {
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:model.experUrl]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
if(model.isCustomWord == YES){
|
||
if (model.inRoomNameplatePic.length > 0){
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
|
||
}else{
|
||
if (model.inRoomNameplatePic.length > 0 && model.inRoomNameplateWord.length > 0) { //铭牌有图片加文字
|
||
[attribute appendAttributedString:[self createNameplateAttibute:model.inRoomNameplateWord image:model.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
} else if (model.inRoomNameplatePic.length > 0) {//铭牌只有图片
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
|
||
id nickNameNifo = message.remoteExt[@"atNames"];
|
||
NSMutableAttributedString *msgStr;
|
||
if (message.text) {
|
||
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
|
||
[msgStr addAttribute:NSForegroundColorAttributeName
|
||
value:[DJDKMIMOMColor messageTextColor]
|
||
range:NSMakeRange(0, msgStr.length)];
|
||
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
|
||
for (NSString *nick in nickNameNifo) {
|
||
NSRange range = [message.text rangeOfString:nick];
|
||
if (range.length) {
|
||
[msgStr yy_setTextHighlightRange:range color:UIColorFromRGB(0xFD85C9) backgroundColor:[UIColor clearColor] userInfo:nil];
|
||
}
|
||
}
|
||
}
|
||
[attribute appendAttributedString:msgStr];
|
||
}
|
||
[self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
/// 房间tips消息
|
||
/// @param message 消息的实体
|
||
- (XPMessageInfoModel*)makeTipsAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
messageInfo.bubbleImageUrl = [self parseMessageBubble:message];
|
||
if ([message.localExt.allKeys containsObject:@"isRoomTopic"]) {
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString: [self createTextAttribute:message.text color:[UIColor whiteColor] font:kRoomMessageDefalutFont]];
|
||
if ([[message.localExt objectForKey:@"isRoomTopic"] boolValue] == YES) {
|
||
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||
TTPopupService * config = [[TTPopupService alloc] init];
|
||
XPRoomTopicAlertView * alertView = [[XPRoomTopicAlertView alloc] init];
|
||
alertView.title = roomInfo.roomDesc;
|
||
alertView.message = roomInfo.introduction;
|
||
config.contentView = alertView;
|
||
[TTPopup popupWithConfig:config];
|
||
}];
|
||
}
|
||
messageInfo.content = attribute;
|
||
} else {
|
||
NSAttributedString * attribute = [self createTextAttribute:message.text color:UIColorFromRGB(0xFE5D7F) font:kRoomMessageDefalutFont];
|
||
messageInfo.content = attribute;
|
||
}
|
||
return messageInfo;
|
||
}
|
||
|
||
/// 房间通知类消息
|
||
/// @param message 消息的实体
|
||
- (XPMessageInfoModel*)makeNotificationAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
messageInfo.bubbleImageUrl = [self parseMessageBubble:message];
|
||
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
|
||
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
|
||
NIMChatroomNotificationMember *member = content.targets[0];
|
||
NIMMessageChatroomExtension * messageExt = (NIMMessageChatroomExtension *)message.messageExt;
|
||
switch (content.eventType) {
|
||
case NIMChatroomEventTypeEnter:///进入房间
|
||
{
|
||
NSString* nick = member.nick.length > 0 ? member.nick : @"";
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
NSDictionary * dic = [(NSDictionary *)messageExt.roomExt.toJSONObject objectForKey:message.from];
|
||
XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithDictionary:dic];
|
||
if ([ClientConfig shareConfig].canOpen) {
|
||
///官方新用户
|
||
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:extModel.defUser newUser:extModel.newUser fromSayHelloChannel:extModel.fromSayHelloChannel]];
|
||
|
||
if ([self isCurrentRoomSuperAdmin:message.from]) {
|
||
[attribute appendAttributedString:[self createLocalImageAttribute:@"common_super_admin"]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
|
||
if (extModel.vipIcon.length > 0) {//贵族icon
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
if (extModel.experUrl.length > 0) {//等级
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.experUrl]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
if(extModel.isCustomWord == YES){
|
||
if (extModel.inRoomNameplatePic.length > 0) {
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.inRoomNameplatePic]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
}else{
|
||
if (extModel.inRoomNameplatePic.length > 0 && extModel.inRoomNameplateWord.length > 0) {
|
||
[attribute appendAttributedString:[self createNameplateAttibute:extModel.inRoomNameplateWord image:extModel.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
}
|
||
|
||
[attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]];
|
||
if (extModel.carName.length > 0) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser1") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:extModel.carName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
|
||
if (extModel.fromType > 0) {
|
||
if (extModel.fromType == UserEnterRoomFromType_Home_Recommend) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser2") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if(extModel.fromType == UserEnterRoomFromType_Follow_User || extModel.fromType == UserEnterRoomFromType_New_User_Greet) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser3") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createNickAtrribute:extModel.fromNick uid:extModel.fromUid.integerValue]];
|
||
} else if(extModel.fromType == UserEnterRoomFromType_Follow_Game_Detail) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser4") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createNickAtrribute:extModel.fromNick uid:extModel.fromUid.integerValue]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser5") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser6") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else {
|
||
[attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser7") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
break;
|
||
case NIMChatroomEventTypeInfoUpdated:{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
if (self.hostDelegate.getRoomInfo.datingState == RoomDatingStateChangeType_Open) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser8") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
return nil;
|
||
}
|
||
return nil;
|
||
}
|
||
#pragma mark - 夺宝精灵
|
||
- (XPMessageInfoModel *)createTreasureFairyAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
TreasureFailryMessageModel *info = [TreasureFailryMessageModel modelWithDictionary:attachment.data];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L3) {///初级礼物
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser115") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
|
||
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
|
||
[attribute appendAttributedString:nickAttriibute];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
if (info.rewardNum > 1) {
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"X%ld", info.rewardNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5) {///高级礼物
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser117") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
|
||
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
|
||
[attribute appendAttributedString:nickAttriibute];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
if (info.rewardNum > 1) {
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"X%ld", info.rewardNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L1) {///初级球
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser115") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
|
||
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
|
||
[attribute appendAttributedString:nickAttriibute];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L3) {///高级球
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser117") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
|
||
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
|
||
[attribute appendAttributedString:nickAttriibute];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3) {///合成礼物
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser115") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
|
||
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
|
||
[attribute appendAttributedString:nickAttriibute];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
if(attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser119") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser120") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
} else {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser121") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser122") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%ld", info.rewardShowValue] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
if ([info.rewardType isEqualToString:@"gift"]){
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser123") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
} else {
|
||
[attribute appendAttributedString:[self createTextAttribute:info.rewardUnit color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
if (self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq >= info.userLevelLimit) {
|
||
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser124") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
|
||
@kWeakify(self);
|
||
[nickAttriibute yy_setTextHighlightRange:NSMakeRange(0, nickAttriibute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
|
||
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
|
||
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
||
fairyVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||
[self.hostDelegate.getCurrentNav presentViewController:fairyVC animated:YES completion:nil];
|
||
}];
|
||
[attribute appendAttributedString:nickAttriibute];
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
#pragma mark -星级厨房
|
||
//- (NSAttributedString *)createStarKitchenAttribute:(AttachmentModel *)attachment{
|
||
// XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attachment.data];
|
||
// NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser103"),starModel.nick,starModel.itemMultiple,starModel.diamonds];
|
||
// NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor messageDefaultTextColor]}];
|
||
// [attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageNickColor]} range:[title rangeOfString:starModel.nick]];
|
||
// [attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.itemMultiple]]];
|
||
// [attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.diamonds]]];
|
||
// @kWeakify(self)
|
||
// [attribute yy_setTextHighlightRange:[title rangeOfString:starModel.nick] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
// @kStrongify(self);
|
||
// if (starModel.uid.integerValue <= 0) {return;}
|
||
// [self showUserCard:starModel.uid.integerValue];
|
||
// }];
|
||
//
|
||
// return attribute;
|
||
//}
|
||
|
||
- (XPMessageInfoModel *)createGeneralPublicScreenAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
|
||
PIGeneralPublicScreenModel *screenModel = [PIGeneralPublicScreenModel modelWithDictionary:attachment.data];
|
||
NSDictionary *textDic = screenModel.template;
|
||
if(textDic.allKeys.count == 0)return messageInfo;
|
||
NSString *title = textDic[@"zh-CHT"] == nil ? textDic[textDic.allKeys.firstObject] : textDic[@"zh-CHT"];
|
||
|
||
if(title.length == 0)return messageInfo;
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:screenModel.textColor]}];
|
||
for (PIGeneralPublicScreenItemModel *model in screenModel.contents) {
|
||
if([model.type isEqualToString:@"TEXT"]){
|
||
NSDictionary *subTextDic = model.text;
|
||
if(subTextDic.allKeys.count > 0){
|
||
NSString *subText = subTextDic[@"zh-CHT"] == nil ? subTextDic[subTextDic.allKeys.firstObject] : subTextDic[@"zh-CHT"];
|
||
NSAttributedString *attText = [[NSAttributedString alloc]initWithString:subText attributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:model.textColor]}];
|
||
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attText];
|
||
|
||
@kWeakify(self)
|
||
[attribute yy_setTextHighlightRange:[attribute.string rangeOfString:subText] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
if(model.skipType == 6){
|
||
if(model.skipContent.length == 0)return;
|
||
[self showUserCard:model.skipContent.integerValue];
|
||
}
|
||
}];
|
||
}
|
||
|
||
}else if ([model.type isEqualToString:@"IMAGE"]){
|
||
NSMutableAttributedString *attImage = [self createUrlImageAttribute:model.image size:CGSizeMake(model.width, model.height)];
|
||
[attImage appendAttributedString:[self createSapceAttribute:2]];
|
||
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attImage];
|
||
}
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
- (XPMessageInfoModel *)createGuardianPlanetAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attachment.data];
|
||
NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser1033334"),starModel.nick,starModel.diamonds];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor messageDefaultTextColor]}];
|
||
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageNickColor]} range:[title rangeOfString:starModel.nick]];
|
||
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@"%@",starModel.diamonds]]];
|
||
@kWeakify(self)
|
||
[attribute yy_setTextHighlightRange:[title rangeOfString:starModel.nick] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
if (starModel.uid.integerValue <= 0) {return;}
|
||
[self showUserCard:starModel.uid.integerValue];
|
||
}];
|
||
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
|
||
- (XPMessageInfoModel *)createStarredKitchenAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attachment.data];
|
||
NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser1033333"),starModel.nick,starModel.itemMultiple,starModel.diamonds];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor messageDefaultTextColor]}];
|
||
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageNickColor]} range:[title rangeOfString:starModel.nick]];
|
||
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.itemMultiple]]];
|
||
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.diamonds]]];
|
||
@kWeakify(self)
|
||
[attribute yy_setTextHighlightRange:[title rangeOfString:starModel.nick] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
if (starModel.uid.integerValue <= 0) {return;}
|
||
[self showUserCard:starModel.uid.integerValue];
|
||
}];
|
||
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
#pragma mark - 红包
|
||
- (XPMessageInfoModel *)createRedPacketAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
XPOpenRedPacketModel *info = [XPOpenRedPacketModel modelWithDictionary:attachment.data];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.openRedEnvelopeUserNick uid:info.openRedEnvelopeId.integerValue]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser9") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.redEnvelopeMasterNick uid:info.redEnvelopeMasterId.integerValue]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser10") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
if (info.amount.floatValue>0) {
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser11"), info.amount] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 航海
|
||
- (XPMessageInfoModel *)createRoomSailingAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
RoomSailingPrizeModel *info = [RoomSailingPrizeModel modelWithDictionary:attachment.data];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomCandyGiftView0") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser13") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.prizeName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
if (info.prizeNum>1) {
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"x%d", info.prizeNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
[self attributeAddHihtLight:attribute uid:info.uid.integerValue];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 礼物合成
|
||
- (XPMessageInfoModel *)createRoomGiftCompoundAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
XPGiftCompoundModel *info = [XPGiftCompoundModel modelWithDictionary:attachment.data];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser14") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.msg color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.giftName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[self attributeAddHihtLight:attribute uid:info.uid.integerValue];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 房间内幸运礼物 大价值
|
||
- (XPMessageInfoModel *)createRoomLuckyBigPrizeAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
XPGiftBigPrizeModel * info= [XPGiftBigPrizeModel modelWithDictionary:attachment.data];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser15") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser16") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:info.roomTitle color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser17"), info.luckyBagName] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser18" ), info.giftName] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 房间内PK
|
||
- (XPMessageInfoModel *)createRoomPKAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
if (attachment.second == Custom_Message_Sub_Room_PK_Manager_Up_Mic) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser19") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
for (NSDictionary * selectuUser in [attachment.data allValues]) {
|
||
RoomPKChooseUserModel * userInfoModel = [RoomPKChooseUserModel modelWithDictionary:selectuUser];
|
||
if (userInfoModel.groupType != GroupType_default && userInfoModel.nick.length > 0) {
|
||
[attribute appendAttributedString:[self createNickAtrribute:userInfoModel.nick uid:userInfoModel.uid.integerValue]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser20") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
NSString * groupTypeStr;
|
||
UIColor * groupColor;
|
||
if (userInfoModel.groupType == GroupType_Red) {
|
||
groupTypeStr= YMLocalizedString(@"XPRoomMessageParser21");
|
||
groupColor = UIColorFromRGB(0xFB3D74);
|
||
}else{
|
||
groupTypeStr = YMLocalizedString(@"XPRoomMessageParser22");
|
||
groupColor = UIColorFromRGB(0x3291FC);
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:groupTypeStr color:groupColor font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:@"," color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}
|
||
[attribute deleteCharactersInRange:NSMakeRange(attribute.string.length - 1, 1)];
|
||
} else {
|
||
RoomPKInfoModel * model = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||
if (attachment.second == Custom_Message_Sub_Room_PK_Mode_Close) {
|
||
NSString * title = YMLocalizedString(@"XPRoomMessageParser23");
|
||
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
NSRange range = [title rangeOfString:YMLocalizedString(@"XPRoomMessageParser24")];
|
||
[attribute addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor messageDefaultTextColor] range:range];
|
||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Result) {
|
||
NSString * victoryStr;
|
||
if (model.result == RoomPKResultType_Draw) {
|
||
RoomPKTeamModel * blueTeam;
|
||
RoomPKTeamModel * redTeam;
|
||
for (int i = 0 ; i < model.teams.count; i++) {
|
||
RoomPKTeamModel * team = [model.teams safeObjectAtIndex1:i];
|
||
if (team.team == GroupType_Red) {
|
||
redTeam = team;
|
||
}else{
|
||
blueTeam = team;
|
||
}
|
||
}
|
||
RoomPKTeamModel * team = [model.teams firstObject];
|
||
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
|
||
victoryStr = YMLocalizedString(@"XPRoomMessageParser25");
|
||
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
|
||
NSString * result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser26"),victoryStr, resultScale];
|
||
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}else{
|
||
if (team.protecScore > 0) {
|
||
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
|
||
victoryStr = YMLocalizedString(@"XPRoomMessageParser27");
|
||
NSString * result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser28"),victoryStr, resultScale];
|
||
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}else{
|
||
victoryStr = YMLocalizedString(@"XPRoomMessageParser29");
|
||
NSString * result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser28"),victoryStr, @"0:0"];
|
||
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}
|
||
if (team.protector > 0) {
|
||
[attribute appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"\n"]];
|
||
NSString * teamStr = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser31"), blueTeam.protector.nick.length > 0 ? blueTeam.protector.nick : @"", [[NSNumber numberWithLongLong:blueTeam.protecScore] stringValue], redTeam.protector.nick.length > 0 ? redTeam.protector.nick : @"", [[NSNumber numberWithLongLong:redTeam.protecScore] stringValue]];
|
||
[attribute appendAttributedString:[self createTextAttribute:teamStr color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}else{
|
||
RoomPKTeamModel * victoryTeam;
|
||
RoomPKTeamModel * failTeam;
|
||
for (int i = 0 ; i < model.teams.count; i++) {
|
||
RoomPKTeamModel * team = [model.teams safeObjectAtIndex1:i];
|
||
if (team.team == (GroupType)model.result) {
|
||
victoryTeam = team;
|
||
}else{
|
||
failTeam = team;
|
||
}
|
||
}
|
||
if (model.result == RoomPKResultType_Red){
|
||
victoryStr = YMLocalizedString(@"XPRoomMessageParser32");
|
||
}else if (model.result == RoomPKResultType_Blue){
|
||
victoryStr = YMLocalizedString(@"XPRoomMessageParser33");
|
||
}
|
||
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", victoryTeam.score],[NSString stringWithFormat:@"%lld", failTeam.score]];
|
||
NSString * result;
|
||
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
|
||
result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser34"),victoryStr, resultScale,[NSNumber numberWithLongLong:victoryTeam.score]];
|
||
}else{
|
||
if (victoryTeam.protector) {
|
||
NSString * victoryProteror = victoryTeam.protector.nick.length > 0 ? victoryTeam.protector.nick : @"";
|
||
result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser35"),victoryStr, resultScale,victoryStr, victoryProteror, victoryStr,[[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
|
||
}else{
|
||
result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser36"),victoryStr, resultScale,victoryStr,[[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
|
||
}
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
|
||
@kWeakify(self);
|
||
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
[self showRoomPKResult:attachment.data];
|
||
}];
|
||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Open) {
|
||
NSString * pkType;
|
||
if (model.voteMode == RoomPKVoteModeType_GiftValue) {
|
||
pkType = YMLocalizedString(@"XPRoomMessageParser37");
|
||
}else if (model.voteMode == RoomPKVoteModeType_NumberPerson){
|
||
pkType = YMLocalizedString(@"XPRoomMessageParser38");
|
||
}
|
||
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser114"), model.duration, pkType];
|
||
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}else if (attachment.second == Custom_Message_Sub_Room_PK_Start){
|
||
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser40"), model.duration];
|
||
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}else if (attachment.second == Custom_Message_Sub_Room_PK_Re_Start){
|
||
NSString * pkType;
|
||
if (model.voteMode == RoomPKVoteModeType_GiftValue) {
|
||
pkType = YMLocalizedString(@"XPRoomMessageParser41");
|
||
}else if (model.voteMode == RoomPKVoteModeType_NumberPerson){
|
||
pkType = YMLocalizedString(@"XPRoomMessageParser42");
|
||
}
|
||
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser43"), model.duration, pkType];
|
||
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
- (void)showRoomPKResult:(NSDictionary *)dic {
|
||
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:dic];
|
||
if (pkInfo.pkStatus == RoomPKStatusType_End || pkInfo.pkStatus == RoomPKStatusType_ReStart) {
|
||
XPRoomPKResultView * result = [[XPRoomPKResultView alloc] init];
|
||
result.roomPKResultInfoModel = pkInfo;
|
||
[TTPopup popupView:result style:TTPopupStyleAlert];
|
||
}
|
||
}
|
||
|
||
#pragma mark - 表情显示
|
||
- (XPMessageInfoModel*)createRoomFaceAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
if ([attachment.data[@"data"] isKindOfClass:[NSArray class]]) {
|
||
NSArray * array = [RoomFaceSendInfoModel modelsWithArray:attachment.data[@"data"]];
|
||
for (int i = 0; i< array.count; i++) {
|
||
RoomFaceSendInfoModel * sendFaceInfo = [array safeObjectAtIndex1:i];
|
||
[attribute appendAttributedString:[self createTextAttribute:sendFaceInfo.nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:@":" color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:@"\n" color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
for (int j = 0; j < sendFaceInfo.resultIndexes.count; j++) {
|
||
NSNumber *index = sendFaceInfo.resultIndexes[j];
|
||
UIImage *face = [[XPRoomFaceTool shareFaceTool] findFaceImageById:sendFaceInfo.faceId index:[index integerValue]];
|
||
if (face) {
|
||
UIImageView *imageView = [[UIImageView alloc]init];
|
||
imageView.image = face;
|
||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
imageView.bounds = CGRectMake(0, 0, 30, 30);
|
||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||
[attribute appendAttributedString:[self createSapceAttribute:1]];
|
||
[attribute appendAttributedString:attrString];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 收藏房间
|
||
- (XPMessageInfoModel*)createCollectRoomAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
NSDictionary *data = attachment.data[@"data"];
|
||
NSString *nick = [NSString stringWithFormat:@"%@",data[@"nick"]];
|
||
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
NSString *tipString = @"";
|
||
if (attachment.second == Custom_Message_Sub_Collect_Room_Tips) {
|
||
tipString = YMLocalizedString(@"XPRoomMessageParser44");
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:tipString color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 房间信息更新
|
||
- (XPMessageInfoModel*)createRoomInfoUpdateAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
if (attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
|
||
NSDictionary * dic= attachment.data[@"roomInfo"];
|
||
if (dic.allKeys.count <=0) {
|
||
dic = attachment.data;
|
||
}
|
||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser45") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
if (roomInfo.isCloseScreen) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser46") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
} else {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser47") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
messageInfo.content = attribute;
|
||
} else if(attachment.second == Custom_Message_Sub_Update_RoomInfo_AnimateEffect) {
|
||
NSDictionary * dic = attachment.data[@"roomInfo"];
|
||
if (dic.allKeys.count <=0) {
|
||
dic = attachment.data;
|
||
}
|
||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser45") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
if (roomInfo.hasAnimationEffect) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser49") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
} else {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser50") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createImageAttribute:[UIImage imageNamed:@"room_menu_more"]]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser51") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
messageInfo.content = attribute;
|
||
} else if (attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
|
||
NSNumber *roleType = attachment.data[@"roleType"];
|
||
NSString *nick = attachment.data[@"nick"];
|
||
NSInteger uid = 0;
|
||
if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) {
|
||
uid = ((NSNumber *)attachment.data[@"uid"]).integerValue;
|
||
} else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) {
|
||
uid = ((NSString *)attachment.data[@"uid"]).integerValue;
|
||
}
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser45") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
if (roleType.integerValue == 1) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser53") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
} else if (roleType.integerValue == 2) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser54") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser55") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[self attributeAddHihtLight:attribute uid:uid];
|
||
messageInfo.content = attribute;
|
||
}
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 相亲
|
||
- (XPMessageInfoModel *)createRoomDatingAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
if(attachment.second == Custom_Message_Sub_Room_Play_Dating_Pick_Heart) {
|
||
DatingInfoModel * datingModel = [DatingInfoModel modelWithDictionary:attachment.data];
|
||
NSString * targetGender = datingModel.targetGender == GenderType_Male ? YMLocalizedString(@"XPSessionFindNewFiltrateView2") : YMLocalizedString(@"XPRoomMessageParser57");
|
||
NSString * pickString = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser58"), (datingModel.targetPosition + 1), targetGender];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser59") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:pickString color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
NSString * targetNick = datingModel.targetNickname ? datingModel.targetNickname : @"";
|
||
[attribute appendAttributedString:[self createNickAtrribute:targetNick uid:datingModel.targetUid]];
|
||
NSString * heartContent = YMLocalizedString(@"XPRoomMessageParser60");
|
||
[attribute appendAttributedString:[self createTextAttribute:heartContent color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if(attachment.second == Custom_Message_Sub_Room_Play_Dating_Result_Mutual) {///互选
|
||
DatingInfoModel * datingModel = [DatingInfoModel modelWithDictionary:attachment.data];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser61") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
NSString * nick = datingModel.nickname ? datingModel.nickname : @"";
|
||
[attribute appendAttributedString:[self createNickAtrribute:nick uid:datingModel.uid]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser62") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
NSString * targetNick = datingModel.targetNickname ? datingModel.targetNickname : @"";
|
||
[attribute appendAttributedString:[self createNickAtrribute:targetNick uid:datingModel.targetUid]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser63") color:[UIColor whiteColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Room_Play_Dating_Result_Not_Mutual) {///不是互选
|
||
DatingInfoModel * datingModel = [DatingInfoModel modelWithDictionary:attachment.data];
|
||
NSString * nick = datingModel.nickname ? datingModel.nickname : @"";
|
||
[attribute appendAttributedString:[self createNickAtrribute:nick uid:datingModel.uid]];
|
||
if (datingModel.hasSelectUser) {//选择的有人
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser64") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
NSString * targetNick = datingModel.targetNickname ? datingModel.targetNickname : @"";
|
||
[attribute appendAttributedString:[self createNickAtrribute:targetNick uid:datingModel.targetUid]];
|
||
} else {///没有选择人
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser65") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 排麦
|
||
- (XPMessageInfoModel *)createArrangeMicAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser66") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
if (attachment.second == Custom_Message_Sub_Arrange_Mic_Mode_Open) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser67") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser68") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Arrange_Mic_Mode_Close) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser69") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser70") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Arrange_Mic_Free_Mic_Open) {
|
||
NSDictionary * dic = attachment.data;
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser71") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser72"), ((NSNumber *)dic[@"micPos"]).intValue + 1 ] color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser73") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Arrange_Mic_Free_Mic_Close) {
|
||
NSDictionary * dic = attachment.data;
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser74") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser75"), ((NSNumber *)dic[@"micPos"]).intValue + 1 ] color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser76") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 糖果树公屏消息
|
||
- (XPMessageInfoModel *)createCandyTreeHighLevelAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
//action
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser77") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
CandyTreeGiftInfoModel * giftInfo = [CandyTreeGiftInfoModel modelWithDictionary:attachment.data];
|
||
[attribute appendAttributedString:[self createTextAttribute:giftInfo.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser78") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:giftInfo.prizeName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
if (giftInfo.prizeNum > 1) {
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X %d", giftInfo.prizeNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
|
||
if (attachment.second == Custom_Message_Sub_Candy_Tree_Me && giftInfo.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser79") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
|
||
[self attributeAddHihtLight:attribute uid:giftInfo.uid.integerValue];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 贵族
|
||
- (XPMessageInfoModel *)createNobleLevelAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
NSInteger uid = 0;
|
||
if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) {
|
||
uid = ((NSNumber *)attachment.data[@"uid"]).integerValue;
|
||
} else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) {
|
||
uid = ((NSString *)attachment.data[@"uid"]).integerValue;
|
||
}
|
||
if (attachment.second == Custom_Message_Sub_Room_Open_Noble_VIP) {/// 开通贵族房内消息 851
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser80") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%@(%@)", attachment.data[@"nick"], attachment.data[@"erbanNo"]] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser81") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"currVipName"] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser82") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_Room_Noble_LevelUp || attachment.second == Custom_Message_Sub_AllRoom_Noble_LevelUp_Suspend) {///贵族升级
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser83") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"nick"] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser84") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"currVipName"] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:@"!" color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
[self attributeAddHihtLight:attribute uid:uid];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 塔罗
|
||
- (XPMessageInfoModel *)createTarotAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
if (attachment.second == Custom_Message_Sub_Tarot_Novice || attachment.second == Custom_Message_Sub_Tarot_Advanced || attachment.second == Custom_Message_Sub_Tarot_Intermediate) {
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser85") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"nick"] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
NSString *text = [NSString stringWithFormat:@" %@", YMLocalizedString(@"XPRoomMessageParser125")];
|
||
[attribute appendAttributedString:[self createTextAttribute:text color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
if ([attachment.data[@"drawGoldNum"] intValue] > 1) {
|
||
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%d",[attachment.data[@"drawGoldNum"] intValue]] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPNobleCenterPayView1") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 个播粉丝团
|
||
- (XPMessageInfoModel *)createAnchorFansTeamAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
NSInteger uid = 0;
|
||
if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) {
|
||
uid = ((NSNumber *)attachment.data[@"uid"]).integerValue;
|
||
} else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) {
|
||
uid = ((NSString *)attachment.data[@"uid"]).integerValue;
|
||
}
|
||
NSString *idString = [NSString stringWithFormat:@"%ld", uid];
|
||
NSString *nickName = attachment.data[@"nickname"];
|
||
if ([idString isEqualToString:[[AccountInfoStorage instance] getUid]]) {
|
||
nickName = YMLocalizedString(@"XPRoomMessageParser86");
|
||
}
|
||
if (attachment.second == Custom_Message_Sub_FansTeam_Open_Success) {/// 开通粉丝团成功
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser87") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:nickName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser88") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_FansTeam_Join_Success) {///加入粉丝团
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser89") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:nickName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser90") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if (attachment.second == Custom_Message_Sub_FansTeam_Out_Success) {//退出粉丝团
|
||
[attribute appendAttributedString:[self createTextAttribute:nickName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser91") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
[self attributeAddHihtLight:attribute uid:uid];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 踢出房间/拉黑/下麦
|
||
- (XPMessageInfoModel *)createKickUserAttribute:(AttachmentModel *)attachment info:(XPKickUserModel *)info messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.targetNick uid:info.targetUid]];
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser92") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.handleNick uid:info.handleUid]];
|
||
NSString * content= @"";
|
||
if (attachment.second == Custom_Message_Sub_Kick_BeKicked || attachment.second == Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room) {
|
||
content = YMLocalizedString(@"XPRoomMessageParser93");
|
||
} else if(attachment.second == Custom_Message_Sub_Kick_BlackList) {
|
||
content = YMLocalizedString(@"XPRoomMessageParser94");
|
||
} else if(attachment.second == Custom_Message_Sub_Queue_Kick) {
|
||
content = YMLocalizedString(@"XPRoomMessageParser95");
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:content color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
|
||
#pragma mark - 分享房间
|
||
- (XPMessageInfoModel *)createShareOrAttentionRoomAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo uid:(NSString *)uid messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
NSDictionary *data = attachment.data;
|
||
NSString *nick = [NSString stringWithFormat:@"%@",data[@"data"][@"nick"]];
|
||
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
NSString *tipString = @"";
|
||
if (attachment.second == Custom_Message_Sub_Room_Tip_ShareRoom) {
|
||
tipString = YMLocalizedString(@"XPRoomMessageParser96");
|
||
}else if (attachment.second == Custom_Message_Sub_Room_Tip_Attention_Owner) {
|
||
tipString = YMLocalizedString(@"XPRoomMessageParser97");
|
||
}
|
||
[attribute appendAttributedString:[self createTextAttribute:tipString color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[self attributeAddHihtLight:attribute uid:uid.integerValue];
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - 送礼物的公屏
|
||
- (XPMessageInfoModel *)createBatchMicroSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
GiftReceiveInfoModel *info = [GiftReceiveInfoModel modelWithJSON:attachment.data];
|
||
GiftInfoModel *giftInfo = info.gift == nil ? info.giftInfo : info.gift;
|
||
if (giftInfo == nil) {
|
||
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:info.giftId];
|
||
}
|
||
///官方新用户
|
||
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser fromSayHelloChannel:sendInfo.fromSayHelloChannel]];
|
||
//nick
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.nick uid:info.uid.integerValue]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
if (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroSend) {///普通礼物
|
||
if (attachment.second == Custom_Message_Sub_AllBatchSend) {
|
||
//打赏
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser98") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
for (int i = 0; i < info.targetUsers.count; i++) {
|
||
GiftReceiveUserInfoModel *targetInfo = [info.targetUsers safeObjectAtIndex1:i];
|
||
//nick
|
||
[attribute appendAttributedString:[self createNickAtrribute:targetInfo.nick uid:targetInfo.uid]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
if (i < (info.targetUsers.count -1)) {
|
||
//nick
|
||
[attribute appendAttributedString:[self createTextAttribute:@"," color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
}
|
||
} else {
|
||
//打赏
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser99") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
|
||
//img
|
||
if (giftInfo.giftUrl) {
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
|
||
//x N
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X%ld",info.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
} else if(attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend) {///福袋礼物
|
||
//action
|
||
NSString * sendTitle = YMLocalizedString(@"XPRoomMessageParser100");
|
||
if (attachment.second == Custom_Message_Sub_AllMicroLuckySend) {
|
||
sendTitle = YMLocalizedString(@"XPRoomMessageParser101");
|
||
}
|
||
//打赏
|
||
[attribute appendAttributedString:[self createTextAttribute:sendTitle color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
|
||
// 福袋名称
|
||
[attribute appendAttributedString:[self createTextAttribute:info.giftName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
|
||
// 福袋名称
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser102") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
if (info.luckyGiftList) {
|
||
//target
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.luckyGiftList.user.nick uid:info.luckyGiftList.user.uid]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
|
||
// 福袋名称
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser103") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
|
||
[info.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
|
||
GiftInfoModel *luckGiftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
|
||
// 价值
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser104") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
// 礼物价格
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%ld",(NSInteger)luckGiftInfo.goldPrice] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
// 的礼物
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser105") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
//img
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:luckGiftInfo.giftUrl]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
|
||
//x N
|
||
[attribute appendAttributedString:[self createTextAttribute: [NSString stringWithFormat:@" X%ld",giftListInfo.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
if (info.luckyGiftList.giftList.count-1 != idx) {
|
||
//,
|
||
[attribute appendAttributedString:[self createTextAttribute:@"," color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}];
|
||
}
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
- (XPMessageInfoModel *)createSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo messageInfo:(XPMessageInfoModel *)messageInfo{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
GiftReceiveInfoModel *info = [GiftReceiveInfoModel modelWithJSON:attachment.data];
|
||
GiftInfoModel *giftInfo = info.gift == nil ? info.giftInfo : info.gift;
|
||
if (giftInfo == nil) {
|
||
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:info.giftId];
|
||
}
|
||
///官方新用户
|
||
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser fromSayHelloChannel:sendInfo.fromSayHelloChannel]];
|
||
//nick
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.nick uid:info.uid.integerValue]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];;
|
||
if (attachment.second == Custom_Message_Sub_Gift_LuckySend) {
|
||
//action
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser106") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
// 福袋名称
|
||
[attribute appendAttributedString:[self createTextAttribute:info.giftName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser107") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
//target
|
||
[attribute appendAttributedString:[self createNickAtrribute:info.luckyGiftList.user.nick uid:info.luckyGiftList.user.uid]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
//lucky
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser108") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[info.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
|
||
GiftInfoModel *luckyGiftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
|
||
// 价值
|
||
[attribute appendAttributedString: [self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser109") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
// 礼物价格
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%ld",(NSInteger)luckyGiftInfo.goldPrice] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
// 的礼物
|
||
[attribute appendAttributedString: [self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser110") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
//img
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:luckyGiftInfo.giftUrl]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
//x N
|
||
[attribute appendAttributedString:[self createTextAttribute: [NSString stringWithFormat:@" X%ld",giftListInfo.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
if (info.luckyGiftList.giftList.count-1 != idx) {
|
||
//,
|
||
[attribute appendAttributedString: [self createTextAttribute:@"," color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
}];
|
||
} else {
|
||
//打赏
|
||
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser111") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
//target
|
||
[attribute appendAttributedString: [self createNickAtrribute:info.targetNick uid:info.targetUid.integerValue]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
//img
|
||
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
//x N
|
||
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X%ld",info.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
|
||
}
|
||
messageInfo.content = attribute;
|
||
return messageInfo;
|
||
}
|
||
|
||
#pragma mark - Commond Mehotd
|
||
///用户是否当前房间的超管
|
||
- (BOOL)isCurrentRoomSuperAdmin:(NSString *)uid {
|
||
for (GuildSuperAdminInfoModel *info in self.hostDelegate.getRoomSuperAdminList) {
|
||
if ([info.uid isEqualToString:uid]) {
|
||
return YES;
|
||
}
|
||
}
|
||
return NO;
|
||
}
|
||
|
||
- (NSAttributedString *)createOfficalAndNewuserAttribute:(UserLevelType)levelType newUser:(BOOL)newUser fromSayHelloChannel:(BOOL)fromSayHelloChannel{
|
||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||
//offical
|
||
if (levelType == UserLevelType_Offical) {
|
||
[attribute appendAttributedString: [self createLocalImageAttribute:@"common_offical"]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
if (newUser) {
|
||
if (fromSayHelloChannel) {
|
||
[attribute appendAttributedString:[self createLocalImageAttribute:@"room_new_user_greet_new"]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
} else {
|
||
[attribute appendAttributedString: [self createLocalImageAttribute:@"common_new_user"]];
|
||
[attribute appendAttributedString:[self createSapceAttribute:2]];
|
||
}
|
||
}
|
||
return attribute;
|
||
}
|
||
|
||
///名字点击的
|
||
- (NSMutableAttributedString *)createNickAtrribute:(NSString *)nick uid:(NSInteger)uid {
|
||
NSMutableAttributedString * attribute = [self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
|
||
[self attributeAddHihtLight:attribute uid:uid];
|
||
return attribute;
|
||
}
|
||
|
||
- (void)attributeAddHihtLight:(NSMutableAttributedString *)attribute uid:(NSInteger)uid {
|
||
@kWeakify(self);
|
||
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
if (uid <= 0) {return;}
|
||
[self showUserCard:uid];
|
||
}];
|
||
}
|
||
|
||
- (void)attributeAddLongPressHihtLight:(NSMutableAttributedString *)attribute uid:(NSString *)uid nick:(NSString *)nick {
|
||
@kWeakify(self);
|
||
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
if (uid <= 0) {return;}
|
||
[self showUserCard:uid.integerValue];
|
||
} longPressAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
@kStrongify(self);
|
||
if ([uid isEqualToString:[AccountInfoStorage instance].getUid] || uid.length < 1) {
|
||
return;
|
||
}
|
||
UIViewController *vc = self.hostDelegate.getCurrentNav.viewControllers[0];
|
||
[XPRoomSendTextView showTextView:vc.view delegate:self.hostDelegate atUid:uid atNick:nick];
|
||
}];
|
||
}
|
||
|
||
|
||
- (void)showUserCard:(NSInteger)uid {
|
||
if (![ClientConfig shareConfig].canOpen) {
|
||
return;
|
||
}
|
||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||
NSString * targetUid = [NSString stringWithFormat:@"%ld", uid];
|
||
XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init];
|
||
[[self.hostDelegate.getMicroQueue allValues] enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||
if (uid == obj.userInfo.uid) {
|
||
model.position = [NSString stringWithFormat:@"%d", obj.microState.position];
|
||
model.posState = obj.microState.posState;
|
||
model.micState = obj.microState.micState;
|
||
*stop = YES;
|
||
}
|
||
}];
|
||
model.nick = self.hostDelegate.getUserInfo.nick;
|
||
model.uid = targetUid;
|
||
model.micQueue = self.hostDelegate.getMicroQueue;
|
||
model.roomInfo = roomInfo;
|
||
model.delegate = self.hostDelegate;
|
||
model.superMangerList = self.hostDelegate.getRoomSuperAdminList;
|
||
XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model];
|
||
[self.hostDelegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil];
|
||
}
|
||
|
||
#pragma mark - private base methods
|
||
///铭牌
|
||
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName image:(NSString *)imageName textFont:(UIFont *)textFont {
|
||
NetImageConfig *config = [[NetImageConfig alloc]init];
|
||
///先这样吧
|
||
config.autoLoad = YES;
|
||
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageName config:config];
|
||
UIImage* image = imageView.image;
|
||
if (image) {
|
||
CGFloat scale = image.size.width / image.size.height;
|
||
imageView.bounds = CGRectMake(0, 0, 18 * scale, 18);
|
||
} else {
|
||
// NSURL *imgUrl = [NSURL URLWithString:imageName];
|
||
// UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
||
// if (myImage) {
|
||
// CGFloat scale = myImage.size.width / myImage.size.height;
|
||
// if (scale == 0) {
|
||
// imageView.bounds = CGRectMake(0, 0, 60, 18);
|
||
// }else {
|
||
// imageView.bounds = CGRectMake(0, 0, 18* scale, 18);
|
||
// }
|
||
// } else {
|
||
imageView.bounds = CGRectMake(0, 0, 60, 18);
|
||
// }
|
||
}
|
||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
// 铭牌文字
|
||
UILabel *label = [[UILabel alloc] init];
|
||
label.textAlignment = NSTextAlignmentCenter;
|
||
label.font = [UIFont boldSystemFontOfSize:12];
|
||
label.adjustsFontSizeToFitWidth = YES;
|
||
label.textColor = UIColor.whiteColor;
|
||
label.text = tagName;
|
||
[imageView addSubview:label];
|
||
[label mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(27);
|
||
make.right.mas_equalTo(-8);
|
||
make.centerY.mas_equalTo(0);
|
||
}];
|
||
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter];
|
||
return string;
|
||
}
|
||
|
||
|
||
/// 生成一个图片的富文本
|
||
/// @param imageUrl 网络图片的地址
|
||
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl {
|
||
NetImageConfig *config = [[NetImageConfig alloc]init];
|
||
///先这样吧
|
||
config.autoLoad = YES;
|
||
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
|
||
UIImage* image = imageView.image;
|
||
if (image) {
|
||
CGFloat scale = image.size.width / image.size.height;
|
||
imageView.bounds = CGRectMake(0, 0, 18 * scale, 18);
|
||
} else {
|
||
imageView.bounds = CGRectMake(0, 0, 18, 18);
|
||
}
|
||
imageView.layer.masksToBounds = YES;
|
||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||
return attrString;
|
||
}
|
||
/// 生成一个图片的富文本
|
||
/// @param imageUrl 网络图片的地址
|
||
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl size:(CGSize)size {
|
||
NetImageConfig *config = [[NetImageConfig alloc]init];
|
||
///先这样吧
|
||
config.autoLoad = YES;
|
||
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
|
||
|
||
imageView.bounds = CGRectMake(0, 0, size.width, size.height);
|
||
imageView.layer.masksToBounds = YES;
|
||
imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||
return attrString;
|
||
}
|
||
|
||
/// 生成本地一个图片的富文本
|
||
/// @param imageName 网络图片的地址
|
||
- (NSMutableAttributedString *)createLocalImageAttribute:(NSString *)imageName {
|
||
if (imageName == nil && imageName.length <= 0) {
|
||
return nil;
|
||
}
|
||
UIImageView *imaveView = [[UIImageView alloc]init];
|
||
imaveView.image = [UIImage imageNamed:imageName];
|
||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||
imaveView.bounds = CGRectMake(0, 0, 16 * scale, 16);
|
||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||
return attrString;
|
||
|
||
}
|
||
|
||
/// 生成本地一个图片的富文本
|
||
/// @param image 本地的图片
|
||
- (NSMutableAttributedString *)createImageAttribute:(UIImage *)image {
|
||
UIImageView *imaveView = [[UIImageView alloc]init];
|
||
imaveView.image = image;
|
||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||
imaveView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||
return attrString;
|
||
}
|
||
|
||
/// 生成一个富文本
|
||
/// @param text 富文本的文字
|
||
/// @param color 文字的颜色
|
||
/// @param font 文字的大小
|
||
- (NSMutableAttributedString *)createTextAttribute:(NSString *)text color:(UIColor *)color font:(CGFloat)font {
|
||
if (text == nil || text.length <= 0) {
|
||
text = @"";
|
||
}
|
||
NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:text attributes:nil];
|
||
attribute.yy_font = [UIFont systemFontOfSize:font];
|
||
attribute.yy_color = color;
|
||
attribute.yy_paragraphStyle = [self paragraphStyle];
|
||
return attribute;
|
||
}
|
||
|
||
/// 设置文本的样式 间隙 缩进 ...
|
||
- (NSMutableParagraphStyle *)paragraphStyle {
|
||
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
|
||
paraStyle.lineSpacing = 4.0f;//行间距
|
||
// 强制排版(从左到右)
|
||
paraStyle.alignment = NSTextAlignmentLeft;
|
||
paraStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
||
return paraStyle;
|
||
}
|
||
|
||
/// 占位的富文本
|
||
/// @param width 需要的间隙
|
||
- (NSMutableAttributedString *)createSapceAttribute:(CGFloat)width {
|
||
UIView *spaceView = [[UIView alloc]init];
|
||
spaceView.backgroundColor = [UIColor clearColor];
|
||
spaceView.bounds = CGRectMake(0, 0, width, 10);
|
||
NSMutableAttributedString * attribute = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(spaceView.frame.size.width, spaceView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||
return attribute;
|
||
}
|
||
|
||
@end
|