tdryer / hangups

the first third-party instant messaging client for Google Hangouts
https://hangups.readthedocs.io/
MIT License
1.71k stars 189 forks source link

How to Send Newlines? #521

Closed OpenSaned closed 3 years ago

OpenSaned commented 3 years ago

I have tried \n But it only works on mobile not on the web version, is there a way fix it without adding lots of code. This is my request For client.send_chat_message():

request = #hangups.hangouts_pb2.SendChatMessageRequest( request_header=client.get_request_header(), event_request_header=hangups.hangouts_pb2.EventRequestHeader( conversation_id=hangups.hangouts_pb2.ConversationId( id=id ), client_generated_id=client.get_client_generated_id(), ), message_content=hangups.hangouts_pb2.MessageContent( segment=[ hangups.ChatMessageSegment(message).serialize() ], ), )

tdryer commented 3 years ago

You can use ChatMessageSegment.from_str to get a list of segments from a string, including newline segments.

OpenSaned commented 3 years ago

Do I have to Serialize the segments individually or is there a better way to do it?

tdryer commented 3 years ago

You'll have to serialize them individually.

OpenSaned commented 3 years ago

So does this solution have problems? segments = [] for i in hangups.ChatMessageSegment.from_str(message): segments.append(i.serialize())

tdryer commented 3 years ago

That should work.

OpenSaned commented 3 years ago

Ok. Thanks a lot!