|
Joined: Dec 2004
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Dec 2004
Posts: 3 |
A great /op alias op { if (!$1) { echo -a 02ERROR! Who is 02OPNICK01? } else { var %a = 1 var %b = + while ($gettok($1-,%a,32)) { var %b %b $+ o inc %a } mode # %b $1- } } Benefits: dont have bugs for many opnicks, how many needful SOU BRASILEIRO, E NÃO DESISTO NUNCA. :P
|
|
|
|
Joined: Dec 2002
Posts: 3,547
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,547 |
So, what help is needed then?
|
|
|
|
Joined: Dec 2002
Posts: 145
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 145 |
??? Enclosed in mIRC: /op /mode # +ooo $$1 $2 $3
What does your snippet do better than the one supplied in mIRC?
Why make something easy look difficult? Where is the bug in the above?
|
|
|
|
Joined: Dec 2002
Posts: 3,547
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,547 |
Your /op alias doesn't show if you aren't an op in the channel or if it was actually called from a channel window.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Well, so much for me not participating in the forums... Sorry, but it really isn't. Here are some things you should take into consideration: - You are not checking if the $chan identifier is filled, meaning you are not checking if this alias is triggered from a channel or not.
if !$chan { echo -ac info /op: Active window is not a channel | return } - You are not checking if you are oped on the channel where you want to use this alias.
if $me !isop $chan { echo -ac info /op: Not a channel operator | return } - if (!$1) { echo -a 02ERROR! Who is 02OPNICK01? }
You are hard coding colors in your error message. This means that if a person has background color 02, they won't even see your message. Always take into account that other people don't necessarily have the same options set as yourself.
It's preferable to use the /echo command with c switch. If you specify the c switch, you have to specify one of the many colors as defined in the Colors Dialog (alt+k). For example: echo -c normal, echo -c notify, echo -c join, etc.
This way the script will display the color that the user him/herself has chosen. - All of the following is redundant:
var %a = 1 var %b = + while ($gettok($1-,%a,32)) { var %b %b $+ o inc %a }
You obtain the same by specifying: + $+ $str(o,$0)
The $str identifier will repeat the given input N times. In our case, we specified $0, which is the total amount of tokens that the input string was given, in other words the amount of nicks.
While I'm at it, in your var %b %b $+ o statement, you are misusing the var command. The correct syntax is var %var = value. - You are not taking into account that there is a limit to the total amount of parameters that you can send with each mode change. You are assuming that you can op any amount of nicks. $modespl is your friend, as it will tell you how many nicks can be opped in one time.
So what we need to do is loop through the nicks, or use recursion, so that with every iteration, a $modespl amount of nicks is opped. That means if the server allows for 4 nicks to be opped at once ($modespl = 4), and we want to op 12 people, it will happen in 3 iterations. Three times four nicks. Your alias will op four nicks and stop. - You might want to consider using $snicks, and letting the user select the nicks to be opped, as it can be annoying to type out all the nicknames. In my example, I allow both. So if you specify nicknames, seperated by commas, the snippet will op those. If you don't specify nicks, the snippet will op the selected nicks in the nicklist. If none are specified or selected, the snippet halts.
In the end I'd settle for something like this: op {
[color:red] [/color]
; Usage: /op <-- Nicks selected in nicklist
; /op nick1,nick2,...,nickN <-- Nicks specified
[color:red] [/color]
if !$chan { echo -ac info /op: Active window is not a channel }
elseif $me !isop $chan { echo -ac info /op: You are not an operator on $chan }
elseif !$1 && !$snicks { echo -ac info /op: No nicks specified or selected }
[color:red] [/color]
else {
tokenize 44 $iif($1,$1-,$snicks)
while $0 {
mode # + $+ $str(o,$modespl) $($!1- $+ $modespl,2)
tokenize 32 $deltok($1-,1- $modespl,32)
}
}
}
One could also consider passing the channel as a parameter to the alias, so that it could be used in a timer, or a situation where the $chan identifier isnt filled. And, to be honest, it would be a good idea to turn this sort of alias into a more general system alias, which handles more modes than only ops, and not only giving + mode, but also - mode. It's been done before, by others and myself, but here goes again: massmode {
[color:red] [/color]
; Usage: /massmode <channel> <+|-mode> [param1,param2,...paramN]
; [color:red] [/color]
; Examples:
;
; When specifying params: /massmode #channel +v James,John,Jane
; /massmode #channel -b *!hehe@*.com,*!*@bad.org
;
; When selecting nicks in nicklist: /massmode #channel -o
; /massmode #channel +h
;[color:red] [/color]
; Specified parameters have priority over selected nicks.
[color:red] [/color]
[color:red] [/color]
if $$1 !ischan { echo -ac info /massmode: you are not on channel $1 }
elseif $me !isop $1 && $me !ishop $1 { echo -ac info /massmode: you are not an operator on $1 }
elseif !$regex(mm,$2,/^([+-])([a-z])$/i) { echo -ac info /massmode: incorrect setting of mode: $2 }
elseif !$3 && !$snicks { echo -ac info /massmode: no nicks specified or selected }
[color:red] [/color]
else {
var %a = $1, %b = $modespl
tokenize 44 $iif($3,$3-,$snicks)
while $0 {
mode %a $regml(mm,1) $+ $str($regml(mm,2),%b) $($!1- $+ %b,2)
tokenize 32 $deltok($1-,1- %b,32)
}
}
}
I didn't want to hardcode the modes, because I'm uncertain of all the current and future possible modes. Obviously there is ohvb, though, I don't really chat that often, so I'm not qualified to say. For now it accepts any letter from the alphabet. It's up to the user to use the right mode. Anyway, not saying this is a perfect alias, but it is certainly more qualified to be a "great alias" than yours. Greets
Gone.
|
|
|
|
Joined: Dec 2002
Posts: 3,547
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,547 |
Your alias is pefect, it works, it has comments, and it actually checks if you are on the channel or an op in that repsect.
|
|
|
|
Joined: Mar 2004
Posts: 175
Vogon poet
|
Vogon poet
Joined: Mar 2004
Posts: 175 |
- Relinsquish
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
@SladeKraven, Relinsquish: thanks. I have just thought of something. If the $modespl is bigger than the remaining amount of nicks in the last iteration, in the case of a +b mode, the mode will invoke the showing of the ban list for that channel. Adding a small $iif check solved this. Final code, unless if I spot more of these tricky things: massmode {
[color:red] [/color]
; Usage: /massmode <channel> <+|-mode> [param1,param2,...paramN]
;
; When specifying params: /massmode #channel +v James,John,Jane
; /massmode #channel -b *!hehe@*.com,*!*@bad.org
;
; When selecting nicks in nicklist: /massmode #channel -o
; /massmode #channel +h
;
; Specified nicks have priority over selected nicks.
[color:red] [/color]
if $$1 !ischan { echo -ac info /massmode: You are not on channel $1 }
elseif $me !isop $1 && $me !ishop $1 { echo -ac info /massmode: You are not an operator on $1 }
elseif !$regex(mm,$2,/^([+-])([a-z])$/i) { echo -ac info /massmode: Incorrect setting of mode: $2 }
elseif !$3 && !$snicks { echo -ac info /massmode: No nicks specified or selected }
[color:red] [/color]
else {
var %a = $1, %b = $modespl
tokenize 44 $iif($3,$3-,$snicks)
while $0 {
mode %a $regml(mm,1) $+ $str($regml(mm,2),$iif($0 < %b,$0,%b)) $($!1- $+ %b,2)
tokenize 32 $deltok($1-,1- %b,32)
}
}
}
Gone.
|
|
|
|
Joined: Dec 2002
Posts: 3,547
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,547 |
Genius, genius genius!
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
elseif !$regex(mm,$2,/^([+-])([a-z])$/i) { echo -ac info /massmode: incorrect setting of mode: $2 } You might want to allow modes with capital letters also. I don't know a server that has capital ones, but just in case: elseif !$regex(mm,$2,/^([+-])([a-z[color:red]A-Z[/color]])$/i) { echo -ac info /massmode: incorrect setting of mode: $2 }
New username: hixxy
|
|
|
|
Joined: Dec 2002
Posts: 145
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 145 |
tokenize 44 $iif($3,$3-,$snicks)
How would you cover the possibility of a string being too long?
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
But tidy, capitalized letters are already allowed thanks to the i modifier //echo -a $regex(A,/([a-z])/i) ** $regml(1) gives A //echo -a $regex(a,/([a-z])/i) ** $regml(1) gives a Greets
Gone.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Indeed,
that will become a problem in the case of selected nicks in the nicklist, if you select more than +/-940 chars worth of nicks.
I was on the verge of making a queue system but then Hammer made me realise something: massmodes are bad. He thought I already showed too much code, cuz no one without malicious intentions/activities is going to set a mode on lets say 70+ nicks at a time.
To conclude, it's definitely possible, and not that hard to do, but you won't see it coming from me.
Greets
Gone.
|
|
|
|
Joined: Dec 2004
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Dec 2004
Posts: 3 |
sorry
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Now now, don't feel bad, you're new and you didn't know. Normally in the Scripts & Popups forum, people come with questions regarding scripting, and other people reply to it to help out. If you wish to submit your scripts, you are better of to go to sites which are meant for that, like www.mircscripts.org, www.mirc.net, www.mircscripts.com, www.hawkee.com, etc. Cya! /me tosses HesT a cookie. Enjoy!
Gone.
|
|
|
|
|