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.

+v voice ?

Help for those learning Tcl or writing their own scripts.
Post Reply
p
pektek
Halfop
Posts: 41
Joined: Sat Jul 01, 2023 4:51 pm

+v voice ?

Post by pektek »

The autovoice part is all working fine when the user joins the bot sets +v automatically, but when that person changes nickname they remain +v

However it doesnt seem to be effecting the user when they change their nick to anything else.

Code: Select all

bind nick - * bla

proc bla {nick uhost hand chan nn} {
 global wasvoice
 if {[isvoice $nn $chan]} {
  pushmode $chan -v $nn
  set wasvoice([string tolower $nick:$chan]) 1
 } {
  if {[info exists wasvoice([set nc [string tolower $nn:$chan]])]} {
   pushmode $chan +v $nn
   unset wasvoice($nc)
  }
 }
}
User avatar
CrazyCat
Revered One
Posts: 1240
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: +v voice ?

Post by CrazyCat »

What do you mean ?
The user doesn't get his voice when he regains his previous nick ?

I made a little test (and some little modifications):
bind nick - * checkvoice

proc checkvoice {nick uhost handle chan newnick} {
   set onchash [md5 [string tolower "${nick}:${chan}"]]
   set nnchash [md5 [string tolower "${newnick}:${chan}"]]
   if {[isvoice $newnick $chan]} {
      pushmode $chan -v $newnick
      set ::wasvoice($onchash) 1
   } elseif {[info exists ::wasvoice($nnchash)] && $::wasvoice($nnchash)==1} {
      pushmode $chan +v $newnick
      unset ::wasvoice($nnchash)
   }
}
This works. I use md5 of $nick:$chan (and $newnick:$chan) because arrays sometime dislike non alnum characters in keys
p
pektek
Halfop
Posts: 41
Joined: Sat Jul 01, 2023 4:51 pm

Re: +v voice ?

Post by pektek »

thank you CrazyCat

Can I do this in TCL AOPs, for example ?
User avatar
CrazyCat
Revered One
Posts: 1240
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: +v voice ?

Post by CrazyCat »

What is Tcl AOP ?
p
pektek
Halfop
Posts: 41
Joined: Sat Jul 01, 2023 4:51 pm

Re: +v voice ?

Post by pektek »

No, can we apply this to AOPs?

@ aop 🙂
User avatar
CrazyCat
Revered One
Posts: 1240
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: +v voice ?

Post by CrazyCat »

Oh, I understand :) But not all...
Explain what you want to do.
p
pektek
Halfop
Posts: 41
Joined: Sat Jul 01, 2023 4:51 pm

Re: +v voice ?

Post by pektek »

Let's not only cover voices. Let's apply it to aop and sop as well

aop @
Sop & 🙂
User avatar
CrazyCat
Revered One
Posts: 1240
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: +v voice ?

Post by CrazyCat »

You can do that for the @ (but just op, not aop), I'm not sure you can add the sop.
Eggdrop doesn't know these modes, so it can't check if an op is aop nor sop.
p
pektek
Halfop
Posts: 41
Joined: Sat Jul 01, 2023 4:51 pm

Re: +v voice ?

Post by pektek »

How can we do it for op?
User avatar
CrazyCat
Revered One
Posts: 1240
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: +v voice ?

Post by CrazyCat »

By replacing "isvoice" check with "isop" and mode +/-v with +/-o

Small tip: https://docs.eggheads.org/using/tcl-com ... me-channel
p
pektek
Halfop
Posts: 41
Joined: Sat Jul 01, 2023 4:51 pm

Re: +v voice ?

Post by pektek »

bind nick - * checkvoice

proc checkvoice

wasvoice

What will we do here?

Code: Select all

bind nick - * checkvoice

proc checkvoice {nick uhost handle chan newnick} {
   set onchash [md5 [string tolower "${nick}:${chan}"]]
   set nnchash [md5 [string tolower "${newnick}:${chan}"]]
   if {[isvoice $newnick $chan]} {
      pushmode $chan -v $newnick
      set ::wasvoice($onchash) 1
   } elseif {[info exists ::wasvoice($nnchash)] && $::wasvoice($nnchash)==1} {
      pushmode $chan +v $newnick
      unset ::wasvoice($nnchash)
   }
}
User avatar
CrazyCat
Revered One
Posts: 1240
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: +v voice ?

Post by CrazyCat »

Peharps can you try to understand what the code does, read the doc and try to adapt. OR, to say that quicker: learn.
bind nick - * checkvoice # name of the called procedure is checkvoice

proc checkvoice {nick uhost handle chan newnick} {
   set onchash [md5 [string tolower "${nick}:${chan}"]]
   set nnchash [md5 [string tolower "${newnick}:${chan}"]]
   if {[isvoice $newnick $chan]} {
   # here we check if nick is voiced, isop will check if user is @
      pushmode $chan -v $newnick
      # removes the v flag
      set ::wasvoice($onchash) 1
      # we set a temp variable called wasvoice
   } elseif {[info exists ::wasvoice($nnchash)] && $::wasvoice($nnchash)==1} {
   # we check if the temp variable exists and is setted to 1
      pushmode $chan +v $newnick
      # we set the v flag to the user
      unset ::wasvoice($nnchash)
      # deleting the temp variable
   }
}
You have enough comments in the script now to adapt it for @
p
pektek
Halfop
Posts: 41
Joined: Sat Jul 01, 2023 4:51 pm

Re: +v voice ?

Post by pektek »

Thank you for your help Crazycat
Post Reply