mIRC Home    About    Download    Register    News    Help

Print Thread
mirc error event? #231280 10/04/11 07:00 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Hello,

I don't mean the on error event. Supposedly that only relays an error message from the server. I want access to mirc's internal errors.

Let's say I enter a command that doesn't exist.

/command 1
mIRC says in the status window: COMMAND Unknown command

Is there anyway, besides monitoring my status window, that I can be notified of this in a script?

I was messing around with a text response script where I make mirc remotely perform a dynamic command. (I know how dangerous this can be, thanks.) Just for fun I wanted to let the remote user know if the command failed. I put an :error with messaging at the bottom but it didn't catch the error of the unnknown command.

Code:
  elseif ($1 = .c) $eval($2-,2)
return
:error { echo 4 -s ERROR: $error | msg # $error }


Any ideas? Thanks.

Re: mirc error event? [Re: DJ_Sol] #231282 10/04/11 07:13 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
That message isn't an internal mIRC error. When you execute a command mIRC does the following:
a) Checks for an alias with that name and executes it.
Or if not:
b) Checks for a built-in command with that name and executes it
Or if not:
c) Sends it to the server.

If there's no such command recognised by the server then it will respond with raw 421 (ERR_UNKNOWNCOMMAND), which is what you see in the status window. So in answer to your question you need to use a raw event to catch 421.

If you don't want it to get to the stage where it sends it to the server in the first place then you'd need to perform the checks mentioned above yourself. You can use $isalias() for the first check, unfortunately there's no easy way to check for built-ins so you'd probably have to check against a hardcoded list of existing commands in your script.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: mirc error event? [Re: starbucks_mafia] #231283 10/04/11 07:18 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Cool man, thanks. smile

Re: mirc error event? [Re: DJ_Sol] #231284 10/04/11 07:22 PM
Joined: Mar 2010
Posts: 145
Masoud Offline
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 145
If i get your meaning currectly, you can store the channel name and command somewhere and then handle RAW 421 which is for Unknown command... Something like this:

Code:
alias AddCommand {
  if (!$hget(MyCmds)) { hmake MyCmds }
  hadd -m MyCmds $1 $eval($2-,0)
}

on *:Text:*:#:{
  ; Doing some validation for triggers and stuff here...
  AddCommand $chan $eval($2-,0)
  $(,$2-)
}

raw 421:*:{
  if ($hget(MyCmds)) {
    if ($hfind(MyCmds,$+(*,$2,*),1,w).data) {
      msg $gettok($hget(MyCmds,$v1),1,32) It seems $qt($2) is an unknown command!
      hdel MyCmds $v1
    }
  }
}


Hope that helps...


Nothing...
Re: mirc error event? [Re: starbucks_mafia] #231286 10/04/11 07:43 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: starbucks_mafia
unfortunately there's no easy way to check for built-ins so you'd probably have to check against a hardcoded list of existing commands in your script.
It's possible to fetch mIRC's internal errors:
Code:
alias !msg {
  msg # $iif($1,$1-)
  return
  :error
  if (/msg: insufficient parameters isin $error) {
    echo 4 -a * The error $qt($v1) has been caught!
    reseterror
  }
}
/msg <message> will send a message to the channel. Without the message but the /msg command, it'll echo that the error has been caught in red.

Re: mirc error event? [Re: Tomao] #231287 10/04/11 07:58 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
I meant there was no easy way to check if a given string is the name of a built-in command, ie. you cannot know if "/moo" will call an internal command or be sent to the server.


Spelling mistakes, grammatical errors, and stupid comments are intentional.