Check the following
- the token you are using has
chat:editscope - you are sending a PRIVMSG to
#channelnamenot#ChannelNamechannels are all lower case - use raw logging to log all messages sent by the server
- your lines end in CLRF (which
socket_writemight handle for you I don’t recal off hand)