The raw 366 is the end of the /names command, which is performed everytime you join a channel. $2, in the case, is the channel name. I don't know why that
on me:*: join did not work, but the raw one will (unless you've previously halted it).
BTW, the correct raw line is:
raw 366:*: set $+(%,topic,.,$2) $chan($2).topicZyzzyx