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.

A bit different devoice script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
o
ozgur1
Voice
Posts: 1
Joined: Sun Apr 15, 2012 5:35 pm

A bit different devoice script

Post by ozgur1 »

Hello Everyone,

I need a little different .tcl for my eggdrop.

I'll use it on Quakenet.I want to devoice who had been voiced by @'s except Q bot.e.g If I voice someone my bot will devoice him.But if Q voice him my eggdrop will do nothing.I found a little code for irc script but i couldn't find .tcl version of it.Here is the script version of it.Maybe it helps to understand what i want :P the hostmask is belong to Q bot.If there is a few way to do it i'll really appreciate.

Code: Select all

on *:VOICE:#CHANNEL:{
  if ($address($nick,2) != *!*@CServe.quakenet.org) { mode # -v $vnick }
}
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

You can try this code
So what will actually do is if someone will voice an user on that specified channel from the script and its not Q it will devoice the user who got voiced. If bot voices someone he wont do anything

Code: Select all

bind MODE - * egghelp:mode

set temp(devoice) #saphira

proc egghelp:mode {nick uhost hand chan mode target} {
	global temp

	switch -exact -- $mode {
		"+v" {
			if {[string tolower $temp(devoice)] == [string tolower $chan]} {
				if {![string match -nocase "*CServe.quakenet.org*" [lindex [split $uhost @] 1]] || ![isbotnick $nick]} {
					pushmode $chan -v $target
				}
			}
		}
	}
}
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What will happen if the mode change is not just +v? For example: +vo user1 user2
Once the game is over, the king and the pawn go back in the same box.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

He only asked for a script that will devoice used who are not voiced by Q (or the bot himself) if the user gets +vo i don`t think -v would mean something tot that user. So i only matched the +v channel mode and never tested for +vo

But i will make another version now that you mentioned that


### EDIT
I tested for +vo it seems like the bot keeps tracks for every mode once so its should be ok
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Mode bindings are indeed triggered once for each mode, not once for the MODE command. Separating which parameter (in this case, the nickname), is also handled by eggdrop itself - target will always be the parameter applied to this mode-change (or empty string in the event that the current mode-change does not have a parameter).
NML_375
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I knew that, my point was that the egghelp:mode would have been triggered for each mode change in particular. For instance, in a +vvvvvv user1 user2 user3 user4 user5 user6 mode, the egghelp:mode would be triggered 6 times.

A better way to deal with this would have been a raw mode bind.
Once the game is over, the king and the pawn go back in the same box.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Since the script uses pushmode, you'd still gain the mode-stacking advantage, yet you don't have to bother with dividing up each mode change yourself. As for the performance impact, 1 bind trigger as opposed to 6, I'd consider that neglible.

If you're a real Cookie Cutter, Just change the bind mask from * to "#saphira +v", and skip the checks for channelname and mode:

Code: Select all

bind MODE - "#saphira +v" egghelp:mode

proc egghelp:mode {nick host handle channel mode target} {
  if {![string match -nocase "*CServe.quakenet.org*" [lindex [split $host @] 1]] || ![isbotnick $nick]} {
    pushmode $channel -v $target
  }
}
NML_375
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Im just not used to use
bind MODE - "#saphira +v" egghelp:mode
Yet i will try use something like this in the future ... and i used string tolower to check the channel because in the past i encoutered problems with the channel names. $temp(chan) != $chan (#Saphira with #saphira) sometimes the eggdrop would recognise the channel with an "S" and sometimes with 's'

So thanks for the hints :)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Madalin,
No worries, your code looks good enough to me. Using switch might be a bit excessive, but then again, it makes the function easy to extend for other modes as well.

If you don't care for compatibility with older versions of tcl, you could use "string equal -nocase $temp(devoice) $chan" when comparing the channel (as for the case of the channel name, that all comes down to what the actual mode-changer used).
NML_375
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

I always use that kind of code. I like using switch because it gives me alot of movement in the future if i want to update the script and its easier to read the code atleast for me
Post Reply