mIRC Homepage

ON Event for script leaving a channel?

Posted By: davethejackal

ON Event for script leaving a channel? - 03/10/15 11:57 AM

What ON event triggers when my bot/script leaves a channel. I had though ON PART would work but it doesn't seem to.
Posted By: Nillen

Re: ON Event for script leaving a channel? - 03/10/15 12:22 PM

on part, check if ($nick == $me) { do stuff }
Posted By: davethejackal

Re: ON Event for script leaving a channel? - 03/10/15 01:32 PM

Does this work even when you just exit MIRC. I have used it but it doesn't seem to.
Posted By: OrFeAsGr

Re: ON Event for script leaving a channel? - 03/10/15 01:36 PM

ehm.. i think it's obvious that parting a channel isn't even by far related to exiting mIRC..
The event that triggers when you exit mIRC is
on *:EXIT:
Posted By: davethejackal

Re: ON Event for script leaving a channel? - 03/10/15 01:53 PM

Ehm I'd have thought it was obvious that you leave a channel when you exit IRC or disconnect from a server...

The problem is that you can't tell which channels you were in during an exit / disconnect event and the part doesn't seem to be triggered.
Posted By: westor

Re: ON Event for script leaving a channel? - 03/10/15 02:03 PM

In this case use : ON *:DISCONNECT: { } event, the on part event does not trigger while u disconnect from an server and i am sure that ON EXIT is not useful here.

Be careful that in the ON *:DISCONNECT: { } event you must add an loop to track down the channels that you are in using the $chan identifier.

e.g:

Code:
ON *:DISCONNECT: {
  var %t = $chan(0)
  var %i = 1
  while (%i <= %t) {
    var %c = $chan(%i)
    var %tot = $addtok(%tot,%c,44)
    inc %i
  }
  echo -a Disconnected from $server IRC Server, you were into the: $iif(%tot,$v1,None) channel(s).
}


/help on disconnect
/help $chan (it has 2, read both to understand)
Posted By: davethejackal

Re: ON Event for script leaving a channel? - 03/10/15 02:23 PM

Originally Posted By: westor
In this case use : ON *:DISCONNECT: { } event, the on part event does not trigger while u disconnect from an server and i am sure that ON EXIT is not useful here.

Be careful that in the ON *:DISCONNECT: { } event you must add an loop to track down the channels that you are in using the $chan identifier.

e.g:

Code:
ON *:DISCONNECT: {
  var %t = $chan(0)
  var %i = 1
  while (%i <= %t) {
    var %c = $chan(%i)
    var %tot = $addtok(%tot,%c,44)
    inc %i
  }
  echo -a Disconnected from $server IRC Server, you were into the: $iif(%tot,$v1,None) channel(s).
}


/help on disconnect
/help $chan (it has 2, read both to understand)


That is great but I want a catchall. Correct me if I am wrong but that doesn't fire if I just close a chat window for a specific channel.
Posted By: westor

Re: ON Event for script leaving a channel? - 03/10/15 02:50 PM

If you manually close an channel window then you must use the ON *:PART:#: { if ($nick == $me) { do_stuff } } event.
Posted By: davethejackal

Re: ON Event for script leaving a channel? - 04/10/15 12:43 AM

Originally Posted By: westor
If you manually close an channel window then you must use the ON *:PART:#: { if ($nick == $me) { do_stuff } } event.


Is "on part" called when you exit from mIRC, before the DISCONENCT/QUIT etc events?
Posted By: OrFeAsGr

Re: ON Event for script leaving a channel? - 04/10/15 01:05 AM

ON *:PART:#: { do this }
This will trigger when you part a channel. Not when you EXIT mIRC nor when you disconnect from a network.
ON *:EXIT: { do that }
This will trigger when mIRC Closes. aka when you EXIT mIRC
ON *:DISCONNECT: { do the other thing }
This will trigger when you disconnect from a network. Also triggers when you exit mIRC because it disconnects from networks when it closes. But for mIRC Exit use ON *:EXIT:
ON *:QUIT: { do something }
Triggers when other users quit from a network.
© 2022 mIRC Discussion Forums