2026-01-15 18:16:56 +08:00
|
|
|
//
|
|
|
|
|
// KBChatMessage.m
|
|
|
|
|
// CustomKeyboard
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "KBChatMessage.h"
|
|
|
|
|
|
|
|
|
|
@implementation KBChatMessage
|
|
|
|
|
|
|
|
|
|
+ (instancetype)messageWithText:(NSString *)text
|
|
|
|
|
outgoing:(BOOL)outgoing
|
|
|
|
|
audioFilePath:(NSString *)audioFilePath {
|
|
|
|
|
KBChatMessage *msg = [[KBChatMessage alloc] init];
|
|
|
|
|
msg.text = text ?: @"";
|
|
|
|
|
msg.outgoing = outgoing;
|
|
|
|
|
msg.audioFilePath = audioFilePath;
|
2026-01-30 13:17:11 +08:00
|
|
|
msg.isComplete = YES;
|
|
|
|
|
msg.isLoading = NO;
|
|
|
|
|
msg.needsTypewriterEffect = NO;
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (instancetype)userMessageWithText:(NSString *)text {
|
|
|
|
|
KBChatMessage *msg = [[KBChatMessage alloc] init];
|
|
|
|
|
msg.text = text ?: @"";
|
|
|
|
|
msg.outgoing = YES;
|
|
|
|
|
msg.isComplete = YES;
|
|
|
|
|
msg.isLoading = NO;
|
|
|
|
|
msg.needsTypewriterEffect = NO;
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (instancetype)assistantMessageWithText:(NSString *)text
|
|
|
|
|
audioId:(NSString *)audioId {
|
|
|
|
|
KBChatMessage *msg = [[KBChatMessage alloc] init];
|
|
|
|
|
msg.text = text ?: @"";
|
|
|
|
|
msg.outgoing = NO;
|
|
|
|
|
msg.audioId = audioId;
|
|
|
|
|
msg.isComplete = NO;
|
|
|
|
|
msg.isLoading = NO;
|
|
|
|
|
msg.needsTypewriterEffect = YES;
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (instancetype)loadingAssistantMessage {
|
|
|
|
|
KBChatMessage *msg = [[KBChatMessage alloc] init];
|
|
|
|
|
msg.text = @"";
|
|
|
|
|
msg.outgoing = NO;
|
|
|
|
|
msg.isComplete = NO;
|
|
|
|
|
msg.isLoading = YES;
|
|
|
|
|
msg.needsTypewriterEffect = NO;
|
2026-01-15 18:16:56 +08:00
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|