Add Users

By Get_A_Fix on May 22, 2010

Just a basic adduser script.

Supported Arguments:
AddOWNER
AddMASTER
AddGOP
AddCHANOWNER
AddSOP
DelSOP
AddAOP
DelAOP
AddAOV
DelAOV

I also included a joinmodes procedure, to auto OP/voice the matching users, which can be enabled/disabled on channel, or via /msg command.

See below code for command reference.

# Default trigger set to !

# Commands are:
# !addowner nickname
# !addmaster nickname
# !addgop nickname
# !addchanowner nickname
# !addsop nickname
# !delsop nickname
# !addaop nickname
# !delaop nickname
# !addaov nickname
# !delaov nickname

# JoinModes Public Commands:
# Enable:  !joinmodes on
# Disable: !joinmodes off

# JoinModes Message Command:
# /msg botnick joinmodes #channel on/off

# -----------EDIT BELOW------------

# Set this to whatever trigger you like.
set trigger "!"

# ------DONT TOUCH BELOW HERE!!!------
setudef flag joinmode

proc getTrigger {} {
  global trigger
  return $trigger
}

bind join - * join:modes
bind pub - ${trigger}addowner addowner:pub
bind pub - ${trigger}addmaster addmaster:pub
bind pub - ${trigger}addgop addgop:pub
bind pub - ${trigger}addchanowner addcowner:pub
bind pub - ${trigger}addsop addsop:pub
bind pub - ${trigger}delsop delsop:pub
bind pub - ${trigger}addaop addaop:pub
bind pub - ${trigger}delaop delaop:pub
bind pub - ${trigger}addaov addaov:pub
bind pub - ${trigger}delaov delaov:pub
bind pub - ${trigger}joinmodes jmode:pub
bind msg - joinmodes jmode:msg

