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.

Page 1 of 3 1 2 3

Link Copied to Clipboard