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 

A bit different devoice script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ozgur1
Voice


Joined: 15 Apr 2012
Posts: 1

PostPosted: Sun Apr 15, 2012 5:42 pm    Post subject: A bit different devoice script Reply with quote

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 Razz the hostmask is belong to Q bot.If there is a few way to do it i'll really appreciate.

Code:

on *:VOICE:#CHANNEL:{
  if ($address($nick,2) != *!*@CServe.quakenet.org) { mode # -v $vnick }
}
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Jan 27, 2013 9:23 am    Post subject: Reply with quote

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:

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
            }
         }
      }
   }
}

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sun Jan 27, 2013 9:35 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Jan 27, 2013 9:37 am    Post subject: Reply with quote

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
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Jan 27, 2013 10:44 am    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sun Jan 27, 2013 2:59 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Jan 27, 2013 3:10 pm    Post subject: Reply with quote

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:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Jan 27, 2013 3:30 pm    Post subject: Reply with quote

Im just not used to use

Quote:
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 Smile
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Jan 27, 2013 3:38 pm    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Jan 27, 2013 3:40 pm    Post subject: Reply with quote

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
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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