@@ -14,8 +14,9 @@ def export
1414 description = open_characters_persona_params . fetch ( 'description' , '' )
1515
1616 add_character_hash = base_open_characters_export . merge ( {
17+ "uuid" : deterministic_uuid ( @character . id ) ,
1718 "name" : name ,
18- "roleInstruction" : "You are to act as #{ name } , whos personality is detailed below:\n \n #{ description } " ,
19+ "roleInstruction" : "You are to act as #{ name } , whose personality is detailed below:\n \n #{ description } " ,
1920 "reminderMessage" : "#{ personality } \n \n Do not break character!" ,
2021 } )
2122
@@ -32,15 +33,22 @@ def export
3233
3334 private
3435
36+ def deterministic_uuid ( id )
37+ static_prefix = "notebook-"
38+ hashed_id = Digest ::SHA1 . hexdigest ( static_prefix + id . to_s )
39+ uuid = "#{ hashed_id [ 0 ..7 ] } -#{ hashed_id [ 8 ..11 ] } -#{ hashed_id [ 12 ..15 ] } -#{ hashed_id [ 16 ..19 ] } -#{ hashed_id [ 20 ..31 ] } "
40+ uuid
41+ end
42+
3543 def personality_for_character
3644 name = @character . name
37- gender = @character . get_field_value ( 'Overview' , 'Gender' )
38- role = @character . get_field_value ( 'Overview' , 'Role' )
39- age = @character . get_field_value ( 'Overview' , 'Age' )
40- aliases = @character . get_field_value ( 'Overview' , 'Aliases' )
41- hobbies = @character . get_field_value ( 'Nature' , 'Hobbies' )
45+ gender = @character . get_field_value ( 'Overview' , 'Gender' ) . try ( :strip )
46+ role = @character . get_field_value ( 'Overview' , 'Role' ) . try ( :strip )
47+ age = @character . get_field_value ( 'Overview' , 'Age' ) . try ( :strip )
48+ aliases = @character . get_field_value ( 'Overview' , 'Aliases' ) . try ( :strip )
49+ hobbies = @character . get_field_value ( 'Nature' , 'Hobbies' ) . try ( :strip )
4250
43- [
51+ final_text = [
4452 name ,
4553 " is a " ,
4654 gender . downcase ,
@@ -50,6 +58,8 @@ def personality_for_character
5058 aliases . present? ? "(also known as #{ aliases } )" : nil ,
5159 hobbies . present? ? " into #{ hobbies } ." : "."
5260 ] . compact . join
61+
62+ ContentFormatterService . plaintext_show ( text : final_text , viewing_user : current_user )
5363 end
5464
5565 def description_for_character
@@ -72,7 +82,7 @@ def description_for_character
7282 description_parts . concat [ "TALENTS" , talents , nil ] if talents . present?
7383 description_parts . concat [ "HOBBIES" , hobbies , nil ] if hobbies . present?
7484
75- description_parts . join ( "\n " )
85+ ContentFormatterService . plaintext_show ( text : description_parts . join ( "\n " ) , viewing_user : current_user )
7686 end
7787
7888 def set_character
0 commit comments