房间内公聊大厅

This commit is contained in:
liyuhua
2024-05-11 10:21:48 +08:00
parent 8d78cb6be5
commit e05876be41
42 changed files with 1506 additions and 264 deletions

View File

@@ -53,13 +53,14 @@
#import "XCCurrentVCStackManager.h"
#import "XPTreasureFairyViewController.h"
#import "PIGeneralPublicScreenModel.h"
#import "MSSessionPublicChatHallTopModel.h"
@implementation XPRoomMessageParser
- (XPMessageInfoModel*)parseMessageAttribute:(NIMMessage *)message {
NIMMessageType messageType = message.messageType;
XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init];
XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init];
if([message.messageObject isKindOfClass:[NIMCustomObject class]] ){
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
@@ -70,7 +71,7 @@
}
}
}
switch (messageType) {
case NIMMessageTypeText:
@@ -91,7 +92,7 @@
return model != nil ? model : [XPMessageInfoModel new];
break;
}
case NIMMessageTypeCustom:
case NIMMessageTypeCustom:
{
XPMessageInfoModel *model = [self makeCustomAttribute:message messageInfo:messageInfo];
return model != nil ? model : [XPMessageInfoModel new];
@@ -109,119 +110,125 @@
///
- (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;
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) {//VIP
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;
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) {//VIP
return [self createNobleLevelAttribute:attachment messageInfo:messageInfo];
} else if (first == CustomMessageType_Face) {//VIP
return [self createRoomFaceAttribute:attachment messageInfo:messageInfo];
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];
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_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){
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];
}else if(first == CustomMessageType_Super_Gift){
return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo];
}
}
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];
}else if(first == CustomMessageType_Super_Gift){
return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo];
}else if(first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn){
return [self createChatHallnAttribute:attachment messageInfo:messageInfo];
}
return nil;
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];
messageInfo.bubbleImageUrl = [self parseMessageBubble:message];
NSString *getNick = ((NIMMessageChatroomExtension *)message.messageExt).roomNickname;
if(getNick == nil && model.nick != nil){
getNick = model.nick;
}
NSString * nick = [NSString stringWithFormat:@"%@:", getNick];
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 createLanguageImageAttribute:@"common_super_admin"]];
}
if (model.vipIcon) {//VIPicon
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon size:CGSizeMake(20, 20)]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if (model.experUrl) {
[attribute appendAttributedString:[self createUrlImageAttribute:model.experUrl]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if ([ClientConfig shareConfig].canOpen) {
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser fromSayHelloChannel:model.fromSayHelloChannel]];
if ([self isCurrentRoomSuperAdmin:message.from]) {
[attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]];
}
if (model.vipIcon) {//VIPicon
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon size:CGSizeMake(20, 20)]];
[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]]];
@@ -231,10 +238,10 @@
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
}
}
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
id nickNameNifo = message.remoteExt[@"atNames"];
@@ -242,8 +249,8 @@
if (message.text) {
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
[msgStr addAttribute:NSForegroundColorAttributeName
value:[DJDKMIMOMColor messageTextColor]
range:NSMakeRange(0, msgStr.length)];
value:[DJDKMIMOMColor messageTextColor]
range:NSMakeRange(0, msgStr.length)];
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
for (NSString *nick in nickNameNifo) {
NSRange range = [message.text rangeOfString:nick];
@@ -255,7 +262,7 @@
[attribute appendAttributedString:msgStr];
}
[self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
messageInfo.content = attribute;
messageInfo.content = attribute;
messageInfo.vipIcon = model.vipIcon;
return messageInfo;
}
@@ -263,62 +270,62 @@
/// 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;
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];
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;
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 createLanguageImageAttribute:@"common_super_admin"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if (extModel.vipIcon.length > 0) {//VIPicon
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 createLanguageImageAttribute:@"common_super_admin"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if (extModel.vipIcon.length > 0) {//VIPicon
messageInfo.vipIcon = extModel.vipIcon;
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon size:CGSizeMake(20, 20)]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if (extModel.experUrl.length > 0) {//
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.experUrl]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon size:CGSizeMake(20, 20)]];
[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]];
@@ -330,49 +337,49 @@
[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;
[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;
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;
return nil;
}
#pragma mark -
- (XPMessageInfoModel *)createTreasureFairyAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
@@ -439,11 +446,11 @@
@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];
fairyVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self.hostDelegate.getCurrentNav presentViewController:fairyVC animated:YES completion:nil];
}];
[attribute appendAttributedString:nickAttriibute];
}
@@ -467,7 +474,22 @@
//
// return attribute;
//}
- (XPMessageInfoModel *)createChatHallnAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data];
messageInfo.first = CustomMessageType_Chat_Hall_Headlinesn;
if (topModel.nick != nil){
NSString *text = [NSString stringWithFormat:YMLocalizedString(@"MSSessionContextHeadlinesView0"),topModel.nick];
NSMutableAttributedString *textAtt = [[NSMutableAttributedString alloc]initWithString:text attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:UIColorFromRGB(0xffffff)}];
[textAtt addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xFE6859)} range:[text rangeOfString:topModel.nick]];
messageInfo.content = textAtt;
}
return messageInfo;
}
- (XPMessageInfoModel *)createGeneralPublicScreenAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
PIGeneralPublicScreenModel *screenModel = [PIGeneralPublicScreenModel modelWithDictionary:attachment.data];