To get the currect topic, use $chan(#channame).topic
So:
on *:join:#yourchan: { if ($nick == $me) { .timer 1 5 set.topic $chan } }
alias set.topic {
if ($me isop $1 && !$chan($1).topic) {
topic New topic
}
}
Replace #yourchan and "New topic".
This hasn't been tested as I'm at work and can't connect right now, but I believe it will work.
The timer/alias combo gives you the delay for gaining ops. If you aren't gaining ops within 5 seconds of joining, adjust the timer.