Using what you provided I just modified it.

Code:
on *:text:!invite*:*:{
  if (!$1-3) { halt }
  else {
    .msg Mrbot invite $nick $3
  }
}


That worked for me when I changed it to:
Code:
on *:text:!invite*:#:{
  if (!$1-3) { halt }
  else {
    msg #channel invite $nick $3
  }
}


So it should work for you now.