egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help change command

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
MasterScript
Halfop


Joined: 26 Apr 2005
Posts: 41

PostPosted: Wed Jan 16, 2013 8:17 pm    Post subject: Need help change command Reply with quote

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:
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:
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:
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
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber