syabruk/pync

Issues with unicode/ASCII encoding/decoding of messages when receiving notifications from weechat

megalithic opened this issue · 6 comments

Describe the bug

On macOS 10.13.6 (high sierra), using the latest pync installed via github, the latest version of weechat, the latest notification_center.py weechat plugin installed via /script command in weechat, and latest terminal-notifier (using either the ruby gem or the homebrew formula).

I get the following error:

11:15 python: stdout/stderr (notification_center): Traceback (most recent call last):
11:15 python: stdout/stderr (notification_center):   File "/Users/me/.dotfiles/private/weechat/python/autoload/notification_center.py", line 63, in notify
11:15 python: stdout/stderr (notification_center):     Notifier.notify('From %s' % prefix, title='Private Message', sound=sound, appIcon=WEECHAT_ICON, activate=activate_bundle_id)
11:15 python: stdout/stderr (notification_center):   File "/usr/local/opt/python@2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pync/TerminalNotifier.py", line 73, in notify
11:15 python: stdout/stderr (notification_center):     message = message.encode('utf-8')
11:15 python: stdout/stderr (notification_center): UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 5: ordinal not in range(128)
11:15 ⚠ python: error in function "notify"

Desktop (please complete the following information):

  • OS: macOS
  • Version 10.13.6
  • kitty: 0.12.3
  • tmux: 2.7
  • zsh: 5.6.2
  • weechat: 2.3
  • pync: 2.0.4
  • notification_center.py: 1.3.0
  • terminal-notifier: 2.0.0

To Reproduce

Steps to reproduce the behavior:

  1. Install weechat, pync, terminal-notifier, and the notification_center.py plugin versions shown above (those are all the latest versions as of the writing of this issue).
  2. Have someone @ you, or DM you, or what not within IRC, whatever bitlbee or other server source you might be using.
  3. Without fail, the above error occurs.

Expected behavior

I would expect the notification to popup, I can call terminal-notifier directly from a term prompt and it raises a notification (using the basic example on their repo: echo 'Piped Message Data!' | terminal-notifier -sound default.

Additional context

I tried fiddling with the notification_center.py plugin to see if i can add more logging or more encoding/decoding for unicode and/or ascii or other file format types (trying the things others on stackoverflow and other github repos have suggested to work around this), but to no avail. I still end up with an error from pync.

What's interesting is if i just output directly to a weechat buffer (like the core buffer), the message sent that should be getting passed, ultimately to pync/terminal-notifier, the message text looks just fine, but for some reason pync just doesn't like it at all.

@megalithic Thanks, I will check this issue asap.

@maxkrivich let me know if i can help and/or test anything. much thanks for your work on this!

@maxkrivich the more i've thought about this; there may be some sort of correlation between having the weemote and weemoji plugins installed too. i haven't had a chance to test that theory. just wanted to mention it in case it's related to the encoding/decoding "issues".

thanks again!

hey there @maxkrivich, just checking in.

i've pretty well come to the conclusion that it's throwing those errors when I have either the emoji.lua and weemoticons.py plugin scripts installed for weechat. i haven't checked to see which one specifically, but if there is emoji/emotes in the message to be notified on, then it throws the error; not able to decode/encode the message.

howdy @maxkrivich, doing my weekly'ish check in if you had an opportunity to dig into this.

i really appreciate it!

@megalithic I'm super busy right now, if you think what you can fix that, I will be glad to help you.