mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 3 1 2 3
#184927 02/09/07 11:28 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
I wanted to create an alias so I could type /kb nick in the window and it would kickban them off the channel. But, I'm not sure how. How does mIRC know to take the nick, /whois it, +b the hostmask, and kick it? I tried $nick, but meh. Help?

Mpot #184930 02/09/07 11:54 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
For the "whois question" check "/help internal address list"
For your ban command, have a closer look at "/help /ban"
For the nick-pick, check "/help aliases" or "/help $snick"
smile

Mpot #184934 03/09/07 12:40 AM
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Originally Posted By: Mpot
I wanted to create an alias so I could type /kb nick in the window and it would kickban them off the channel. But, I'm not sure how. How does mIRC know to take the nick, /whois it, +b the hostmask, and kick it? I tried $nick, but meh. Help?


The inbuilt 'ban' command is your friend. As Horstl mentioned, read the help. But to summarise:

The 'ban' command uses an inbuilt feature of mIRC called the IAL (Internal Address List). In other words, the hostname and username are in mIRC's memory pool.

Bekar #184936 03/09/07 12:52 AM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Alright. I've got /kb /mode # +b $$1 kick $$1 $chan

Two problems:

1. It bans by nickname (Mpot!*@*) instead of hostmask ( *!*@adsl-065-007-137-149.sip.asm.bellsouth.net)

2. It doesn't follow through with a kick.

Any ideas?

Mpot #184939 03/09/07 01:12 AM
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
use :
Code:
kb ban -k $$1 2 kick !


in a channel, type /kb "nick"


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Mpot #184941 03/09/07 01:20 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Code:
/kb /ban -k # $$1 2 $2-
The trick to get a kickban-combination is adding the -k switch (there are other sollutions as well, but this should suffice your needs) smile

- "2" is the mask type to ban; in this case "2" = "host" (compare: /help $mask)

- I also added "$2-" so you can add a kick reason, e.g.
/kb -NICK-
/kb -NICK- you have been warned!

Wims #184942 03/09/07 01:22 AM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
/kb /mode # +b $1 | /kick # $1

Is what I have come up with, and it works like an absolute dream, except for the fact that it bans by nick instead of hostmask. I tried going to $mask and looking around /ban and decided /kb /mode # +b 4 $1 | /kick # $1 might work, because

Quote:
0: *!user@host

1: *!*user@host

2: *!*@host

3: *!*user@*.host

4: *!*@*.host

5: nick!user@host

6: nick!*user@host

7: nick!*@host

8: nick!*user@*.host

9: nick!*@*.host



And 4 is the bantype I want.


And Wims + Horstl, thanks, but I really wanna figure this out as much as I can by myself. That's the only way to learn. I wanna start compeltly from scratch instead of using an already scripted /ban feature

Last edited by Mpot; 03/09/07 01:28 AM.
Mpot #184943 03/09/07 01:33 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Learning by doing is the best method, we're reading here some "can you make me a complete script that does xy" all too often. *thumbsup*
Now you could improve the alias e.g. with feedbacks for the following scenarios:
- no nick given (insufficient/ wrong input)
- unable to kick (being a regular user or voiced)
...
Keep it up! smile

Horstl #184944 03/09/07 01:35 AM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Er...

/kb /mode # +b $1 | /kick # $1

Is still flipped up. Bans by name. Want ban by hostmask. Dont' wanna use /ban preprogrammed. Bantype wanted: 4: *!*@*.host

Mrow?



AND, while we're at it, how about a /unban that removes all bans for a nick? I tried /unban /mode # -b $1 , but that once agian only removes for a nick, not a hostmask.


Furthermore, I'm attempting to add error handling as you suggested. However {/i /invite $$1 #
:error /echo No such nick.}
is not working. I tried doing /i nonexistantnick and I just got I Unknown command to the status window.

Last edited by Mpot; 03/09/07 01:46 AM.
Mpot #184945 03/09/07 01:45 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
You already looked at "$mask" ...
Quoting the help file: "Returns address with a mask specified by type." ...
Now, how to get one of these masks for a nick? *spoiler* check the helpfile for "$address"

For the unban: e.g. a combination of "while" "$ibl" and "$address" could do the job, using iswm operator...

Error handling: Use if-then-else constructions to trigger an echo for insufficient or invalid parameters

Last edited by Horstl; 03/09/07 01:49 AM.
Mpot #184947 03/09/07 01:51 AM
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
If you ban to kick ban on type 4, juste change the 2 to 4 :
Code:
kb ban -k $$1 4 $2-



Last edited by Wims; 03/09/07 01:56 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Horstl #184948 03/09/07 01:52 AM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
I'm sorry, my brain is getting overloaded, I think the script has reached a complexity that I can't handle. /kb /mode # +b $1 | /kick # $1 needs $address incorporated into it somehow to ban by hostmask, but I don't have a clue. As for if-then-else, I haven't a clue how to write them. I'm thinking it's time I look at a completed script and learn from it. I wanted to muck through the help files and try and pull it off, and I nearly succeeded, but sadly we reached to high of a difficultly level. Much thanks for bringing me this far.

