mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2010
Posts: 30
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2010
Posts: 30
I need an autovoice script which allows me to devoice in a moderated channel; adding the ip/host to a black list so that the devoiced nick cannot return and be voiced again unless I remove it.

I should be able to view the list of devoiced nicks so that I can highlight and remove if necessary.


Is anyone up to this challange?


DS



Joined: Jan 2011
Posts: 9
N
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
N
Joined: Jan 2011
Posts: 9
I tried tackling this, and came with some success. All in Remote section.

Ins and Outs: The IP Blacklist works to the best of my knowledge, all you have to do is Right-Click their name in the Channel's namelist and highlight Devoice 'EM and then you have two options. You can Perm DV or Timed DV. The timed has some preset times and a Custom time setting. Right clicking the chat area will let you view the 'IP' list in: "Username -- IP" format. The demuting feature isn't up to the standards you stated, but all you have to do is rightclick namelist and hit De-Devoice and type their name in. Also have a simple Autovoice and a Refresh button in the IP list-window. Hope you enjoy, it was fun to make, besides a few headaches. ^^

Code:
on *:JOIN:#: {
  if ( $read(dvupkeep.txt, s, $nick ) != $null ) {
    /notice $nick You are still muted.
  }
  else {
    /mode # +v $nick
  }
}
Menu channel {
  View Devoice List:{
    /window @Devoice -l
    var %blahhityblah = 1
    while (%blahhityblah <= $lines(dvupkeep.txt) ) {
      /aline -c @Devoice $read( dvupkeep.txt, %blahhityblah )
      inc %blahhityblah
    }
  }
}
Menu nicklist {
  Devoice 'EM!
  .Perm DVoice: {
    if ( $read(dvupkeep.txt, w, * $+ $address( $$1 $+ ,1) $+ * ) == $null ) {
      /write dvupkeep.txt $$1 -- $address( $$1 $+ ,1)
      /mode # -v $$1
    }
    else {
      /notice $me That name is already in the Devoice List.
    }
  }
  .Timed DVoice
  ..One Minute: {
    /mode # -v $$1
    /write dvupkeep.txt $$1 -- $address( $$1 $+ ,1 )
    timer $+ $1 1 60 /mode # +v $$1
    timer $+ $1 $+ 2 1 60 /write -ds $+ $$1 dvupkeep.txt
  }
  ..Five Mins: {
    /mode # -v $$1
    /write dvupkeep.txt $$1 -- $address( $$1 $+ ,1)
    timer $+ $1 1 300 /mode # +v $$1
    timer $+ $1 $+ 2 1 300 /write -ds $+ $$1 dvupkeep.txt
  }
  ..15 Mins: {
    /mode # -v $$1
    /write dvupkeep.txt $$1 -- $address( $$1 $+ ,1)
    timer $+ $1 1 900 /mode # +v $1
    timer $+ $1 $+ 2 1 900 /write -ds $+ $$1 dvupkeep.txt
  }
  ..30 Mins: {
    /mode # -v $$1
    /write dvupkeep.txt $$1 -- $address( $$1 $+ ,1)
    timer $+ $1 1 1800 /mode # +v $1
    timer $+ $1 $+ 2 1 1800 /write -ds $+ $$1 dvupkeep.txt
  }
  ..Custom: {
    var %ctime $+ $1 = $?="Enter how many seconds."
    /mode # -v $$1
    /write dvupkeep.txt $$1 -- $address( $$1 $+ ,1)
    timer $+ $1 1 $! /mode # +v $1
    timer $+ $1 $+ 2 1 $! /write -ds $+ $$1 dvupkeep.txt 
  }
  De-Devoice:{
    /write -ds $+ $?="Enter name to delete."  dvupkeep.txt
    /mode # +v $!
  }
}
Menu @Devoice {
  Refresh List: {
    /window @Devoice -l
    var %blahhityblah = 1
    while (%blahhityblah <= $lines(dvupkeep.txt) ) {
      /aline -c @Devoice $read( dvupkeep.txt, %blahhityblah )
      inc %blahhityblah
    }
  }  
}




Quick edit before I forget: When you first use it, you may want to click PermDV then unmute a dummy account in a room. That should setup the .txt you'll need. After that Autovoice will work X_X

