Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems sending messages with Unicode #2732

Closed
dazzzl opened this issue May 8, 2019 · 7 comments

Comments

Projects
None yet
2 participants
@dazzzl
Copy link

commented May 8, 2019

I have problems sending messages with Unicode (Emojis)

python 2.7

File "/opt/transwhat2/yowsup/axolotl/manager.py", line 150, in encrypt
logger.debug("encrypt(recipientid=%s, message=%s)" % (recipient_id, message))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 2: ordinal not in range(128)

@tgalal

This comment has been minimized.

Copy link
Owner

commented May 8, 2019

yowsup version?

@dazzzl

This comment has been minimized.

Copy link
Author

commented May 8, 2019

from yesterday ...
commit d8b6d5f

Edit: Wrong commit

@tgalal

This comment has been minimized.

Copy link
Owner

commented May 8, 2019

ok please post more information, like full debug output and how are you sending the emoji, how to reproduce..etc

@dazzzl

This comment has been minimized.

Copy link
Author

commented May 8, 2019

I looked for the important code lines:

messageEntity = TextMessageProtocolEntity(message, to = to)
self.stack.broadcastEvent(YowLayerEvent(YowsupAppLayer.TO_LOWER_EVENT,
                        entity = messageEntity))'

Output + Trace:
`019-05-08 18:58:36,169 DEBUG WhatsAppBackend: handleMessageSendRequest(user=xxx, buddy=xxx, message=<U+1F600> , xhtml=, ID=3b7c253a-cb13-4672-a685-2d96a7492ac6)
2019-05-08 18:58:36,169 INFO Session: Message sent from xxx to xxx <U+1F600>  (xhtml=)
2019-05-08 18:58:36,171 DEBUG yowsup.axolotl.manager: session_exists(xxx)?
2019-05-08 18:58:36,219 ERROR transwhat: Traceback (most recent call last):
  File "/opt/transwhat2/transwhat.py", line 75, in handleTransportData
    plugin.handleDataRead(data)
  File "/opt/transwhat2/Spectrum2/backend.py", line 423, in handleDataRead
    self.handleConvMessagePayload(wrapper.payload)
  File "/opt/transwhat2/Spectrum2/backend.py", line 277, in handleConvMessagePayload
    self.handleMessageSendRequest(payload.userName, payload.buddyName, payload.message, payload.xhtml, payload.id)
  File "/opt/transwhat2/whatsappbackend.py", line 73, in handleMessageSendRequest
    self.sessions[user].sendMessageToWA(buddy, message, ID, xhtml)
  File "/opt/transwhat2/session.py", line 731, in sendMessageToWA
    waId = self.sendTextMessage(sender + '@s.whatsapp.net', message)
  File "/opt/transwhat2/yowsupwrapper.py", line 172, in sendTextMessage
    self.sendEntity(messageEntity)
  File "/opt/transwhat2/yowsupwrapper.py", line 701, in sendEntity
    entity = entity
  File "/opt/transwhat2/yowsup/stacks/yowstack.py", line 175, in broadcastEvent
    if not self.__stackInstances[-1].onEvent(yowLayerEvent):
  File "/opt/transwhat2/yowsupwrapper.py", line 734, in onEvent
    self.toLower(layerEvent.getArg('entity'))
  File "/opt/transwhat2/yowsup/layers/__init__.py", line 84, in toLower
    self.__lower.send(data)
  File "/opt/transwhat2/yowsup/layers/__init__.py", line 198, in send
    s.send(data)
  File "/opt/transwhat2/yowsup/layers/__init__.py", line 136, in send
    send(entity)
  File "/opt/transwhat2/yowsup/layers/protocol_messages/layer.py", line 15, in sendMessageEntity
    self.entityToLower(entity)
  File "/opt/transwhat2/yowsup/layers/__init__.py", line 140, in entityToLower
    self.toLower(entity.toProtocolTreeNode())
  File "/opt/transwhat2/yowsup/layers/__init__.py", line 84, in toLower
    self.__lower.send(data)
  File "/opt/transwhat2/yowsup/layers/__init__.py", line 198, in send
    s.send(data)
  File "/opt/transwhat2/yowsup/layers/axolotl/layer_send.py", line 37, in send
    self.processPlaintextNodeAndSend(node)
  File "/opt/transwhat2/yowsup/layers/axolotl/layer_send.py", line 71, in processPlaintextNodeAndSend
    self.sendToContact(node)
  File "/opt/transwhat2/yowsup/layers/axolotl/layer_send.py", line 112, in sendToContact
    messageData
  File "/opt/transwhat2/yowsup/axolotl/manager.py", line 150, in encrypt
    logger.debug("encrypt(recipientid=%s, message=%s)" % (recipient_id, message))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 2: ordinal not in range(128)

2019-05-08 18:59:12,249 DEBUG yowsup.layers.protocol_iq.layer: ping queue size: 1

Hope this helps

@dazzzl

This comment has been minimized.

Copy link
Author

commented May 8, 2019

It is only the debug output. By removing the debug output, the message will be sent correctly.

tgalal added a commit that referenced this issue May 8, 2019

[fix] omit message content from log output
Refs #2732 Problems sending messages with Unicode
@tgalal

This comment has been minimized.

Copy link
Owner

commented May 8, 2019

I'm not able to reproduce, but I also see no advantage of including the message content in that specific log line so I'll just remove it. Please close the issue if 749ac64 fixed the problem.

@dazzzl

This comment has been minimized.

Copy link
Author

commented May 8, 2019

Ok, it is working. Thanks!

@dazzzl dazzzl closed this May 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.