Ok, so I'm all for simplicity, and I can't do very intricate mIRC scripting as I only taught myself the basics. So simplicity for me is key.
Here I have created an Auto Voice script for my bot, that will voice anyone that enters my channel. Aha!, I hear you say, but this is easy. Right? Well no. There are a few examples, but they are all too simple and don't do what I need it to do.
Often times there are 2 people who join the channel at the same time, and then the script only voices 1 person. Or, there are people who join, who will be opped/voiced by Chanserv, thus negating the need for them to be auto voiced. Now this script gets rid of this problem by introducing "Nickname Slots". I use 12 of these slots as the channel that I moderate with my bot is small, and thus if there is a netsplit it will make use of nearly 12 slots.
You'll get the idea once you see it. It's simple if then else statements with loops.
What you see here is 4 hours of code from scratch, including extensive testing that was done to ensure that it works 100% - I am also sure that some of you clever folk will come up with a way to turn all of this into a tidy bundle with fewer lines. G'luck if you do.
** Feel free to use as is, just give credit where due.
*** Feel free to mod it, but give credit where due, also let me know.
What it will do:
Written for mirc 6.35 but should work with any version really, as it's quite basic.
on 1:load: {
set %vloaddate $date
set %timevoice $time
setnickvar
.echo %vloaddate %timevoice ** Auto voice script installed and activated.
}
on 1:join:#channel_name: {
set %channel $chan
if ($me !isop %channel) { goto error }
Else goto continue
:continue
if (%NickVar1 != empty) { goto FillNickVar2 | halt }
else {
set %timevoice $time
set %NickVar1 $nick
.echo %timevoice ** NickVar1 filled %NickVar1
goto CheckNickStatus1
halt
}
:FillNickVar2
if (%NickVar2 != empty) { goto FillNickVar3 | halt }
else {
set %timevoice $time
set %NickVar2 $nick
.echo %timevoice ** NickVar2 filled %NickVar2
goto CheckNickStatus2
halt
}
:FillNickVar3
if (%NickVar3 != empty) { goto FillNickVar4 | halt }
else {
set %timevoice $time
set %NickVar3 $nick
.echo %timevoice ** NickVar3 filled %NickVar3
CheckNickStatus3
halt
}
:FillNickVar4
if (%NickVar4 != empty) { goto FillNickVar5 | halt }
else {
set %timevoice $time
set %NickVar4 $nick
.echo %timevoice ** NickVar4 filled %NickVar4
goto CheckNickStatus4
halt
}
:FillNickVar5
if (%NickVar5 != empty) { goto FillNickVar6 | halt }
else {
set %timevoice $time
set %NickVar5 $nick
.echo %timevoice ** NickVar5 filled %NickVar5
goto CheckNickStatus5
halt
}
:FillNickVar6
if (%NickVar6 != empty) { goto FillNickVar7 | halt }
else {
set %timevoice $time
set %NickVar6 $nick
.echo %timevoice ** NickVar6 filled %NickVar6
goto CheckNickStatus6
halt
}
:FillNickVar7
if (%NickVar7 != empty) { goto FillNickVar8 | halt }
else {
set %timevoice $time
set %NickVar7 $nick
.echo %timevoice ** NickVar7 filled %NickVar7
goto CheckNickStatus7
halt
}
:FillNickVar8
if (%NickVar8 != empty) { goto FillNickVar9 | halt }
else {
set %timevoice $time
set %NickVar8 $nick
.echo %timevoice ** NickVar8 filled %NickVar8
goto CheckNickStatus8
halt
}
:FillNickVar9
if (%NickVar9 != empty) { goto FillNickVar10 | halt }
else {
set %timevoice $time
set %NickVar9 $nick
.echo %timevoice ** NickVar9 filled %NickVar9
goto CheckNickStatus9
halt
}
:FillNickVar10
if (%NickVar10 != empty) { goto FillNickVar11 | halt }
else {
set %timevoice $time
set %NickVar10 $nick
.echo %timevoice ** NickVar10 filled %NickVar10
goto CheckNickStatus10
halt
}
:FillNickVar11
if (%NickVar11 != empty) { goto FillNickVar12 | halt }
else {
set %timevoice $time
set %NickVar11 $nick
.echo %timevoice ** NickVar11 filled %NickVar11
goto CheckNickStatus11
halt
}
:FillNickVar12
if (%NickVar12 != empty) { goto Error | halt }
else {
set %timevoice $time
set %NickVar12 $nick
echo %timevoice ** NickVar12 filled %NickVar12
goto CheckNickStatus12
halt
}
:Error
.echo ** !! Unable to find an empty NickVar slot for the $nick $+ , who just joined !!
.echo ** !! Type !setnickvar to reset all NickVar slots !!
.echo ** !! Or you $me might not be an Opper in the %channel !!
halt
:CheckNickStatus1
.timerV1 1 5 voice1
halt
:CheckNickStatus2
.timerV2 1 5 voice2
halt
:CheckNickStatus3
.timerV3 1 5 voice3
halt
:CheckNickStatus4
.timerV4 1 5 voice4
halt
:CheckNickStatus5
.timerV5 1 5 voice5
halt
:CheckNickStatus6
.timerV6 1 5 voice6
halt
:CheckNickStatus7
.timerV7 1 5 voice7
halt
:CheckNickStatus8
.timerV8 1 5 voice8
halt
:CheckNickStatus9
.timerV9 1 5 voice9
halt
:CheckNickStatus10
.timerV10 1 5 voice10
halt
:CheckNickStatus11
.timerV11 1 5 voice11
halt
:CheckNickStatus12
.timerV12 1 5 voice12
halt
}
alias setnickvar {
set %timevoice $time
set %NickVar1 empty
set %NickVar2 empty
set %NickVar3 empty
set %NickVar4 empty
set %NickVar5 empty
set %NickVar6 empty
set %NickVar7 empty
set %NickVar8 empty
set %NickVar9 empty
set %NickVar10 empty
set %NickVar11 empty
set %NickVar12 empty
.echo %timervoice ** All NickVars have been manually set/reset.
}
alias voice1 {
set %timevoice $time
if (%NickVar1 isop %channel) { .echo %timevoice ** %NickVar1 has been opped by Chanserv already | set %NickVar1 empty | .echo %timevoice ** NickVar1 has been cleared | halt }
elseif (%NickVar1 isvoice %channel) { .echo %timevoice ** %NickVar1 has been voiced by Chanserv already | set %NickVar1 empty | .echo %timevoice ** NickVar1 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar1
.echo %timevoice ** %NickVar1 has been voiced
set %NickVar1 empty | .echo %timevoice ** NickVar1 has been cleared | halt
}
}
alias voice2 {
set %timevoice $time
if (%NickVar2 isop %channel) { .echo %timevoice ** %NickVar2 has been opped by Chanserv already | set %NickVar2 empty | .echo %timevoice ** NickVar2 has been cleared | halt }
elseif (%NickVar2 isvoice %channel) { .echo %timevoice ** %NickVar2 has been voiced by Chanserv already | set %NickVar2 empty | .echo %timevoice ** NickVar2 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar2
.echo %timevoice ** %NickVar2 has been voiced
set %NickVar2 empty | echo %timevoice ** NickVar2 has been cleared | halt
}
}
alias voice3 {
set %timevoice $time
if (%NickVar3 isop %channel) { .echo %timevoice ** %NickVar3 has been opped by Chanserv already | set %NickVar3 empty | .echo %timevoice ** NickVar3 has been cleared | halt }
elseif (%NickVar3 isvoice %channel) { .echo %timevoice ** %NickVar3 has been voiced by Chanserv already | set %NickVar3 empty | .echo %timevoice ** NickVar3 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar3
.echo %timevoice ** %NickVar3 has been voiced
set %NickVar3 empty | echo %timevoice ** NickVar3 has been cleared | halt
}
}
alias voice4 {
set %timevoice $time
if (%NickVar4 isop %channel) { .echo %timevoice ** %NickVar4 has been opped by Chanserv already | set %NickVar4 empty | .echo %timevoice ** NickVar4 has been cleared | halt }
elseif (%NickVar4 isvoice %channel) { .echo %timevoice ** %NickVar4 has been voiced by Chanserv already | set %NickVar4 empty | .echo %timevoice ** NickVar4 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar4
.echo %timevoice ** %NickVar4 has been voiced
set %NickVar4 empty | .echo %timevoice ** NickVar4 has been cleared | halt
}
}
alias voice5 {
set %timevoice $time
if (%NickVar5 isop %channel) { .echo %timevoice ** %NickVar5 has been opped by Chanserv already | set %NickVar5 empty | .echo %timevoice ** NickVar5 has been cleared | halt }
elseif (%NickVar5 isvoice %channel) { .echo %timevoice ** %NickVar5 has been voiced by Chanserv already | set %NickVar5 empty | .echo %timevoice ** NickVar5 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar5
.echo %timevoice ** %NickVar5 has been voiced
set %NickVar5 empty | .echo %timevoice ** NickVar5 has been cleared | halt
}
}
alias voice6 {
set %timevoice $time
if (%NickVar6 isop %channel) { .echo %timevoice ** %NickVar6 has been opped by Chanserv already | set %NickVar6 empty | .echo %timevoice ** NickVar6 has been cleared | halt }
elseif (%NickVar6 isvoice %channel) { .echo %timevoice ** %NickVar6 has been voiced by Chanserv already | set %NickVar6 empty | .echo %timevoice ** NickVar6 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar6
.echo %timevoice ** %NickVar6 has been voiced
set %NickVar6 empty | .echo %timevoice ** NickVar6 has been cleared | halt
}
}
alias voice7 {
set %timevoice $time
if (%NickVar7 isop %channel) { .echo %timevoice ** %NickVar7 has been opped by Chanserv already | set %NickVar7 empty | .echo %timevoice ** NickVar7 has been cleared | halt }
elseif (%NickVar7 isvoice %channel) { .echo %timevoice ** %NickVar7 has been voiced by Chanserv already | set %NickVar7 empty | .echo %timevoice ** NickVar7 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar7
.echo %timevoice ** %NickVar7 has been voiced
set %NickVar7 empty | .echo %timevoice ** NickVar7 has been cleared | halt
}
}
alias voice8 {
set %timevoice $time
if (%NickVar8 isop %channel) { .echo %timevoice ** %NickVar8 has been opped by Chanserv already | set %NickVar8 empty | .echo %timevoice ** NickVar8 has been cleared | halt }
elseif (%NickVar8 isvoice %channel) { .echo %timevoice ** %NickVar8 has been voiced by Chanserv already | set %NickVar8 empty | .echo %timevoice ** NickVar8 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar8
.echo %timevoice ** %NickVar8 has been voiced
set %NickVar8 empty | .echo ** NickVar8 has been cleared | halt
}
}
alias voice9 {
set %timevoice $time
if (%NickVar9 isop %channel) { .echo %timevoice ** %NickVar9 has been opped by Chanserv already | set %NickVar9 empty | .echo %timevoice ** NickVar9 has been cleared | halt }
elseif (%NickVar9 isvoice %channel) { .echo %timevoice ** %NickVar9 has been voiced by Chanserv already | set %NickVar9 empty | .echo %timevoice ** NickVar9 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar9
.echo %timevoice ** %NickVar9 has been voiced
set %NickVar9 empty | .echo %timevoice ** NickVar9 has been cleared | halt
}
}
alias voice10 {
set %timevoice $time
if (%NickVar10 isop %channel) { .echo %timevoice ** %NickVar10 has been opped by Chanserv already | set %NickVar10 empty | .echo %timevoice ** NickVar10 has been cleared | halt }
elseif (%NickVar10 isvoice %channel) { .echo %timevoice ** %NickVar10 has been voiced by Chanserv already | set %NickVar10 empty | .echo %timevoice ** NickVar10 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar10
.echo %timevoice ** %NickVar10 has been voiced
set %NickVar10 empty | .echo %timevoice ** NickVar10 has been cleared | halt
}
}
alias voice11 {
set %timevoice $time
if (%NickVar11 isop %channel) { .echo %timevoice ** %NickVar11 has been opped by Chanserv already | set %NickVar11 empty | .echo %timevoice ** NickVar11 has been cleared | halt }
elseif (%NickVar11 isvoice %channel) { .echo %timevoice ** %NickVar11 has been voiced by Chanserv already | set %NickVar11 empty | .echo %timevoice ** NickVar11 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar11
.echo %timevoice ** %NickVar11 has been voiced
set %NickVar11 empty | .echo %timevoice ** NickVar11 has been cleared | halt
}
}
alias voice12 {
set %timevoice $time
if (%NickVar12 isop %channel) { .echo %timevoice ** %NickVar12 has been opped by Chanserv already | set %NickVar12 empty | .echo %timevoice ** NickVar12 has been cleared | halt }
elseif (%NickVar12 isvoice %channel) { .echo %timevoice ** %NickVar12 has been voiced by Chanserv already | set %NickVar12 empty | .echo %timevoice ** NickVar12 has been cleared | halt }
else {
set %timevoice $time
.mode %channel +v %NickVar12
.echo %timevoice ** %NickVar12 has been voiced
set %NickVar12 empty | .echo %timevoice ** NickVar12 has been cleared | halt
}
}
I am also sure that some of you clever folk will come up with a way to turn all of this into a tidy bundle with fewer lines. G'luck if you do.
Challenge accepted!
on *:JOIN:#: if ($nick($chan,$me,~&@%)) .timer 1 3 $!iif( $!nick( $chan , $nick ,~&@%+) ,noop, mode $chan +v $nick )
I did it like this. Does this work as intended, for you, or did I miss a feature?
Of course, this isn't the most readable code out there. In another thread you asked for advice:
I believe your issue with only some people getting +v is when you override the timer - that is, you start a timer with its name of one that is yet to run. However, you can have unnamed timers, my just calling the /timer command without anything appended to it, e.g: timer 1 1 echo -a test
My snippet above makes use of this.
In the snippet above, I made use of my knowledge of mIRC's evaluation. However, a much more simpler way to do this would be to have an alias and the join event. In the join event, it would call a timer with the alias as the command, and using $chan and $nick as the alias parameters. In the alias, it uses $1 and $2 to check to see if they need a voice, and if so, add them as voice.
If there's any confusion with this don't hesitate to ask :)
That is quite neat and tidy! I also didn't know that mIRC had a built in /avoice - however, this script has separate slots for when more than 1 person joins and then waits to see if the person is going to get opped and if not continues voicing the person. Because there's a few ops in the chan.
From what I can tell, I dunno if I'm right, but your code there allows for two people? I do like it.
@blackvenomm666 so did the original script. However, the extended code was because he was using named timers (overriding if lots of people join) and not passing parameters in the timers
Hmm Conscious, the code worked, a few times. And then something went wrong. There was a dude who had connection issues, he joined and quit about 5 times, and every time he joined he was oppend and then the script didn't voice him, as he should, but then it started voicing him after he got opped, which was odd.
[19:07:12] @Acid[]Killer (AcidKiller@AcidKiller.vampyres.cathedral) Quit (Connection reset by peer)
[19:07:44] Acid[]Killer (AcidKiller@AcidKiller.vampyres.cathedral) has joined #vampyres_cathedral
[19:07:44] ChanServ sets mode: +o Acid[]Killer
[19:07:44] Red_Queen sets mode: +v Acid[]Killer
Any ideas?
This doesn't account for people who don't need voice, i.e. people with access in the channel