mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 3 1 2 3
Re: /kb alias [Re: Mpot] #185034 03/09/07 10:17 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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

Re: /kb alias [Re: 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.
Re: /kb alias [Re: Mpot] #185037 03/09/07 10:32 PM
Joined: Jan 2006
Posts: 111
N
noMen Offline
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 
  }
}

Re: /kb alias [Re: 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.
Re: /kb alias [Re: Mpot] #185039 03/09/07 10:45 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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

Re: /kb alias [Re: 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.
Re: /kb alias [Re: Mpot] #185044 03/09/07 11:37 PM
Joined: Sep 2007
Posts: 32
S
SplitFire Offline
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 # }
Re: /kb alias [Re: 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.

Re: /kb alias [Re: Mpot] #185089 04/09/07 10:09 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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

Re: /kb alias [Re: 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.
Re: /kb alias [Re: Mpot] #185091 04/09/07 10:43 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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.
Re: /kb alias [Re: 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.
Re: /kb alias [Re: Mpot] #185094 04/09/07 11:16 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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

Re: /kb alias [Re: 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!

Re: /kb alias [Re: Horstl] #185104 05/09/07 01:05 AM
Joined: Sep 2007
Posts: 32
S
SplitFire Offline
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 # }
Re: /kb alias [Re: SplitFire] #185110 05/09/07 02:00 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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.

Re: /kb alias [Re: Horstl] #185112 05/09/07 02:12 AM
Joined: Sep 2007
Posts: 32
S
SplitFire Offline
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 # }
Re: /kb alias [Re: 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.

Re: /kb alias [Re: 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. =\

Re: /kb alias [Re: SplitFire] #185322 08/09/07 04:57 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
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

Page 2 of 3 1 2 3