Last edited by Nonborn; 24/01/11 09:51 AM.
Joined: Jul 2010
Posts: 30
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2010
Posts: 30
well bless your heart!!

I am going to try this out right now.

If others come along and say " You could have done it this way or that way..." and make changes, I will try them too.

Thank you very much. I am glad you had fun doing it.

DS

Joined: Jan 2011
Posts: 9
N
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
N
Joined: Jan 2011
Posts: 9
Well, it's open for suggestions. If anyone has any.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Looks good the way you have it, but just a couple suggestions. First, and I think you know this because you don't use them everywhere... you don't need / in front of commands within a script. Of course, if you prefer them there, they don't hurt anything.

Second, you can use /filter for this:
Code:
Menu @Devoice {
  Refresh List: {
    /window @Devoice -l
    var %blahhityblah = 1
    while (%blahhityblah <= $lines(dvupkeep.txt) ) {
      /aline -c @Devoice $read( dvupkeep.txt, %blahhityblah )
      inc %blahhityblah
    }
  }  
}


So it looks like this:
Code:
Menu @Devoice {
  Refresh List: {
    if ($window(@Devoice)) { clear @Devoice }
    else { window @Devoice -l }
    filter -fw dvupkeep.txt @Devoice
  }  
}


If may not look much shorter, but one of those lines (the if line) is there to clear the list to avoid duplication of the list if refreshed while the window is already displaying a list. So that's an extra line that wasn't already there. Anyhow, besides being shorter, /filter is faster than $read() for this sort of thing.


* Note that this same change will also work for the View Devoice List menu item as well.


EDIT: One other change I would suggest making... You're saving the information in the file starting with "nick --". Currently, you're searching the file with just $nick. The problem with that is that If someone joins with a nick of "nick" and there's a nick in the file of "nickname", your search will find a match. If you instead search for "$nick --", it will only find a match if the nick is an exact match.

This also affects the timers as those will also potentially erase the wrong information for the same reason.

Another thing you might consider is checking to see if the nick is already in the text file before allowing a menu item to be used. Right now, you could add the same person to the file as many times as you want to (they won't overwrite).

And, thinking about this more, you might want to consider a "safer" method of tracking the timer information. Normally, the way you have it will work well. However, if you close mIRC (or it crashes) while timers are running, they will not be running when you start mIRC again. This means that anyone who was on a timed "mute" will end up being listed as permanently "muted" because nothing will remove them from the list. The "safer" method would be to also store $ctime + amount of time to be "muted" and use on START to remove anything that is expired.

EDIT2: Ok, something else... Personally, I'd silence every timer (.timer instead of timer) so they don't show up all of the time. Also, the timers do not verify that the nick is still in the channel. That means that anytime someone leaves the channel while "muted," there will be an error message when the timer triggers. It might not make any significant difference, but it's not nice to look at. I think I'd have all of the +v timers point to an alias that will check if the nick is still in the channel and voice them if they are. My using an alias, you save a lot of duplication of lines. You could also use an alias to avoid the duplication seen in the menu items already listed. It may not really matter, but I think learning to compress code down efficiently is a good skill to practice.

Also, I'm not sure why you have $+ inside $address(). It isn't necessary.

Last edited by Riamus2; 24/01/11 09:19 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just to show the changes since I wrote more than I expected, here are all of the changes other than the "safe" method of using on START and $ctime.

Code:
on *:JOIN:#: {
  if ( $read(dvupkeep.txt, s, $nick --) != $null ) {
    notice $nick You are still muted.
  }
  else {
    if ($me isop #) { mode # +v $nick }
  }
}
Menu channel {
  View Devoice List:DList
}
Menu nicklist {
  Devoice 'EM!
  .Perm DVoice:DVoice $$1
  .Timed DVoice
  ..1 Min:DVoice $$1 60
  ..5 Mins:DVoice $$1 300
  ..15 Mins:DVoice $$1 900
  ..30 Mins:DVoice $$1 1800
  ..Custom:DVoice $$1 $$?="Enter how many seconds."
  De-Devoice:{
    write -ds " $+ $?="Enter name to delete." $+ --" dvupkeep.txt
    if ($! isin # && $me isop #) { mode # +v $! }
  }
}
Menu @Devoice {
  Refresh List:DList 
}
alias DVoice {
  if ( $read(dvupkeep.txt, w, * $+ $address( $1 ,1) $+ * ) == $null ) {
    write dvupkeep.txt $1 -- $address( $1 ,1)
    if ($me isop #) { mode # -v $1 }
    if ($2 isnum) {
      .timer $+ $1 1 $2 DDVoice $1 #
      .timer $+ $1 $+ 2 1 $2 write -ds " $+ $1 --" dvupkeep.txt
    }
  }
  else {
    notice $me That name is already in the Devoice List.
  }
}
alias DList {
  if ($window(@Devoice)) { clear @Devoice }
  else { window @Devoice -l }
  filter -fw dvupkeep.txt @Devoice
}
alias DDVoice {
  if ($1 isin $2 && $me isop $2) { mode $2 +v $1 }
}


** Note: Channels pass to aliases, but I am not certain that channels pass to an alias of an alias, so I specifically included the channel for DDVoice. I can't test right now to see if it is passed that far. If it is, then you can leave off # in the timer and change $2 to # in the alias. It really doesn't make any difference, though.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2011
Posts: 9
N
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
N
Joined: Jan 2011
Posts: 9
Nice suggestions. Yeah, I did this really late and didn't consider the "nick --" problem until about an hour after I woke up. The filtering looks neater, and yeah the sleep deprivation led to some commands having '/' and some not. I noticed it, but needed to go to bed. Thanks for the input. smile

Edit: Trying to get the revision to work without the $nick search, but I ran into a problem that's lasted 2 hours! confused
Code:
  De-Devoice:{
    var %namer = $$1
    var %ncheck = $read(dvupkeep.txt, s, %namer)
    write -ds%ncheck dvcheck.txt
    write -ds%namer dvupkeep.txt
    mode # +v %namer
  }


This keeps giving a /write error. I think that the problem is in the
Code:
write -ds $+ %ncheck dvcheck.txt


The dvcheck has a format of: "$address(nick,1) .. $address(nick,1)". Trying

This is the last part before I post the new version up. Thanks in advance.

Last edited by Nonborn; 25/01/11 03:52 AM.
Joined: Jan 2011
Posts: 9
N
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
N
Joined: Jan 2011
Posts: 9
Sorry, the Edit button disappeared. Just wanted to say that I fixed my problem and the revised script is finished and up for suggestions.
Code:
alias DVoice {
  if ($me isop $chan) {
    if ($read(dvupkeep.txt, s, $address($1, 1)) == $null) {
      if ($2 isnum) {
        mode # -v $1
        write dvupkeep.txt $address($1, 1) - $1
        timerdv $+ $1 1 $2 mode # +v $1
        timerdv2 $+ $1 1 $2 write -ds $+ $address($1, 1) dvupkeep.txt
      }
      else {
        mode # -v $1
        write dvupkeep.txt $address($1, 1) - $1
      }
    }
    else { echo # That person is already in the Devoice List. }
  }
  else { echo # Can't perform action. $me is not an Operator in $chan $+ . }
}


on *:JOIN:#: {
  if ( $me isop $chan ) && ( $read(dvupkeep.txt, s, $address($nick,1) ) != $null ) { notice $nick You are still muted. } 
  else { mode # +v $nick }
}
Menu channel {
  View Devoice List:{
    window @Devoice -l
    filter -fw dvupkeep.txt @Devoice
  }
}
Menu nicklist {
  Devoice 'EM!
  .Perm DVoice: { DVoice $1 }
  .Timed DV
  ..1 Minute: { DVoice $1 60 }
  ..5 Minutes: { DVoice $1 300 }
  ..15 Min: { DVoice $1 900 }
  ..30 Min: { DVoice $1 1800 }
  ..Custom Mins!: {
    $?="Enter how many minutes."
    DVoice $1 $calc( $! * 60 )
  }
  ..Custom Hrs!!: {
    $?="Enter how many hours."
    DVoice $1 $calc( $! * 60 ^ 2 )
  }
  De-Devoice: {
    write -ds $+ $address($1,1) dvupkeep.txt
    mode # +v $1
    timerdv $+ $1 off
    timerdv2 $+ $1 off
  }
}
Menu @Devoice {
  Refresh List: {
    if ($window(@Devoice)) { clear @Devoice }
    else { window @Devoice -l }
    filter -fw dvupkeep.txt @Devoice
  }
}  

Last edited by Nonborn; 25/01/11 04:47 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Looks good, but here are some things you'd want to consider:


  • I still think silencing timers is a good idea.
  • Your isop check in the on JOIN event is on the wrong line. You can give the message even if you aren't an op. But you can't voice the person if you're not an op. I'd move the isop to the else line to prevent the error there.
  • You don't want to check isop in the DVoice alias at the top of the alias like that. You should be allowed to add someone to the list even if you are not opped. You can't devoice them, but you should still be allowed to add them (useful for permanent de-voice or long-term de-voice). I think the isop should only be on the +v/-v lines and let the /write lines through as shown in my example above.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2011
Posts: 9
N
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
N
Joined: Jan 2011
Posts: 9
Thanks for the advice. I didn't silence the timers to watch if they were activating and halting correctly through the runs I gave it earlier. --I forgot to add them back before posting. I can see how letting the /write commands go through without mod would be useful, but I see myself just @-ing myself when I really want to shut someone up. Do you have any suggestions on adding some features I overlooked? Thanks for all the help thus-far.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Not really, no. I don't use this type of thing, so I'm probably not the best person to think up features for it. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Maybe add a command to your @Devoice menu to allow you to remove an entry right at that window.
Adding might also be a possibility, but I can see that being a bit harder to script.

Joined: Jan 2011
Posts: 9
N
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
N
Joined: Jan 2011
Posts: 9
I'm still slowly learning custom windows so at-the-time-being, I don't know how to make a custom window that allows one line selection for each entry. Being able to click one line in the window to highlight an entry in it; and then right-click -calling a popup to remove that entry was what I was aiming to do. But I got stomped and left the feature out and shortly forgot about looking into it because of the 'IP muting' confusion I had before. I feel embarrassed on that one, took me 2 hours to figure out all I had to do was switch the write from "$nick - $address" to "$address - $nick". I'm sure there must be another way, but I was so relieved to get that one to work that I settled. Sorry for the rant. smirk

Edit: Oh, you don't think a Dialog would work better than a Custom Window? If so then I have to start learning from scratch. V.V

Last edited by Nonborn; 26/01/11 12:22 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
In this situation, the difference between using a custom window vs. a dialog is a matter of personal preference. You could, very easily, even have both.

For more information on working with the custom window regarding my suggestion look at /help menu prefix

If you'd like to consider reading/learning about dialogs, I suggest you start with /help /dialog

Last edited by RusselB; 26/01/11 04:19 AM.
Joined: Jul 2010
Posts: 30
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2010
Posts: 30
I guess I am not seeing the auto voice portion of this script.

and I really need it to autovoice when ppl enter channel.

I am going to be moderating my channel , autovoicing and then using the script instead of kicking/banning. It will be a mute script basically that will keep someone muted but still allow them to park in channel to watch. And keeping them muted until I remove them... even if they leave and return hours later.

Also, I need it to work in all the channels I am op in. This will include not just ~, & , @, but also %

<smile>

hope Im not being difficult.

DeeperStill

Last edited by DeeperStill; 28/01/11 01:52 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
On the script I put above, that's what this part does-

Code:
on *:JOIN:#: {
  if ( $read(dvupkeep.txt, s, $nick --) != $null ) {
    notice $nick You are still muted.
  }
  else {
    if ($me isop #) { mode # +v $nick }
  }
}


If you want it to also work with halfop, replace the isop check with:

Code:
if ($me !isreg # && $me !isvo #)


Repeat anywhere there is an isop check.


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Code:
on *:join:#:{
  if ($read(dvupkeep.txt,s,$nick --) != $null) {
    notice $nick You are still muted.
  }
  elseif (!$nick(#,$me,rv)) mode # +v $nick
}
-edited with an elseif statement, thanks to wims.

Last edited by Tomao; 28/01/11 06:57 PM.
Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
Quote:
else { $iif(!$nick(#,$me,rv),mode # +v $nick) }
Wait what ..?
Code:
elseif (!$nick(#,$me,rv)) mode # +v $nick
smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Yeah, I suppose that is more efficient, Wims. ^^ Thanks.


Link Copied to Clipboard