Or just use a timer.

join #chan | .timermodeme 1 1 mode #chan -o $me