Skip to content

Instantly share code, notes, and snippets.

@ShikChen
Last active June 27, 2021 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShikChen/b6664174d8ed067bb610dba0ca805335 to your computer and use it in GitHub Desktop.
Save ShikChen/b6664174d8ed067bb610dba0ca805335 to your computer and use it in GitHub Desktop.
PTT WebSocket CLI Command

Install https://github.com/vi/websocat to setup a local proxy between wss://ws.ptt.cc/bbs and 127.0.0.1:1337:

$ websocat --oneshot --binary --origin=https://term.ptt.cc tcp-l:127.0.0.1:1337 wss://ws.ptt.cc/bbs

Now use telnet localhost 1337 to connect to PTT. Sadly it will show things with a specialized Big5 + UAO (Unicode 補完計畫), which is not compatible with most of the terminals.

To solve this, either

  1. Enter username with comma like username,, then PTT will show characters in UTF8 after the login screen.
  2. Use https://github.com/buganini/bug5 wrapper to transcode between Big5 and UTF8, such as:
$ (websocat --oneshot --binary --origin=https://term.ptt.cc tcp-l:127.0.0.1:1337 wss://ws.ptt.cc/bbs &) && ./bug5 -up telnet localhost 1337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment