Project

General

Profile

alias help

Added by shire pirate about 9 years ago

hello,

trying to extend the usefulness of a script using an alias but not sure if it can be done. currently it will automatically OP or VOICE those that join the channel under given conditions. i want to add a 5-second timer using SLEEP to wait and see if ChanServ does the job before me. so i tried to stick most of it in an alias, then call up the alias using SLEEP, but keep getting the error that "if" is an "Unknown command."

i realize $nick & $chan probably only work through the ONJOIN event too, but i think they could be passed as arguments, yes? main issue seems to be whether or not an if statement can actually be called up using another command i guess. is it possible? thanks for reading.


Replies (11)

RE: alias help - Added by Per Amundsen about 9 years ago

Hi,

Can you post what your script looks like now?

RE: alias help - Added by shire pirate about 9 years ago

sure, this is the script for auto-op & auto-voice

on *:JOIN:#channel:{
  if ($me !isop $chan) {
    msg nickserv identify password
  }
  if ($nick != $me) && ($me isop $chan) {
    if (123.45.678.9 isin $address) {
      mode $chan +v $nick
      ;username1
    }
    if (987-65-432-123.dyn.iinet.net.au isin $address) {
      mode $chan +o $nick
      ;username2
    }
  }
}

all i would like to do is add a 5-second timer to avoid redundancy when ChanServ recognizes the user. any ideas?

RE: alias help - Added by Per Amundsen about 9 years ago

Oh I see, I think you were on the right track, something like this maybe?

on *:JOIN:#channel:{
  ; Run once after 5 seconds, send $chan and $nick as parameters.
  .timer 1 5 example $chan $nick
}

alias example {
  ; $1 is $chan
  ; $2 is $nick
  if ($me !isop $1) {
    msg nickserv identify password
  }
  if ($2 != $me) && ($me isop $1) {
    if (123.45.678.9 isin $address) {
      mode $1 +v $2
      ;username1
    }
    if (987-65-432-123.dyn.iinet.net.au isin $address) {
      mode $1 +o $2
      ;username2
    }
  }
}

Edit: forgot formatting.

RE: alias help - Added by shire pirate about 9 years ago

ah that's great, had a hunch sleep was the wrong command. thanks a lot.

RE: alias help - Added by shire pirate about 9 years ago

hm, this script doesn't work for me anymore when using an alias like that example

on *:JOIN:#channel:{
  .timer 1 3 exampleone $chan $nick
  .timer 1 6 exampletwo $chan $nick
}

alias exampleone {
  if ($me !isop $1) {
    msg nickserv identify password
  }
}

alias exampletwo {
  if ($2 != $me) && ($me isop $1) && ($2 !isop $1) && ($2 !isvoice &1) && ($2 ison $1) {
    if (exampleipaddress isin $address) {
      mode $1 +v $2
      ;username
    }
    if (exampleipaddress2 isin $address) {
      mode $1 +o $2
      ;username2
    }
    if (examplehostname isin $address) {
      mode $1 +v $2
      ;username3
    }
    if (examplehostnametwo isin $address) {
      mode $1 +v $2
      ;username4
    }
  }
}

something wrong with my syntax? it will no longer OP or VOICE anyone.

RE: alias help - Added by Per Amundsen about 9 years ago

This doesn't look right "($2 !isvoice &1)" .. should maybe be "($2 !isvoice $1)"

A good way to test if something works, is to insert /echo commands at various places to see if something is called or what it's value is.

Example:

echo -ag Checking parameters 1 is $1 2 is $2 
echo -ag $iif($2 != $me, not me, me) $iif($me isop $1, i am op, i am not op)
echo -ag Checking $address - $iif(exampleipaddress isin $address, address found, address not found)

And so on, hope that helps.

RE: alias help - Added by shire pirate about 9 years ago

ah, yeah, was a typo when posting to here. had tried different parameters in that line of code already though, doesn't even work if it is just:

if ($2 != $me) {

i added them all in the example as ideally i wanted all of those.

any reason the alias wouldn't be called at all with those timer commands though?

RE: alias help - Added by Per Amundsen about 9 years ago

You can insert echo statements like in my example to figure out what goes wrong and why, here is what I would do in your example.

alias exampletwo {
  echo -ag Checking parameters 1 is $1 - 2 is $2 - $iif(2 != $me, not me, me) - $iif($me isop $1, is op, is not op)
  if ($2 != $me) && ($me isop $1) {
    echo -ag First if statement is ok
    if (exampleipaddress isin $address) {
      echo -ag Example1 ok
      mode $1 +v $2
      ;username
    }
    if (exampleipaddress2 isin $address) {
      echo -ag Example2 ok
      mode $1 +o $2
      ;username2
    }
    if (examplehostname isin $address) {
      echo -ag Example3 ok
      mode $1 +v $2
      ;username3
    }
    if (examplehostnametwo isin $address) {
      echo -ag Example4 ok
      mode $1 +v $2
      ;username4
    }
  }
}

Based on the result from the messages on your screen, you should be able to see what goes wrong.

RE: alias help - Added by shire pirate about 9 years ago

using these echo statements everything reports ok down to the final command,

mode $1 +o $2

or
mode $1 +v $2

then this doesn't work...

edit: perhaps $address needs to be passed along as an argument too? i'll try that...

RE: alias help - Added by shire pirate about 9 years ago

yeah, that was the problem, works now. thanks for the help

RE: alias help - Added by Per Amundsen about 9 years ago

Good catch, I didn't think of that :)

    (1-11/11)