on 3r kick = remuser.

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

on 3r kick = remuser.

Post by Nor7on »

Hi.

I have this code, it suspend when a Op kicked other Op via X.

So i want add when is first kick, suspend only 3Days. if kick again, suspend for 5 days, and if continue one kick more, my eggdrop run this comand:
.-user $kicker(user)
.msg x remuser #mychan username of kicker.

but the code only put chattr +Y, if continue, don't put -Y+E

something wrong?

code:

Code: Select all

bind kick - * xstuff:kick

proc xstuff:kick {nick host hand chan target reason} {
	global knick
    if {[matchattr [nick2hand $target $chan] b|b $chan] || [matchattr [nick2hand $target $chan] o|o $chan]} {
    set kicker [string trim [lindex [split $reason] 0] {()}]
	set knick [nick2hand $kicker]
	if {$hand == "*"} {set hand $kicker} 
          chattr $hand +Y
	      putserv "PRIVMSG X :SUSPEND $chan $kicker 2d"
			putlog "Suspendiendo el username $kicker y cambiando flag a $hand"
          return 0
	} elseif {([matchattr $hand Y])} {
	  chattr $hand -Y+E
	      putserv "PRIVMSG X :SUSPEND $chan $kicker 3d"
          return 1
	} elseif {([matchattr $hand E])} {
	  deluser $hand
      putserv "PRIVMSG X :REMUSER $chan $kicker"
          return 1
	} 

}
putlog "Suspend and remuser"
some1 can helpme?

Thanks. :oops:
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

bind kick - * xstuff:kick

proc xstuff:kick {nick host hand chan target reason} {
	if {[matchattr [nick2hand $target $chan] b|b $chan] || [matchattr [nick2hand $target $chan] o|o $chan]} {
		set kicker [string trim [lindex [split $reason] 0] {()}]
		if {[string match -nocase "\*" [lindex [split $hand] 0] } {
			set hand [nick2hand $kicker]
		}
		if {[matchattr $hand E]} {
			deluser $hand
			putserv "PRIVMSG X :REMUSER $chan $kicker"
			return 1
		} elseif {[matchattr $hand Y]} {
			chattr $hand -Y+E
			putserv "PRIVMSG X :SUSPEND $chan $kicker 3d"
			return 1
		} else {
			chattr $hand +Y
			putserv "PRIVMSG X :SUSPEND $chan $kicker 2d"
			putlog "Suspendiendo el username $kicker y cambiando flag a $hand"
			return 1
		}
	} else {
		return 0
	}
}

putlog "Suspend and remuser" 
You misplaced a curly brace, and forgot to construct your if statements in the correct conditional order. You realize, since everything is handled within the procedure (invoked by a public kick bind), using 'return' statements isn't really necessary at all, right?

Edit: try again.. works
Last edited by speechles on Mon Jun 16, 2008 5:52 pm, edited 6 times in total.
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

ok i try.

one momet.
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

thanks speechles, its work...

but have a little problem... don't find the user.

i have an user at userlist of my eggdrop: XCarlos
urs nickname in IRC is: Carlos

so, the $hand don't change flag to XCarlos, it do this: chattr Carlos +Y
but Carlos is not an user in the userlist.

someting wrong?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

try the edited code above, fixes that problem.
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

buff i try but can't fix this :oops:
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

bind kick - * xstuff:kick

proc xstuff:kick {nick host hand chan target reason} {
   if {[matchattr [nick2hand $target $chan] b|b $chan] || [matchattr [nick2hand $target $chan] o|o $chan]} {
      set kicker [string trim [lindex [split $reason] 0] {()}]
      set hand [nick2hand $kicker]

      if {[matchattr $hand E]} {
         deluser $hand
         putserv "PRIVMSG X :REMUSER $chan $kicker"
         return 1
      } elseif {[matchattr $hand Y]} {
         chattr $hand -Y+E
         putserv "PRIVMSG X :SUSPEND $chan $kicker 3d"
         return 1
      } else {
         chattr $hand +Y
         putserv "PRIVMSG X :SUSPEND $chan $kicker 2d"
         putlog "Suspendiendo el username $kicker y cambiando flag a $hand"
         return 1
      }
   }
} 
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

hi metroid.

the script only recognizes the $kicker but not the $hand
yeah suspend the username, but no recognizes $hand.

what happend ;/.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

variable adminlist "nick1 nick2 nick3"

bind kick - * xstuff:kick

proc xstuff:kick {nick host hand chan target reason} {
   if {[matchattr [nick2hand $target $chan] b|b $chan] || [matchattr [nick2hand $target $chan] o|o $chan]} {
      set kicker [string trim [lindex [split $reason] 0] {()}]
      set hand [nick2hand $kicker $chan]
      if {[string match -nocase "\*" [lindex [split $hand] 0]] } {
         xstuff:admin "X ha utilizado para patada $target. No puedo suspender $kicker. Este usuario no tiene asa."
         return 0
      } elseif {[lindex [split $hand] 0] == ""} {
         xstuff:admin "X ha utilizado para patada $target. No puedo suspender $kicker. No se puede encontrar este apodo en irc por más tiempo.."
         return 0
      }
      if {[matchattr $hand E]} {
         deluser $hand
         putserv "PRIVMSG X :REMUSER $chan $kicker"
         return 1
      } elseif {[matchattr $hand Y]} {
         chattr $hand -Y+E
         putserv "PRIVMSG X :SUSPEND $chan $kicker 3d"
         return 1
      } else {
         chattr $hand +Y
         putserv "PRIVMSG X :SUSPEND $chan $kicker 2d"
         putlog "Suspendiendo el username $kicker y cambiando flag a $hand"
         return 1
      }
   } else {
      return 0
   }
}

proc xstuff:admin {text} {
   foreach admin $::adminlist {
      putserv "privmsg $admin :$text"
   }
}

putlog "Suspend and remuser"
There are two instances where admins will be needed. Fill the admin list at top with a list of nicks you want alerted when the suspend script cannot: a) find the nickname on irc b) cannot find the handle record for nick

