Sending this to the server will join a channel:
JOIN #channel-name
This will send a message:
PRIVMSG #channel-name :YOUR MESSAGE HERE
How can I send a command?
In my IRC client, if I type /list, it will list all the channels. I try to send /list programmatically using PRIVMSG, but it literally sends /list and doesn't return channel names.
/listis not sent as a PRIVMSG to the server. Use the LIST command. - Greg Hewgillircsock.send('LIST'):verne.freenode.net 421 Mybot LISTPRIVMSG :Unknown command - user3893623\r\nafter your LIST command. - Greg Hewgill