You JOIN <cfg.CHAN>, but send with PRIVMSG #<cfg.CHAN>. Notice the #; it needs to be consistent for both: #<channelname>. Whether the # comes from the cfg.CHAN or the code doesn’t matter, but there must be exactly one # for the IRC commands.