noctcp

By Get_A_Fix on Apr 30, 2010

This is again something someone asked me for.

Stops people or bots/drones from doing /ctcp #yourchannel version/finger/ping/time requests.

SYNTAX

Public: !noctcp on/off

Message: /msg botnick noctcp #channel on/off

# NOCTCP Module
setudef flag noctcp

bind pub - !noctcp noctcp:pub
bind msg - noctcp noctcp:msg
bind ctcp - "VERSION" chan:ctcp
bind ctcp - "FINGER" chan:ctcp
bind ctcp - "TIME" chan:ctcp
bind ctcp - "PING" chan:ctcp

proc chan:ctcp {nick uhost hand dest key text} {
  global botnick
  if {![string match "*#*" $dest]} {return}
  set chan $dest
  if {[channel get $chan noctcp]} {
    if {[botisop $chan] && [onchan $nick $chan] && ![isop $nick $chan] && ![isvoice $nick $chan] && ![validuser $hand]} {
      newignore *!*@[lindex [split $uhost @] 1] $botnick "NOCTCP - Autoignore on: $nick (5mins)" 5
      putquick "MODE $chan +b *!*@[lindex [split $uhost @] 1]"
      putquick "KICK $chan $nick :(\002NOCTCP\002) - You are \002NOT\002 Permitted to CTCP $chan"
    }
  }
}

proc noctcp:pub {nick uhost hand chan text} {
  if {![matchattr $hand o|m $chan]} {return}
  if {([lindex [split $text] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: !noctcp on/off"; return}
  if {([lindex [split $text] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: !noctcp on/off"; return}

  if {[lindex [split $text] 0] == "on"} {
    if {[channel get $chan noctcp] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
    if {[channel get $chan noctcp] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already enabled."; return}
    channel set $chan +noctcp
    puthelp "PRIVMSG $chan :Enabled Anti Channel CTCP for $chan"
  }

  if {[lindex [split $text] 0] == "off"} {
    if {![channel get $chan noctcp] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
    if {![channel get $chan noctcp] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already disabled."; return}
    channel set $chan -noctcp
    puthelp "PRIVMSG $chan :Disabled Anti Channel CTCP for $chan"
  }
}

proc noctcp:msg {nick uhost hand arg} {
  global botnick
  set chan [strlwr [lindex $arg 0]]
  if {![matchattr $hand o|m $chan]} {return}
  if {[lindex [split $arg] 0] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick noctcp #channel on/off"; return}
  if {[lindex [split $arg] 1] == ""} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick noctcp $chan on/off"; return}

  if {[lindex [split $arg] 1] == "on"} {
    if {[channel get $chan noctcp]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
    channel set $chan +noctcp
    putquick "NOTICE $nick :Enabled Anti Channel CTCP for $chan"
  }

  if {[lindex [split $arg] 1] == "off"} {
    if {![channel get $chan noctcp]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
    channel set $chan -noctcp
    putquick "NOTICE $nick :Disabled Anti Channel CTCP for $chan"
  }
}

putlog "Loaded: NOCTCP Module."

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.