@@ -119,7 +119,7 @@ def set_thread_parent(
119119 thread_parent .content .get_thread_parent () or self .relates_to .event_id
120120 )
121121 if not disable_reply_fallback :
122- self .set_reply (last_event_in_thread or thread_parent , disable_fallback = True , ** kwargs )
122+ self .set_reply (last_event_in_thread or thread_parent , ** kwargs )
123123 self .relates_to .is_falling_back = True
124124
125125 def set_edit (self , edits : Union [EventID , "MessageEvent" ]) -> None :
@@ -287,25 +287,6 @@ class TextMessageEventContent(BaseMessageEventContent, SerializableAttrs):
287287 format : Format = None
288288 formatted_body : str = None
289289
290- def set_reply (
291- self ,
292- reply_to : Union ["MessageEvent" , EventID ],
293- * ,
294- displayname : Optional [str ] = None ,
295- disable_fallback : bool = False ,
296- ) -> None :
297- super ().set_reply (reply_to )
298- if isinstance (reply_to , str ):
299- return
300- if isinstance (reply_to , MessageEvent ) and not disable_fallback :
301- self .ensure_has_html ()
302- if isinstance (reply_to .content , TextMessageEventContent ):
303- reply_to .content .trim_reply_fallback ()
304- self .formatted_body = (
305- reply_to .make_reply_fallback_html (displayname ) + self .formatted_body
306- )
307- self .body = reply_to .make_reply_fallback_text (displayname ) + self .body
308-
309290 def ensure_has_html (self ) -> None :
310291 if not self .formatted_body or self .format != Format .HTML :
311292 self .format = Format .HTML
@@ -424,36 +405,3 @@ def deserialize_content(data: JSON) -> MessageEventContent:
424405 return LocationMessageEventContent .deserialize (data )
425406 else :
426407 return Obj (** data )
427-
428- def make_reply_fallback_html (self , displayname : Optional [str ] = None ) -> str :
429- """Generate the HTML fallback for messages replying to this event."""
430- if self .content .msgtype .is_text :
431- body = self .content .formatted_body or escape (self .content .body ).replace ("\n " , "<br/>" )
432- else :
433- sent_type = media_reply_fallback_body_map [self .content .msgtype ] or "a message"
434- body = f"sent { sent_type } "
435- displayname = escape (displayname ) if displayname else self .sender
436- return html_reply_fallback_format .format (
437- room_id = self .room_id ,
438- event_id = self .event_id ,
439- sender = self .sender ,
440- displayname = displayname ,
441- content = body ,
442- )
443-
444- def make_reply_fallback_text (self , displayname : Optional [str ] = None ) -> str :
445- """Generate the plaintext fallback for messages replying to this event."""
446- if self .content .msgtype .is_text :
447- body = self .content .body
448- else :
449- try :
450- body = media_reply_fallback_body_map [self .content .msgtype ]
451- except KeyError :
452- body = "an unknown message type"
453- lines = body .strip ().split ("\n " )
454- first_line , lines = lines [0 ], lines [1 :]
455- fallback_text = f"> <{ displayname or self .sender } > { first_line } "
456- for line in lines :
457- fallback_text += f"\n > { line } "
458- fallback_text += "\n \n "
459- return fallback_text
0 commit comments