Using what you provided I just modified it.
on *:text:!invite*:*:{
if (!$1-3) { halt }
else {
.msg Mrbot invite $nick $3
}
}
That worked for me when I changed it to:
on *:text:!invite*:#:{
if (!$1-3) { halt }
else {
msg #channel invite $nick $3
}
}
So it should work for you now.