Edit: corrected missing bracket according to post below, all is well now.
Last edited by speechles on Sat Jun 28, 2008 11:45 am, edited 2 times in total.
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

Code: Select all

<Chasse> [15:28] #Nor7on# set errorInfo
<Chasse> Currently: missing close-bracket
<Chasse> Currently:     ("if" test expression)
<Chasse> Currently:     while compiling
<Chasse> Currently: "if {[string match -nocase "\*" [lindex [split $hand] 0] } {
<Chasse> Currently:          xstuff:admin "$kicker has used X to kick $target. I cannot suspend $kicker. This ..."
<Chasse> Currently:     ("if" then script line 4)
<Chasse> Currently:     while compiling
<Chasse> Currently: "if {[matchattr [nick2hand $target $chan] b|b $chan] || [matchattr [nick2hand $target $chan] o|o $chan]} {
<Chasse> Currently:       set kicker [string trim [lindex [split..."
<Chasse> Currently:     (compiling body of proc "xstuff:kick", line 2)
<Chasse> Currently:     invoked from within
<Chasse> Currently: "xstuff:kick $_kick1 $_kick2 $_kick3 $_kick4 $_kick5 $_kick6"
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Use the edited script above, forgot a simple bracket on the string match.. DOH! Humans being human, this is what we do, we make mistakes.
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

i have windrop 1.6.18 i paste this code exactly

Code: Select all

variable adminlist "Nor7on^"

bind kick - * xstuff:kick

proc xstuff:kick {nick host hand chan target reason} {
   if {[matchattr [nick2hand $target $chan] b|b $chan] || [matchattr [nick2hand $target $chan] o|o $chan]} {
      set kicker [string trim [lindex [split $reason] 0] {()}]
      set hand [nick2hand $kicker $chan]
      if {[string match -nocase "\*" [lindex [split $hand] 0] } {
         xstuff:admin "X ha utilizado para patada $target. No puedo suspender $kicker. Este usuario no tiene asa."
         return 0
      } elseif {[lindex [split $hand] 0] == ""} {
         xstuff:admin "X ha utilizado para patada $target. No puedo suspender $kicker. No se puede encontrar este apodo en irc por más tiempo.."
         return 0
      }
      if {[matchattr $hand E]} {
         deluser $hand
         putserv "PRIVMSG X :REMUSER $chan $kicker"
         return 1
      } elseif {[matchattr $hand Y]} {
         chattr $hand -Y+E
         putserv "PRIVMSG X :SUSPEND $chan $kicker 3d"
         return 1
      } else {
         chattr $hand +Y
         putserv "PRIVMSG X :SUSPEND $chan $kicker 2d"
         putlog "Suspendiendo el username $kicker y cambiando flag a $hand"
         return 1
      }
   } else {
      return 0
   }
}

proc xstuff:admin {text} {
   foreach admin $::adminlist {
      putserv "privmsg $admin :$text"
   }
}

putlog "Suspend and remuser"
when some1 kickme get this error in partyline.

Code: Select all

<Chasse> [15:45] Tcl error [xstuff:kick]: missing close-bracket
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Nor7on wrote:i have windrop 1.6.18 i paste this code exactly

Code: Select all

variable adminlist "Nor7on^"

bind kick - * xstuff:kick

proc xstuff:kick {nick host hand chan target reason} {
   if {[matchattr [nick2hand $target $chan] b|b $chan] || [matchattr [nick2hand $target $chan] o|o $chan]} {
      set kicker [string trim [lindex [split $reason] 0] {()}]
      set hand [nick2hand $kicker $chan]
      if {[string match -nocase "\*" [lindex [split $hand] 0] } {
         xstuff:admin "X ha utilizado para patada $target. No puedo suspender $kicker. Este usuario no tiene asa."
         return 0
      } elseif {[lindex [split $hand] 0] == ""} {
         xstuff:admin "X ha utilizado para patada $target. No puedo suspender $kicker. No se puede encontrar este apodo en irc por más tiempo.."
         return 0
      }
      if {[matchattr $hand E]} {
         deluser $hand
         putserv "PRIVMSG X :REMUSER $chan $kicker"
         return 1
      } elseif {[matchattr $hand Y]} {
         chattr $hand -Y+E
         putserv "PRIVMSG X :SUSPEND $chan $kicker 3d"
         return 1
      } else {
         chattr $hand +Y
         putserv "PRIVMSG X :SUSPEND $chan $kicker 2d"
         putlog "Suspendiendo el username $kicker y cambiando flag a $hand"
         return 1
      }
   } else {
      return 0
   }
}

proc xstuff:admin {text} {
   foreach admin $::adminlist {
      putserv "privmsg $admin :$text"
   }
}

putlog "Suspend and remuser"
when some1 kickme get this error in partyline.

Code: Select all

<Chasse> [15:45] Tcl error [xstuff:kick]: missing close-bracket
I fixed it, see the code above where I originally posted it with adminlist config setting. There was indeed a missing closing bracket on the string match that has since been addressed. It will now work as intended for you, and when it doesn't will message one of your admin's why it isn't doing what is expected.

Code: Select all

      if {[string match -nocase "\*" [lindex [split $hand] 0] } { 

Code: Select all

      if {[string match -nocase "\*" [lindex [split $hand] 0]] } { 
Top is incorrect, missing bracket. Bottom is correct, brackets align. This is the error you see.
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

it work, but dont change flag when an user kick to other user with different name . ex:

Code: Select all

^Modo^ is nor7on@Colmillo.users.undernet.org
Nombre : Visita: ------------
Canales : @#chan1 @#chan2 @#chan3
Servidor : *.undernet.org - The Undernet Underworld
Modo is Logged how: Colmillo

<Nor7on^> .whois Modo
<Chasse> HANDLE    PASS NOTES FLAGS           LAST
<Chasse> Modo      no       0 bflo            17:28 (#Madrid)
<Chasse>   HOSTS: *!*@Colmillo.users.undernet.org
<Chasse>   ADDRESS: xx.xxx.xxx.x
<Chasse>      users: xxxx, bots: xxxx
when ^Modo^(Colmillo) kick via X to me, Chasse can't change flag to Colmillo or ^Modo^.'cause don't find Colmillo or ^Modo^ in userlist.

so there is some way to instert a database for:

$username = $hand

example:

Colmillo = Modo
Alask = Alaska
Ligre = Felino

if it finds "Colmillo" in the kick message, it read the database for change flag to Modo.
if it finds "Ligre" in the kick message, it read the database for change flag to Felino.
etc...

some suggestion? it's possible?
Post Reply