Do you have a MSN/AIM/GTalk/YIM? I have more alias-esqu questions to ask, and it seems that would be more convenient.

Last edited by Mpot; 03/09/07 01:57 AM.
Mpot #184951 03/09/07 02:04 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Sorrry, I'm not using any messengers at all, and I have to hit the hay now...

Take your time looking at working scripts; study the code and try to figure out what it's ment to do - this is a great way to learn.
At first, play with relatively easy tasks like the one you started here, and if you really reach a dead end, feel free to ask smile

Horstl #184954 03/09/07 02:33 AM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Originally Posted By: Horstl
Sorrry, I'm not using any messengers at all, and I have to hit the hay now...

Take your time looking at working scripts; study the code and try to figure out what it's ment to do - this is a great way to learn.
At first, play with relatively easy tasks like the one you started here, and if you really reach a dead end, feel free to ask smile


Alright, bye. I guess I'll see you tomorrow? If and when you show up, could you gimme the line finished up with error checking and all?

I'm also looking at a /i /invite $1 $2 where $1nick and $2channel, but I also want it to work if I just type /i nick on a channel, but that would be just a /i /invite $1 #. So I dunno. Error checking included would pwn.


Also, and /unban /mode # -b $1 alias where $1 is the hostmask of the specified nick. Of course, error checking.

Anyway. I think it might have something to do with /kb /mode # +b$1 | /kick # $1 needing $address. Somehow make it when I go /kb nick it takes the nick, $addresses it, and then puts it in as $1.

On a better day, I might be able to figure this out. But I can't. I feel useless. -_-

Mpot #184969 03/09/07 09:43 AM
Joined: Sep 2007
Posts: 32
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Sep 2007
Posts: 32
this should work, not tested tho;

Code:
; usage: /kb <nick> <reason(Optional)>

alias kb {
 .raw -q mode # +b $address($1,1) $crlf kick # $1 $iif($2,: $+ $2)
}

Last edited by SplitFire; 03/09/07 11:25 AM.

on me:*:JOIN:#: { .raw part # $crlf join # }
SplitFire #184987 03/09/07 03:34 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Originally Posted By: SplitFire
this should work, not tested tho;

Code:
; usage: /kb <nick> <reason(Optional)>

alias kb {
 .raw -q mode # +b $address($1,1) $crlf kick # $1 $iif($2,: $+ $2)
}


Would I be able to do

Code:

alias unban {
 .raw -q mode # -b $address($1,1) 
}


Edit: That works, but only if they're on the channel. o-0


Furthermore: /i /invite $$1 $1 # Would that invite the specified nick to the specified channel and invite the nick to the channel you're on if no channel is specified?

Last edited by Mpot; 03/09/07 05:27 PM.
Mpot #184996 03/09/07 05:40 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Quote:
(...) could you gimme the line finished up with error checking and all?

Put these lines to a remote file. Besides the aliases section, you can add your own aliases to remotes as well - you'll have to prefix them with "alias". I'm prefering this.
Code:
; You can add comments to a code - all lines prefixed with a ; will be ignored while processing your code.
; Of course you can remove all these comments if you like

; kickban per editbox command (example)
alias kb {

  ; the window where you entered the command is not a active channel 
  ; [note how the operator "ison" has been negated with an exclamation mark]

  if ($me !ison $acitve) { echo -a kickban: $active is not a channel! }

  ; no first parameter (no nick given)
  ; [using the 'negation-prefix' again, this time to check whether there was a parameter entered]

  elseif (!$1) { echo -a kickban: no nick specified. Syntax: /kb <nick> <optional kick-reason> }

  ; first paramter given is not a nick on that chan

  elseif ($1 !ison $chan) { echo -a kickban: $1 is not a nick on $active }

  ; no sufficient channel rights (only ops, halfops etc can kick or ban a user)
  ; [this line combines two "if" comparisons with "or"]

  elseif (($me isreg $active) || ($me isvoice $active)) { echo -a kickban: Your have no sufficient channel rights on active to kick or ban }

  ; none of the possible errors above occured: perform the ban with "mode" as you liked, followed by a kick. 
  ; [desired banmask "4" via $address(nick,4). "$2-" refers to the 2nd parameter onwards, in this case the kick reason]

  else { 
    mode $active +b $address($1,4)
    kick $active $1 $2-
  }

}

As you see, the structure of this alias is: if....elseif....elseif...elseif...else. The respective command is executed once a condition is matched; processing stopps at that point. Thus, only if none of the "error message conditions" is true, the alias will procede to "else" and try to perform a kickban.
"$active" refers to the active window, In this case it's the name of the channel where command was entered - so you could use # instead, if you want.

Quote:
Anyway. I think it might have something to do with /kb /mode # +b$1 | /kick # $1 needing $address. Somehow make it when I go /kb nick it takes the nick, $addresses it, and then puts it in as $1.

"mode $active +b $address($1,4) .... kick $active $1 $2-" does the same as "ban -k $active $1 4 $2-" (ban in combination with kick on $active of user $1 with mask 4; kick of user $1 with reason $2-).