proc addowner:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] n]} {return}
  set owneradd [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]addowner nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]addowner nickname"; return}
  if {[validuser [nick2hand $owneradd]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $owneradd is already a valid user."; return}
  if {[validuser [nick2hand $owneradd]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $owneradd is already a valid user."; return}
  if {![onchan $owneradd $chan] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $owneradd is not even on $chan ..."; return}
  if {![onchan $owneradd $chan] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $owneradd is not even on $chan ..."; return}
  set mask *!*@[lindex [split [getchanhost $owneradd $chan] @] 1]
  adduser $owneradd $mask
  chattr $owneradd +n
  putquick "NOTICE $nick :Added $owneradd to the Global Owner List."
  putquick "NOTICE $owneradd :$nick ($hand) has added you to the Global Owner List."
}

proc addmaster:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] n]} {return}
  set masteradd [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]addmaster nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]addmaster nickname"; return}
  if {[validuser [nick2hand $masteradd]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $masteradd is already a valid user."; return}
  if {[validuser [nick2hand $masteradd]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $masteradd is already a valid user."; return}
  if {![onchan $masteradd $chan] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $masteradd is not even on $chan ..."; return}
  if {![onchan $masteradd $chan] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $masteradd is not even on $chan ..."; return}
  set mask *!*@[lindex [split [getchanhost $masteradd $chan] @] 1]
  adduser $masteradd $mask
  chattr $masteradd +m
  putquick "NOTICE $nick :Added $masteradd to the Global Master List."
  putquick "NOTICE $masteradd :$nick ($hand) has added you to the Global Master List."
}

proc addgop:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] m]} {return}
  set gopadd [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]addgop nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]addgop nickname"; return}
  if {[validuser [nick2hand $gopadd]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $gopadd is already a valid user."; return}
  if {[validuser [nick2hand $gopadd]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $gopadd is already a valid user."; return}
  if {![onchan $gopadd $chan] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $gopadd is not even on $chan ..."; return}
  if {![onchan $gopadd $chan] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $gopadd is not even on $chan ..."; return}
  set mask *!*@[lindex [split [getchanhost $gopadd $chan] @] 1]
  adduser $gopadd $mask
  chattr $gopadd +o
  putquick "NOTICE $nick :Added $gopadd to the Global OP List."
  putquick "NOTICE $gopadd :$nick ($hand) has added you to the Global OP List."
}

proc addcowner:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o]} {return}
  set cowneradd [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]addchanowner nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]addchanowner nickname"; return}
  if {[validuser [nick2hand $cowneradd]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $cowneradd is already a valid user."; return}
  if {[validuser [nick2hand $cowneradd]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $cowneradd is already a valid user."; return}
  if {![onchan $cowneradd $chan] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $cowneradd is not even on $chan ..."; return}
  if {![onchan $cowneradd $chan] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $cowneradd is not even on $chan ..."; return}
  set mask *!*@[lindex [split [getchanhost $cowneradd $chan] @] 1]
  adduser $cowneradd $mask
  chattr $cowneradd |n $chan
  putquick "NOTICE $nick :Added $cowneradd to the Channel Owner List for $chan"
  putquick "NOTICE $cowneradd :$nick ($hand) has added you to the Channel Owner List for $chan"
}

proc addsop:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|n $chan]} {return}
  set sopadd [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]addsop nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]addsop nickname"; return}
  if {[validuser [nick2hand $sopadd]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $sopadd is already a valid user."; return}
  if {[validuser [nick2hand $sopadd]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $sopadd is already a valid user."; return}
  set mask *!*@[lindex [split [getchanhost $sopadd $chan] @] 1]
  putquick "MODE $chan +o $sopadd"
  adduser $sopadd $mask
  chattr $sopadd |+m $chan
  putquick "NOTICE $nick :Added $sopadd to the SOP List for $chan"
  putquick "NOTICE $sopadd :$nick ($hand) has added you to the SOP List for $chan"
}

proc delsop:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|n $chan]} {return}
  set sopdel [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]delsop nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]delsop nickname"; return}
  if {![validuser [nick2hand $sopdel]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $sopdel is not a valid user."; return}
  if {![validuser [nick2hand $sopdel]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $sopdel is not a valid user."; return}
  putquick "MODE $chan -o $sopdel"
  deluser $sopdel
  putquick "NOTICE $nick :Deleted $sopdel from the SOP List for $chan"
  putquick "NOTICE $sopdel :$nick ($hand) has deleted you from the SOP List for $chan"
}

proc addaop:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|m $chan]} {return}
  set opadd [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]addaop nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]addaop nickname"; return}
  if {[validuser [nick2hand $opadd]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $opadd is already a valid user."; return}
  if {[validuser [nick2hand $opadd]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $opadd is already a valid user."; return}
  set mask *!*@[lindex [split [getchanhost $opadd $chan] @] 1]
  putquick "MODE $chan +o $opadd"
  adduser $opadd $mask
  chattr $opadd |+o $chan
  putquick "NOTICE $nick :Added $opadd to the AOP List for $chan"
  putquick "NOTICE $opadd :$nick ($hand) has added you to the AOP List for $chan"
}

proc delaop:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|m $chan]} {return}
  set opdel [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]delaop nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]delaop nickname"; return}
  if {![validuser [nick2hand $opdel]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $opdel is not a valid user."; return}
  if {![validuser [nick2hand $opdel]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $opdel is not a valid user."; return}
  putquick "MODE $chan -o $opdel"
  deluser $opdel
  putquick "NOTICE $nick :Deleted $opdel from the AOP List for $chan"
  putquick "NOTICE $opdel :$nick ($hand) has deleted you from the AOP List for $chan"
}

proc addaov:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|o $chan]} {return}
  set aovadd [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]addaov nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]addaov nickname"; return}
  if {[validuser [nick2hand $aovadd]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $aovadd is already a valid user."; return}
  if {[validuser [nick2hand $aovadd]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $aovadd is already a valid user."; return}
  set mask *!*@[lindex [split [getchanhost $aovadd $chan] @] 1]
  putquick "MODE $chan +v $aovadd"
  adduser $aovadd $mask
  chattr $aovadd |+v $chan
  putquick "NOTICE $nick :Added $aovadd to the AOV List for $chan"
  putquick "NOTICE $aovadd :$nick ($hand) has added you to the AOV List for $chan"
}

proc delaov:pub {nick uhost hand chan arg} {
  if {![matchattr [nick2hand $nick] o|o $chan]} {return}
  set aovdel [lindex [split $arg] 0]
  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]delaov nickname"; return}
  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]delaov nickname"; return}
  if {![validuser [nick2hand $aovdel]] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: $aovdel is not a valid user."; return}
  if {![validuser [nick2hand $aovdel]] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: $aovdel is not a valid user."; return}
  putquick "MODE $chan -v $aovdel"
  deluser $aovdel
  putquick "NOTICE $nick :Deleted $aovdel from the AOV List for $chan"
  putquick "NOTICE $aovdel :$nick ($hand) has deleted you from the AOV List for $chan"
}

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

  if {[lindex [split $arg] 0] == "on"} {
    if {[channel get $chan joinmode] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
    if {[channel get $chan joinmode] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already enabled."; return}
    channel set $chan +joinmode
    putquick "PRIVMSG $chan :Enabled Auto @/+ Modes for $chan"
  }

  if {[lindex [split $arg] 0] == "off"} {
    if {![channel get $chan joinmode] && ![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
    if {![channel get $chan joinmode] && [regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :ERROR: This setting is already disabled."; return}
    channel set $chan -joinmode
    puthelp "PRIVMSG $chan :Disabled Auto @/+ Modes for $chan"
  }
}

proc jmode:msg {nick uhost hand arg} {
  global botnick
  set chan [strlwr [lindex $arg 0]]
  if {![matchattr [nick2hand $nick] o|n $chan]} {return}
  if {([lindex [split $arg] 0] == "") && ([string match "*#*" $arg])} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick joinmodes #channel on/off"; return}
  if {([lindex [split $arg] 1] == "") && ([string match "*#*" $arg])} {putquick "NOTICE $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: /msg $botnick joinmodes $chan on/off"; return}

  if {([lindex [split $arg] 1] == "on") && ([string match "*#*" $arg])} {
    if {[channel get $chan joinmode]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already enabled."; return}
    channel set $chan +joinmode
    putquick "NOTICE $nick :Enabled Auto @/+ Modes for $chan"
  }

  if {([lindex [split $arg] 1] == "off") && ([string match "*#*" $arg])} {
    if {![channel get $chan joinmode]} {putquick "NOTICE $nick :\037ERROR\037: This setting is already disabled."; return}
    channel set $chan -joinmode
    putquick "NOTICE $nick :Disabled Auto @/+ Modes for $chan"
  }
}

proc join:modes {nick uhost hand chan} {
  global botnick
  if {[string tolower $nick] != [string tolower $botnick]} {
    if {[channel get $chan joinmode] && [botisop $chan]} {

      if {[matchattr [nick2hand $nick] o]} {
        putquick "MODE $chan +v $nick"
        return 0
      }

      if {[matchattr [nick2hand $nick] |n $chan]} {
        putquick "MODE $chan +o $nick"
        return 0
      }

      if {[matchattr [nick2hand $nick] |m $chan]} {
        putquick "MODE $chan +o $nick"
        return 0
      }

      if {[matchattr [nick2hand $nick] |o $chan]} {
        putquick "MODE $chan +o $nick"
        return 0
      }

      if {[matchattr [nick2hand $nick] |v $chan]} {
        putquick "MODE $chan +v $nick"
        return 0
      }
    }
  }
}

putlog "AddUSER+JoinModes: Module LOADED!"

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.