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 writting small protection tcl.

Old posts that have not been replied to for several years.
Locked
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Need help writting small protection tcl.

Post by Gothic-Angel »

I want to write a tcl to check when someone's deoped if that person matches a certain flag then deop the person who deoped the protected user and reop the protected user.

Im not really sure where to start, I'd just like hints and tips and snippets of code not someone just saying "do it like this"
I like to learn hehe

Thanks for any help...
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set theflag "m"

bind mode - "* -o" protect:deop

proc protect:deop {nick uhost hand chan mc vict} {
  if {[matchattr [nick2hand $vict $chan] $::theflag $chan]} {
    # here you add your stuff to do when one of my friends just got deoped..
  }
}
Once the game is over, the king and the pawn go back in the same box.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

What's the use of "mc" in the proc line for?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Gothic-Angel wrote:What's the use of "mc" in the proc line for?
check tcl-commands.doc (bind mode)
Have you ever read "The Manual"?
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

Well I'v got all that and I'v added in a few other things, now Im stuck on ban protection.

It seems Im having a hard time even getting it to trigger the proc I know that my bind on the mode switch is right yet I can't get my proc to trigger.

Care to give me some idea's on how to write up some basic ban protections?
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

Code: Select all

proc protect:ban {nick uhost hand chan mc vict} {
  if {[matchattr [nick2hand $vict $chan] $::theflag $chan]} {
   putserv "MODE $chan -o+o $nick $vict"
    set Victimhost [getchanhost $vict $chan]
     set Victimbanmask "*!*[string range $uhost [string first "@" $Victimhost] end]"
   pushmode $chan -b $Victimhost
  pushmode $chan -b $Victimbanmask
  }
}
Give me some guidance heheh
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

$Victimhost returns ident@host of the victim, then:

Code: Select all

set Victimbanmask "*!*[string range $uhost [string first "@" $Victimhost] end]"
will not return what you want.
it should be:

Code: Select all

set Victimbanmask "*!*[string range $victimhost [string first "@" $Victimhost] end]"
or

Code: Select all

set Victimbanmask *!*@[lindex [split $Victimhost @] 1]
and remove the pushmode $chan -b $Victimhost line.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

try this one..

Code: Select all

bind mode - "* +b" protect:ban

proc protect:ban {nick uhost hand chan mc ban} {
  if {![botisop $chan]} {
    return
  }
  if {[string match -nocase $ban $::botname]} {
    if {[matchattr $hand $::theflag]} {
      putquick "MODE $chan -b $ban"
      return
    }
    scan $uhost "%\[^@\]@%s" host
    putquick "MODE $chan -bo+b $ban $nick *!*@$host"
    newchanban $chan *!*@$host Moron "Don't place bans that matches me moron!" 1440
    return
  }
  foreach luser [chanlist $chan $::theflag] {
    if {[string match -nocase $ban $luser![getchanhost $luser $chan]]} {
      if {[matchattr $hand mn|mn $chan]} {
        putquick "MODE $chan -b $ban"
        return
      }
      scan $uhost "%\[^@\]@%s" host
      putquick "MODE $chan -bo+b $ban $nick *!*@$host"
      newchanban $chan *!*@$host Moron "Don't place bans that matches one of my friends moron!" 1440
    }
  }
}
Once the game is over, the king and the pawn go back in the same box.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

Tcl error [protect:ban]: different numbers of variable names and field specifiers


Is the error I keep getting when directly pasting only your code and running it.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Yes, noticed that myself.. replace the "scan $uhost "%\[^@\]@%s" host " lines with: scan $uhost "%\[^@\]@%s" user host
Once the game is over, the king and the pawn go back in the same box.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

caesar wrote:Yes, noticed that myself.. replace the "scan $uhost "%\[^@\]@%s" host " lines with: scan $uhost "%\[^@\]@%s" user host
Or...

Code: Select all

scan $uhost {%*[^@]@%s} host
.. which is what I think you meant initially (you just left that * out) :)
Have you ever read "The Manual"?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Yup. Forgot to remove it as you've tiped me before :) Didn't remembered about it.. seesh! :-?
Once the game is over, the king and the pawn go back in the same box.
G
Gothic-Angel
Op
Posts: 109
Joined: Mon Sep 23, 2002 9:46 pm

Post by Gothic-Angel »

How would I go about changing the ban mask to *!*ident@*partial host ?

I really appreciate the help I'v got it working and added a bit onto it with other modes and stuff its comong alone well works fine with the current ban mask would just like to change it up a bit.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set victimhost [maskhost *$uhost]
this returns *!*ident@xx.xx.xx.*
Locked