You can simply change the on text event to this:
on *:TEXT:!url *:#: rtc $chan $2
Also updated the code slightly.