This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Need help change command

Help for those learning Tcl or writing their own scripts.
Post Reply
M
MasterScript
Halfop
Posts: 41
Joined: Tue Apr 26, 2005 1:44 am

Need help change command

Post by MasterScript »

i have a tcl script to check access
Public command /msg botnet access #chan nick
For example: /msg botnet access #bots MasterScript

I need some help to change this to /msg botnet access nick
For example: /msg botnet access MasterScript

It means remove chan.

There is the tcl script:

access

Code: Select all

proc do_access {nick chan msbots1 host} {
  # This proc MUST be kept as streamlined as possible

  global home botnick bcast

  if {![validchan $chan]} {
    putquick "NOTICE $nick :\0034ERROR: \002$chan\002 is not a registered channel."
    return 0
  } elseif {$msbots1 == ""} {
    putquick "NOTICE $nick :\0034ERROR: Please use: \002(/msg) $botnick access <#channel> <nick>\002"
    return 0
  } elseif {![onchan $msbots1 $chan]} {
    putquick "NOTICE $nick :\0034ERROR: \002$msbots1\002 isn't in $chan"
    return 0
  }

  if {[validuser $msbots1]} {
    set hand2 $msbots1
    set hand3 [nick2hand $hand2 $chan]
  } elseif {[validuser [nick2hand $msbots1 $chan]]} {
    set hand2 $msbots1
    set hand3 [nick2hand $hand2 $chan]
  } else {
    putquick "NOTICE $nick :\0034ERROR: \002$msbots1\002 is not a valid user."
    return 0
  }

  set access "N/A"

  # Default global access to null string for use later on  
  set gaccess "" 

  if {[matchattr $hand3 |v $chan]} {
    set access "Automatically Voiced"
  } elseif {[matchattr $hand3 |a $chan]} {
    set access "Automatic Operator"
  } elseif {[matchattr $hand3 |o $chan]} {
    set access "Channel Operator"
  } elseif {[matchattr $hand3 |m $chan]} {
    set access "Channel Co-Administrator"
  } elseif {[matchattr $hand3 |n $chan]} {
    set access "Channel Administrator"
  } elseif {[matchattr $hand3 n]} {
    set gaccess "Bot Administrator"
  } elseif {[matchattr $hand3 m]} {
    set gaccess "Botnet Co-Administrator"
  } elseif {[matchattr $hand3 o]} {
    set gaccess "Botnet Operator"
  }

  set rhosts [getuser $hand3 HOSTS]
  set comment [getchaninfo $hand3 $chan]

  putlog "!$nick ($host)! access $chan $hand3"

  if {$bcast == "1"} {
    putquick "PRIVMSG $home :$nick!$host requested to see access for $hand3 on $chan ..showing..."   
  }

  putquick "NOTICE $nick :\002Nickname:\002 \00312$hand2"
  putquick "NOTICE $nick :\002Handle:\002 \00312$hand3"
  putquick "NOTICE $nick :\002Access in $chan:\002 \00312$access"
  putquick "NOTICE $nick :\002Comment:\002 \00312$comment"
  putquick "NOTICE $nick :\002Remote Hostnames:\002 \00312$rhosts" 


  if {[matchattr $hand3 D]} {
    putquick "NOTICE $nick :\0033\002$hand2\002\0034 is a disabled user."
    return 0  
  }

  # Now display global permissions if anoy
  if {$gaccess != ""} {
    putquick "NOTICE $nick :\002Global Permissions:\002\00312 $gaccess"
  }

  return 0
}


Check Access

Code: Select all

proc checkaccess {hand1 chan hand2} {
  set hand1lev 0
  set hand2lev 0      

  if {[matchattr $hand1 |a $chan]} {
    set hand1lev 1
  }
  if {[matchattr $hand1 |v $chan]} {
    set hand1lev 2
  } 	
  if {[matchattr $hand1 |o $chan]} {
    set hand1lev 3
  }   
  if {[matchattr $hand1 |m $chan]} {
    set hand1lev 4
  }
  if {[matchattr $hand1 |n $chan]} {
    set hand1lev 5
  }
  if {[matchattr $hand1 o]} {
    set hand1lev 6
  }
  if {[matchattr $hand1 m]} {
    set hand1lev 7
  }
  if {[matchattr $hand1 n]} {
    set hand1lev 8
  }
  if {[matchattr $hand2 |a $chan]} {
    set hand2lev 1
  }     
  if {[matchattr $hand2 |v $chan]} {
    set hand2lev 2
  }
  if {[matchattr $hand2 |o $chan]} {
    set hand2lev 3
  }	
  if {[matchattr $hand2 |m $chan]} {
    set hand2lev 4
  }
  if {[matchattr $hand2 |n $chan]} {
    set hand2lev 5
  }
  if {[matchattr $hand2 o]} {
    set hand2lev 6
  }
  if {[matchattr $hand2 m]} {
    set hand2lev 7
  }
  if {[matchattr $hand2 n]} {
    set hand2lev 8
  }
  set result [expr $hand1lev - $hand2lev]

  if {$result == -1 } { return 0 }
  if {$result == -2 } { return 0 }
  if {$result == -3 } { return 0 }
  if {$result == -4 } { return 0 }	
  if {$result == -5 } { return 0 }

  return $result
}
Msg Access

Code: Select all

proc msg:access {nick host handle arg} {
  global botnick

  # Argument = channel
  set argument [lindex $arg 0]

  if {[string match "#*" $argument]} {
    if {[validchan $argument]} {
      set chan $argument
      set msbots1 [lindex $arg 1]
    } else {
      putquick "NOTICE $nick :\0034ERROR - This bot is not in $argument."
      return 0
    }
  } else {
    putquick "NOTICE $nick :\0034ERROR - You need to specify a channel."
    return 0
  }

  do_access $nick $chan $msbots1 $host
  return 0
}
Post Reply