If you only want to "stop processing" if invalid or insufficient parameters were given (no echo feedback), the alias could be much smaller - now you can combine multiple "error-conditions":
Code:
alias kb {
  if ((($me isop $active) || ($me ishop $active)) && ($1 ison $active)) { ban -k $address($1,4) 4 $2- }
}
"if (I'm op on $active OR I'm halfop on $active) AND $1 is a nick on active".
The condition "$active has to be a valid channel" is inherent in these conditions. (if $1 has to be a nick on $active, $active for sure has to be a chan) - thus no need to check this condition on its own smile


Quote:
I'm also looking at a /i /invite $1 $2 where $1nick and $2channel, but I also want it to work if I just type /i nick on a channel, but that would be just a /i /invite $1 #. So I dunno. Error checking included would pwn.

A good starting point for another if-then-else construction:
Code:
alias i {
  ; first parameter is a user in your internal address list 
  if ($ial($1)) { 
    ; second parameter is a channel you're on: invite the user to that chan
    if (#$2 ischan) { invite $1 #$2 }
    ; second parameter given, but it's no channel
    elseif ($2) { echo -a Cannot invite $1 on $2 - $2 is no channel! }
    ; (no second parameter given) and typing the command in a channel window: invite the user to the active channel
    elseif ($active ischan) { invite $1 $active }
    ; (no second parameter given) and typing the command in somo other window, e.g. status window
    else { echo -a invite: neither is $active a channel; nor did you provide a channel to invite $1 }
  }
  ; first parameter given, but it's not a user
  elseif ($1) { echo -a invite: looks like $1 is no user sharing a channel with you! }
  ; no first parameter given
  else { echo -a invite: no nickname given! }
}

Without error echos, it can be simplified again:
Code:
alias i {
  if (($ial($1)) && ((#$2 ischan) || ($active ischan))) { invite $1 $iif(($2 ischan),#$2,$active) }
}
"If $1 is a user in your internal address list AND ($2 is a channel OR $active is a channel)"
You might have noted the # prefix for $2 in some of the lines above: "#$2". Take for example a channel named "#test": "/i John #Test" would work, but what about "/i John Test"? If you use #$2 instead of $2, mIRC will add that prefix if it's missing smile

Quote:
Code:
alias kb {
 .raw -q mode # +b $address($1,1) $crlf kick # $1 $iif($2,: $+ $2)
}
- I don't see any advantage of using rawmode here. Then, breaking lines with a pipe | or splitting the two commands on two lines looks a lot cleaner imho
- it should be $2- as the kick-reason could contain spaces

Horstl #184998 03/09/07 05:50 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
You are god. Your services are appreciated. <3

But, um, /unban would pwn too.

Code:
alias secure {/msg chanserv set $$1 keeptopic on
/msg chanserv set $$1 topiclock on
/msg chanserv set $$1 keeptopic on
/msg chanserv set $$1 private on
/msg chanserv set $$1 restricted on
/msg chanserv set $$1 opnotice on
/msg chanserv set $$1 enforce on }


My latest project. However, I'm not sure I understand the errorchecking system. Could you help me implement it for errors nonexistant channel and access denied?

Edit: if ($1(!ischan)) { echo -a $1 is an invalid channel }

is what I came up with for invalid channel, from looking at your notes in the other scripts. But it doesn't work. Where did I go wrong?

on 1:notice:Access denied.: /echo -a Access denied. | halt
on 1:notice:channel # isn't registered: /echo -a Nonexistant channel. | halt


Some more stuff I came up with. But I don't know how to integrate it into the if-then-else

Edit: Been working a little, got this:

alias secure {
if ($1 ischan) {
/msg chanserv set $$1 topiclock on
/msg chanserv set $$1 keeptopic on
/msg chanserv set $$1 private on
/msg chanserv set $$1 restricted on
/msg chanserv set $$1 opnotice on
/msg chanserv set $$1 enforce on }
}


But that's fairly useless because I have to be ON the channel, I think. And it still doesn't help with access denied.

---

Also, for the /i alias, is there some way to make it work even if the person isn't sharing a channel with you?

--

ALSO, I'm doing SOP aliases. I want it to either SOP on the channel spefcified, or on the channel it was typed on if there was no channel specified. I know we did this with the invite script, but I just don't get it. Could you single out that part of the script and help me with it? /aop /msg chanserv aop #$2 add $1 is what I've managed so far. Of course, error checking would be nice. But I still need help with that. =\

EDIT: Does

alias aop { if ($active ischan) { msg chanserv aop $active add $1 | halt }
else ( msg chanserv aop $2 add $1 ) }


have any merit?

Edit2: Tried it. Worked sorta okay. AOPed the nick on the inputed channel when specification was given, but it still AOPed on the inputed channel when specification WAS given.

Last edited by Mpot; 03/09/07 09:27 PM.
Mpot #185026 03/09/07 09:08 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559

Quote:
But that's fairly useless because I have to be ON the channel, I think. And it still doesn't help with access denied.
check this with "if ($me ison $1)"
In addition: tricky brackets: not "if ($1(!ischan))" but "if ($1 !ischan)... wink

To make the server reply "Access denied" a "conditional" part of your script - no way. At least no simple one smile ...Don't want too much at first.
Alias are processesd linear, that is: until they are finished or return something, or were stoped. You cannot tell a single alias "now wait for a notice of chanserv" etc.. One could code this with raw events and/or timers; but imho thats not woth the effort.

Quote:
Also, for the /i alias, is there some way to make it use the IAL and a /whois if the person isn't sharing a channel with you?
This is an analogical problem smile Better remove the whole "is a user in my address list" condition if you like to invite users you don't share a channel with.

The unban thingie:
Code:
alias unban {
  ; if 2nd parameter is given, use it for "channel". if not, use the active window for "channel".
  var %chan = $iif(($2),#$2,$active)

  ; 1st parameter is a user in your internal address list, and you are on "channel"
  if (($ial($1)) && ($me ison %chan)) { 

    ; use the user's fulladdress for "address"
    var %address = $v1

    ; loop all bans of "channel" (using mIRCs internal banlist)
    var %nr = 1
    while ($ibl(%chan,%nr)) {

      ; if the ban affects "address", remove that ban
      if ($v1 iswm %address) { mode %chan -b $v1 }
      inc %nr
    }

  }
  else { echo -a unban: syntax is /unban <nick> [<#chan>] - You need to share a chan with <nick>, and have to be on <#chan>. }
}


Horstl #185029 03/09/07 09:31 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
How do I remove the internal access list part of the /i alias so it will invite someone even if I don't share a channel with them? Is this it:

alias i {
; second parameter is a channel you're on: invite the user to that chan
if (#$2 ischan) { invite $1 #$2 }
; second parameter given, but it's no channel
elseif ($2) { echo -a Cannot invite $1 on $2 - $2 is no channel! }
; (no second parameter given) and typing the command in a channel window: invite the user to the active channel
elseif ($active ischan) { invite $1 $active }
; (no second parameter given) and typing the command in somo other window, e.g. status window
else { echo -a invite: neither is $active a channel; nor did you provide a channel to invite $1 }
}
; first parameter given, but it's not a user
elseif ($1) { echo -a invite: looks like $1 is no user sharing a channel with you! }
; no first parameter given
else { echo -a invite: no nickname given! }
}



For the /secure alias, since we can't integrate invalid channel and invalid permissions checking, is there anything I can do to make the script stop sending to ChanServ if something buggers up?


Also, what about the /aop alias? I think I'm pretty close, just need a titch more help.

Mpot #185034 03/09/07 10:17 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Code:
alias i {
  if ($1) {
    if (#$2 ischan) { invite $1 #$2 }
    elseif ($2) { echo -a invite: Cannot invite $1 on $2 - You're not on that channel. }
    elseif ($active ischan) { invite $1 $active }
    else { echo -a invite: Neither is $active a channel; nor did you provide a channel to invite $1 }
  }
  else { echo -a invite: No nick given. Syntax: /i <nick> or /i <nick> <chan> }
}


for your secure alias, I think it's ok... Maybe add a check for "being op on that chan".
As a note, you don't need to prefix commands in scripts with a / ...You need them only if you want to set a command per editbox smile

Hm, I'm confused what the /aop alias shall do in detail confused

Horstl #185036 03/09/07 10:23 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
/aop is going to /msg chanserv aop #channel add nick. However, if a channel isn't supplied, it should use the channel that the command was inputed on. I played for a while, and got

alias aop { if ($active ischan) { msg chanserv aop $active add $$2 | halt }
else ( msg chanserv aop $1 add $$2 ) }


But it's buggered. I'd like the same thing for SOP and VOP lists, too. I assume only one letter would need to be changed in the script?

Furthermore, for /unban, just like /i I was hoping the IAL requirement could be removed so that they can be unbanned even if I do not share a channel with them.

And now that I'm thinking about it, I wanna make sure that with the /i alias, that the channel that the nick should be invited to can either be supplied or not supplied, and if it's not supplied, the nick is invited to the channel the command was inputed on.

Last edited by Mpot; 03/09/07 10:32 PM.
Mpot #185037 03/09/07 10:32 PM
Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Without testing it, I think it should be:

Code:
alias aop { 
  if ($active ischan) { 
    msg chanserv aop $active add $$2 
  }
  else {
    msg chanserv aop $1 add $$2 
  }
}

noMen #185038 03/09/07 10:36 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
That's exactly what I did, just formatted differently. o-0

Edit: I just tested it, useless as mine was.

Last edited by Mpot; 03/09/07 10:39 PM.
Mpot #185039 03/09/07 10:45 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Think about the most practical order of conditions and parameters... if <nick> is always needed it's a lot easier to use it as 1st parameter smile
/aop <nick> ... will add nick to aop list of the current channel
/aop <nick> <chan> ...will nick add to aop list of the given channel
Code:
alias aop { 
  if ($2) { msg chanserv aop #$2 add $1 }
  elseif (($active ischan) && ($1)) { msg chanserv aop $active add $1 }
  else { echo -a aop: syntax is /aop <nick> or /aop <nick> <chan> }
}


Quote:
Furthermore, for /unban, just like /i I was hoping the IAL requirement could be removed so that they can be unbanned even if I do not share a channel with them.
This would be possible only if you provide the users full address (nick!identd@host.domain) within the command. Most bans ar no nick-bans, but the banlist has to be compared to a full address to succesfully remove ALL bans affecting that user.

Quote:
And now that I'm thinking about it, I wanna make sure that with the /i alias, that the channel that the nick should be invited to can either be supplied or not supplied, and if it's not supplied, the nick is invited to the channel the command was inputed on.
Imho it is doing that already smile

Horstl #185041 03/09/07 11:01 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Quote:
This would be possible only if you provide the users full address (nick!identd@host.domain) within the command. Most bans are no nick-bans, but the banlist has to be compared to a full address to successfully remove ALL bans affecting that user.


Can we simply set the /kb alias to use ban mask 5(5: nick!user@host) instead of banmask 4(4: *!*@*.host)? Of course,
this wouldn't help with bans set not using the script, but there could be a simple error response "Either this nick is not banned, or the ban was not set with your /kb alias."

Also, can I put multiple aliases in the same remote? IE:

Code:
alias aop { 
  if ($2) { msg chanserv aop #$2 add $1 }
  elseif (($active ischan) && ($1)) { msg chanserv aop $active add $1 }
  else { echo -a aop: syntax is /aop <nick> or /aop <nick> <chan> }
}
;
;
;
alias sop { 
  if ($2) { msg chanserv sop #$2 add $1 }
  elseif (($active ischan) && ($1)) { msg chanserv sop $active add $1 }
  else { echo -a sop: syntax is /sop <nick> or /sop <nick> <chan> }
}
;
;
;
alias vop { 
  if ($2) { msg chanserv vop #$2 add $1 }
  elseif (($active ischan) && ($1)) { msg chanserv vop $active add $1 }
  else { echo -a vop: syntax is /vop <nick> or /vop <nick> <chan> }
}

Last edited by Mpot; 03/09/07 11:05 PM.
Mpot #185044 03/09/07 11:37 PM
Joined: Sep 2007
Posts: 32
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Sep 2007
Posts: 32
Originally Posted By: Mpot
Originally Posted By: SplitFire
this should work, not tested tho;

Code:
; usage: /kb <nick> <reason(Optional)>

alias kb {
 .raw -q mode # +b $address($1,1) $crlf kick # $1 $iif($2,: $+ $2)
}


Would I be able to do

Code:

alias unban {
 .raw -q mode # -b $address($1,1) 
}


Edit: That works, but only if they're on the channel. o-0


Furthermore: /i /invite $$1 $1 # Would that invite the specified nick to the specified channel and invite the nick to the channel you're on if no channel is specified?


well, YES it only works if the nickname is on the channel (you can't retreive a nicknames address unless it's on the channel, i thought you knew that) wich - in turn - means NO you can't use the /unban alias coz "raw -q mode # -b $address($1,1)" means setting -b to an address of a nickname that's BANNED (so it ain't on the channel, so NO you can't operate -b on it's address)

about the invite alias, you could use this

Code:
; usage: /i <nickname> <#channel(optional)>
alias i { invite $1 $iif($2,$2,$chan) }


on me:*:JOIN:#: { .raw part # $crlf join # }
SplitFire #185079 04/09/07 08:22 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Originally Posted By: SplitFire
Originally Posted By: Mpot
Originally Posted By: SplitFire
this should work, not tested tho;

Code:
; usage: /kb <nick> <reason(Optional)>

alias kb {
 .raw -q mode # +b $address($1,1) $crlf kick # $1 $iif($2,: $+ $2)
}


Would I be able to do

Code:

alias unban {
 .raw -q mode # -b $address($1,1) 
}


Edit: That works, but only if they're on the channel. o-0


Furthermore: /i /invite $$1 $1 # Would that invite the specified nick to the specified channel and invite the nick to the channel you're on if no channel is specified?


well, YES it only works if the nickname is on the channel (you can't retreive a nicknames address unless it's on the channel, i thought you knew that) wich - in turn - means NO you can't use the /unban alias coz "raw -q mode # -b $address($1,1)" means setting -b to an address of a nickname that's BANNED (so it ain't on the channel, so NO you can't operate -b on it's address)

about the invite alias, you could use this

Code:
; usage: /i <nickname> <#channel(optional)>
alias i { invite $1 $iif($2,$2,$chan) }



Horstl said it could be done, and I'm guessing fairly simply if I set the KB alias to use mask 5 instead of mask 4.

Mpot #185089 04/09/07 10:09 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Well, it IS possible, but not that easy...
Code:
/*
remove all bans affecting a user or a mask on a certain chan or the active channel
syntax: /remban <nick|mask> [#channel]

method used: 
- nick entered: check for nick being in your ial, or try to get nick's address per /who. 
- mask entered: complete that mask
  (so it works with nick!ident@host but also for !ident or ident@host or @*.domain etc).
- remove on that chan all bans affecting that address/mask by looping the internal banlist.
*/

alias remban {
  var %echo = echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:)
  ; error checking feedback
  if (!$1) {
    %echo Syntax is /remban <nick or mask> [#channel]
    return
  }
  var %chan = $iif(($2),#$2,$active)
  if (%chan !ischan) { %echo No channel specified. Syntax: /remban <nick or mask> [#channel] }
  elseif ($me !ison %chan) { %echo You have to be on channel $qt(%chan) to remove bans. }
  elseif (($me !isop %chan) && ($me !ishop %chan)) {
    %echo You have to be opped on channel $qt(%chan) to remove any bans.
  }
  elseif (!$chan(%chan).ibl) {
    %echo Internal banlist of $qt(%chan) not up to date (retrieving the banlist now). $& 
      Try again in a second...
    .mode %chan +b
  }
  ; unban or get mask and unban (...further error checking)
  else {
    if ($ial($1)) { rb.unban $v1 %chan }
    elseif ($regex($1,/!|@/)) {
      var %mask = $rb.getmask($1)
      if ((%mask == error) || (!$regex(%mask,/^[-\]\\_\*^[{}|`\w]+![\w\*~-]+@[\w\.\*-]+$/)))  { 
        %echo $qt($1) cannot be a valid (partial) mask.
      }
    }
    elseif (!$regex($1,/^[-\]\\_^[{}|`\w]+$/)) { %echo $qt($1) cannot be a valid nickname. }
    else {
      set -e %remban.nick $1
      set -e %remban.chan %chan
      .enable #who.remban
      who $1
    }
  }
}

; return a 'wildcard fullmask' of a maybe partial mask input
; (this alias is pretty ugly but useful :X)
alias -l rb.getmask {
  var %m = $strip($1)
  ; invalid input
  if ($regex(%m,/!.*!|@.*@|!@|@.*!/)) { return error }
  if ($remove($gettok(%m,2,64),$chr(42),$chr(45),$chr(46))) {
    if ($v1 !isalnum) { return error }
  }
  if ($remove(%m,$chr(33),$chr(42),$chr(64)) == $null) { return *!*@* }
  ; input == nick
  if (!$regex(%m,/!|@/)) { return $+(%m,!*@*) }
  else {
    if ($regex(%m,/!/)) {
      ; input contains only !
      if (!$regex(%m,/@/)) { 
        if ($left(%m,1) == $chr(33)) { var %m = $+($chr(42),%m) }
        if ($right(%m,1) == $chr(33)) { var %m = $+(%m,$chr(42)) }
        return $+(%m,@*)
      }
      else { 
        ; input contains ! and @
        if ($istok(!•@,$left(%m,1),149)) { var %m = $+($chr(42),%m) }
        if ($right(%m,1) == $chr(64)) { var %m = $+(%m,$chr(42)) }
        return %m
      }
    }
    else {  
      ; input contains only @
      if ($left(%m,1) == $chr(64)) { var %m = $+($chr(42),%m) }
      if ($right(%m,1) == $chr(64)) { var %m = $+(%m,$chr(42)) }
      return $+(*!,%m)
    }
  }
}

; parsing who replies
#who.remban off
RAW 352:*: {
  if ($6 == %remban.nick) {
    rb.unban $+($6,!,$3,@,$4) %remban.chan
    set %remban.done 1
    haltdef 
  }
}

RAW 315:*: {
  if ($2 == %remban.nick) { 
    if (!%remban.done) {
      echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:) Did not find user $qt($2) on $network $+ . $&
        You might remove bans matching the nick $qt($2) with: /remban $rb.getmask($2) %remban.chan
    }
    unset %remban.*
    .disable #who.remban
    haltdef
  }
}
#who.remban end

; unban loop
alias -l rb.unban {
  var %nr = 1, %bans
  while ($ibl($2,%nr)) {
    if ($v1 iswm $1) {
      inc %bans 
      mode $2 -b $v1
    }
    inc %nr
  }
  if (%bans) { echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:) removing %bans ban(s) matching $qt($1) on channel $2 $+ . }
  else { echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:) Found no bans matching $qt($1) on channel $2 $+ . }
}

...as you see. Thus, no good thing to start out scripting smile

Horstl #185090 04/09/07 10:22 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
You have no idea how much I love you right now. Is there a way I can get in contact with you again in the future?

Edit: Can I change /remban to /unban?

Last edited by Mpot; 04/09/07 10:45 PM.
Mpot #185091 04/09/07 10:43 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
blush (btw, I did a little edit above)
As stated, take your time. That's most important. You will - we all do - learn continually more with every new script you make, and with every error you fix by yourself.
You can find some helpful links about debugging and common errors here

Use /help frequently. It's your best friend!
This reference is also a big help: mScriptBox v1.20

And of course: should you have questions, or problems with your code you cannot solve on your own, just start a fresh thread on this message board smile

Reply to edit: You can rename "alias remban {" to "alias unban {" (and other occurrences of "remban" in that script), but better keep the names of the other aliases.

Last edited by Horstl; 04/09/07 10:54 PM.
Horstl #185093 04/09/07 10:53 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Don't know if you noticed my edit above, or if you'll be checking through this thread again, so I'll say again.

Can I change /remban to /unban?

Also, thank you a TON. I can barely cough out onTEXTs. :P

EDIT: var %mask = $rb.getmask($1)

Stuff like that I should leave? I confuzzled.

And stuff like set -e %remban.nick $1
set -e %remban.chan %chan
.enable #who.remban
who $1

Last edited by Mpot; 04/09/07 10:59 PM.
Mpot #185094 04/09/07 11:16 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Open the file in your scripts editor > ctrl-f > find text: "remban" replace with: "unban" > uncheck "search all files in this section" > replace all smile

Horstl #185095 04/09/07 11:20 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Brilliant. :P

Thanks again!

Horstl #185104 05/09/07 01:05 AM
Joined: Sep 2007
Posts: 32
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Sep 2007
Posts: 32
Originally Posted By: Horstl
Well, it IS possible, but not that easy...
Code:
/*
remove all bans affecting a user or a mask on a certain chan or the active channel
syntax: /remban <nick|mask> [#channel]

method used: 
- nick entered: check for nick being in your ial, or try to get nick's address per /who. 
- mask entered: complete that mask
  (so it works with nick!ident@host but also for nick! or !ident@host or *@*.domain etc).
- remove on that chan all bans affecting that address/mask by looping the internal banlist.
*/

alias remban {
  var %echo = echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:)
  ; error checking feedback
  if (!$1) {
    %echo Syntax is /remban <nick or mask> [#channel]
    return
  }
  var %chan = $iif(($2),#$2,$active)
  if (!%chan) { %echo No channel specified. Syntax: /remban <nick or mask> [#channel] }
  elseif ($me !ison %chan) { %echo You have to be on channel $qt(%chan) to remove bans. }
  elseif (($me !isop %chan) && ($me !ishop %chan)) {
    %echo You have to be opped on channel $qt(%chan) to remove any bans.
  }
  elseif (!$chan(%chan).ibl) {
    %echo Internal banlist of $qt(%chan) not up to date (retrieving the banlist now). $& 
      Try again in a second...
    .mode %chan +b
  }
  ; unban or get mask and unban (...further error checking)
  else {
    if ($ial($1)) { rb.unban $v1 %chan }
    elseif ($regex($1,/!|@/)) {
      var %mask = $rb.getmask($1)
      if ((%mask == error) || (!$regex(%mask,/^[-\]\\_\*^[{}|`\w]+![\w\*~-]+@[\w\.\*-]+$/)))  { 
        %echo $qt($1) cannot be a valid (partial) mask.
      }
    }
    elseif (!$regex($1,/^[-\]\\_^[{}|`\w]+$/)) { %echo $qt($1) cannot be a valid nickname. }
    else {
      set -e %remban.nick $1
      set -e %remban.chan %chan
      .enable #who.remban
      who $1
    }
  }
}

; return a 'wildcard fullmask' of a maybe partial mask input
; (this alias is pretty ugly but useful :X)
alias -l rb.getmask {
  var %m = $strip($1)
  ; invalid input
  if ($regex(%m,/!.*!|@.*@|!@|@.*!/)) { return error }
  if ($remove($gettok(%m,2,64),$chr(42),$chr(45),$chr(46))) {
    if ($v1 !isalnum) { return error }
  }
  if ($remove(%m,$chr(33),$chr(42),$chr(64)) == $null) { return *!*@* }
  ; input == nick
  if (!$regex(%m,/!|@/)) { return $+(%m,!*@*) }
  else {
    if ($regex(%m,/!/)) {
      ; input contains only !
      if (!$regex(%m,/@/)) { 
        if ($left(%m,1) == $chr(33)) { var %m = $+($chr(42),%m) }
        if ($right(%m,1) == $chr(33)) { var %m = $+(%m,$chr(42)) }
        return $+(%m,@*)
      }
      else { 
        ; input contains ! and @
        if ($istok(!•@,$left(%m,1),149)) { var %m = $+($chr(42),%m) }
        if ($right(%m,1) == $chr(64)) { var %m = $+(%m,$chr(42)) }
        return %m
      }
    }
    else {  
      ; input contains only @
      if ($left(%m,1) == $chr(64)) { var %m = $+($chr(42),%m) }
      if ($right(%m,1) == $chr(64)) { var %m = $+(%m,$chr(42)) }
      return $+(*!,%m)
    }
  }
}

; parsing who replies
#who.remban off
RAW 352:*: {
  if ($6 == %remban.nick) {
    rb.unban $+($6,!,$3,@,$4) %remban.chan
    set %remban.done 1
    haltdef 
  }
}

RAW 315:*: {
  if ($2 == %remban.nick) { 
    if (!%remban.done) {
      echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:) Did not find user $qt($2) on $network $+ . $&
        You might remove bans matching the nick $qt($2) with: /remban $rb.getmask($2) %remban.chan
    }
    unset %remban.*
    .disable #who.remban
    haltdef
  }
}
#who.remban end

; unban loop
alias -l rb.unban {
  var %nr = 1, %bans
  while ($ibl($2,%nr)) {
    if ($v1 iswm $1) {
      inc %bans 
      mode $2 -b $v1
    }
    inc %nr
  }
  if (%bans) { echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:) removing %bans ban(s) matching $qt($1) on channel $2 $+ . }
  else { echo -ac info [remove bans] $+($chr(3),$color(norm).dd,:) Found no bans matching $qt($1) on channel $2 $+ . }
}

...as you see. Thus, no good thing to start out scripting smile



var %chan = $iif(($2),#$2,$active) <--- I doubt that would work, for 2 reasons:

1- $2 is an identifier, you can't use #$2, it should be $chr(35) $+ $2

2- the whole # thing is useless, coz the usage is supposed to be /remban <nick|mask> [#channel] so even if you used $chr(35) $+ $2 it would result in ##channel wich is ofcourse wrong


on me:*:JOIN:#: { .raw part # $crlf join # }
SplitFire #185110 05/09/07 02:00 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
You did not even try it.
Code:
alias try { echo -a could join #$1 now }
/try test
/try #test

The #$N is added above just for error prevention and convenience. You'll find it at /help aliases:
Quote:
the # sign indicates that the parameter you specify should be prefixed with a hash indicating that it is a channel.
...and mIRC is clever enough to add this hash only if there is none.

Horstl #185112 05/09/07 02:12 AM
Joined: Sep 2007
Posts: 32
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Sep 2007
Posts: 32
true, i never tried it
never bothered to stick any sign to any identifier in the first place without using $+
i'm kinda too lazy lol, besides, the $+ sign does stick strings without errors so yeah ..


on me:*:JOIN:#: { .raw part # $crlf join # }
SplitFire #185251 07/09/07 01:52 AM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
kickban: #mpot is not a channel!


Getting that on all the channels I'm trying. Just... stopped working.

Mpot #185321 08/09/07 04:36 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
For some reason I couldn't edit my previous post, my apologies for the double posting. Anyhow, I just tried restarting mIRC, seeing as I leave it on 24/7. Didn't help. =\

SplitFire #185322 08/09/07 04:57 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
#$2 just ensures that $2 is a channel parameter. You can't normally stick things directly in front of or after identifiers, but there are exceptions. As a rule of thumb, you should try a script before declaring that it doesn't work, because there's so many quirks in the script parser that you could be wrong without realising.

You can attach things to the end of the $N identifiers too: //tokenize 32 a | echo -a $1bc

hixxy #185323 08/09/07 05:03 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Er, you lost me. I was using the /kb alias and it was working fine until it buggered.

Mpot #185324 08/09/07 05:08 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I wasn't replying to you wink

Mpot #185344 08/09/07 09:31 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Please post your current kb alias. If you're not executing this alias out of an editbox, show us the triggering part of code, too.
In what situation did the error occur?

Horstl #185345 08/09/07 09:34 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Code:
; You can add comments to a code - all lines prefixed with a ; will be ignored while processing your code.
; Of course you can remove all these comments if you like

; kickban per editbox command (example)
alias kb {

  ; the window where you entered the command is not a active channel 
  ; [note how the operator "ison" has been negated with an exclamation mark]

  if ($me !ison $acitve) { echo -a kickban: $active is not a channel! }

  ; no first parameter (no nick given)
  ; [using the 'negation-prefix' again, this time to check whether there was a parameter entered]

  elseif (!$1) { echo -a kickban: no nick specified. Syntax: /kb <nick> <optional kick-reason> }

  ; first paramter given is not a nick on that chan

  elseif ($1 !ison $chan) { echo -a kickban: $1 is not a nick on $active }

  ; no sufficient channel rights (only ops, halfops etc can kick or ban a user)
  ; [this line combines two "if" comparisons with "or"]

  elseif (($me isreg $active) || ($me isvoice $active)) { echo -a kickban: Your have no sufficient channel rights on active to kick or ban }

  ; none of the possible errors above occured: perform the ban with "mode" as you liked, followed by a kick. 
  ; [desired banmask "4" via $address(nick,4). "$2-" refers to the 2nd parameter onwards, in this case the kick reason]

  else { 
    mode $active +b $address($1,4)
    kick $active $1 $2-
  }

}


Well. I was doing /kb nick and it gives me " kickban: #mpot is not a channel! "

But it is a channel because I was typing it in that channel window.

And then I tried /kb #channel nick from a different channel and it gave me the same error as above, except for the channel that I typed it in. It didn't error for the channel specified.


Mpot #185349 08/09/07 09:52 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Now I see the problem - sorry, it's been my own typo.
if ($me !ison $acitve)
has to be:
if ($me !ison $active)

In addition, the line "elseif ($1 !ison $chan)" should be "elseif ($1 !ison $active)" (just for conformity)
Note: The alias was only for kickbanning on the editbox's channel, not for providing a channel parameter.

Horstl #185350 08/09/07 10:03 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Works like a dream now. Thanks a bunch!

On a funnier note, I kept trying /kb #channel nick until I looked at the script again and realized that that wasn't a feature. Me and my stupidity. XD

Page 1 of 3 1 2 3

Link Copied to Clipboard