From WikiChip
Difference between revisions of "mirc/commands/signal"
< mirc‎ | commands

m (Bot: Fixing compatibility)
m (Switches: Fix formatting.)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Signals are a simple way of triggering signal events in multiple scripts at the same time. Once set up to listen for the signal event, either directly or indirectly (using a '''*''' wildcard), your scripts can each perform their own duties based on the signal you've provided.
+
{{mirc title|/signal Command}}
== Signal Command ==
+
The '''/signal''' command is used to send a signal to all loaded script, if one of them has a matching {{mIRC|on signal}} event, it triggers. Signals are a simple way of triggering signal events in multiple scripts at the same time.
Signals have a very simple syntax:
+
 
 +
== Synopsis ==
 
<syntaxhighlight lang="mirc">/signal [-n] <name> [parameters]</syntaxhighlight>
 
<syntaxhighlight lang="mirc">/signal [-n] <name> [parameters]</syntaxhighlight>
  
=== Flags ===
+
== Switches ==
'''-n''': This flag tells the ''/signal'' command to fire immediately after the end of the current routine, not after the end of the whole script processing, which is the case if you don't provide -n.
+
* '''-n''': This flag tells the ''/signal'' command to fire immediately instead of waiting for the end of the whole current script processing, this implies nested call to signal event and also recursion can be made, though the maximum you can get is 24 iterations. If you don't provide the -n switch, mIRC waits for the end of the whole current script processing and then triggers any matching events.
  
=== Examples ===
+
== Parameters ==
 +
* '''<name>''' - the name of a signal event
 +
* '''[parameters]''' - the optional parameter passed to the signal event
 +
 
 +
== Examples ==
 
Let's check out an example of a signal command below:
 
Let's check out an example of a signal command below:
 
<syntaxhighlight lang="mirc">/signal mysignal Signal information!</syntaxhighlight>
 
<syntaxhighlight lang="mirc">/signal mysignal Signal information!</syntaxhighlight>
Line 16: Line 21:
  
 
== Identifiers ==
 
== Identifiers ==
<span style="display: inline-block; width: 85px;">''$signal''</span>Returns the signal name of the signal which triggered the current event.
+
* '''$signal''' - Returns the signal name of the signal which triggered the current event.
 
+
* '''$1-''' - Returns any optional parameters that have been passed along with the signal.
<span style="display: inline-block; width: 85px;">''$1-''</span>Returns any optional parameters that have been passed along with the signal.
 
  
 
== Example Script ==
 
== Example Script ==
Line 71: Line 75:
 
{{mIRC command list}}
 
{{mIRC command list}}
  
[[Category:MIRC commands]]
+
[[Category:mIRC commands|signal command - mIRC]]

Latest revision as of 22:17, 22 January 2024

The /signal command is used to send a signal to all loaded script, if one of them has a matching on signal event, it triggers. Signals are a simple way of triggering signal events in multiple scripts at the same time.

Synopsis[edit]

/signal [-n] <name> [parameters]

Switches[edit]

  • -n: This flag tells the /signal command to fire immediately instead of waiting for the end of the whole current script processing, this implies nested call to signal event and also recursion can be made, though the maximum you can get is 24 iterations. If you don't provide the -n switch, mIRC waits for the end of the whole current script processing and then triggers any matching events.

Parameters[edit]

  • <name> - the name of a signal event
  • [parameters] - the optional parameter passed to the signal event

Examples[edit]

Let's check out an example of a signal command below:

/signal mysignal Signal information!

Once you've executed this command, it will send a signal named mysignal to all scripts in your mIRC remotes. Any script files that have signal event listening for that signal will trigger, and perform whatever tasks they have been set to perform.

ON *:SIGNAL:mysignal:echo -s rcvd: $signal : $1-

Identifiers[edit]

  • $signal - Returns the signal name of the signal which triggered the current event.
  • $1- - Returns any optional parameters that have been passed along with the signal.

Example Script[edit]

Now that we know some basic data that can be obtained from a signal, as well as how to trigger a signal and listen for a signal, let's create a signal and an event that puts these signals to good use!

Useful Scenario[edit]

First, we need to think of something that would make a signal useful. Although signals are useful in simple scenarios, more difficult scenarios can truly pinpoint just how useful these signals can be. How about delaying an auto join script until after your auto identifier script has identified you to a network's NickServ? Let's get into some details.

Some networks allow users to have their own, personalized virtual hosts, which change their host masks to any vanity they would like. Host masks are in the form username@their.isp.address.net. If you've ever performed a /whois on a nickname on an IRC network, this will look familiar. What a vHost will do, when a network offers and or provides you with one, is they mask your true host, and usually they can be vanity, meaning you can make them anything you desire. For example, you could make yours username@ILOVEmIRCScripting.net. It can really be any combination of letters and numbers you'd like.

The personalized vHosts will only activate once you have properly identified yourself to NickServ. Once you're identified, your host becomes a vHost mask/vanity, and then your true connection ID is hidden. Well, what if your auto join triggers before you've properly identifed to NickServ services? The vHost would be useless, as your true identity would already have been exposed to the channel upon joining.

This is where a signal can truly shine, and next we are going to show you how :)

Code[edit]

First, what should we name our signal? How about delayAutoJoin? That works, and it identifies the purpose of the signal. Next, which script should perform the /signal command, the auto join, or the auto identifier? Well, just remember that we don't want to join channels until the auto identifier has completed. In this case, we can ascertain that the auto identifier should be the one to trigger the command, the auto join should listen for the signal.

Let's go to our auto identifier and setup our script:

ON *:NOTICE:*This nickname is registered*:?:{
  ; Check to make sure NickServ issued this notice,
  ; and then identify our nickname with our password
  ; (Note: mypassword is an example password; you would insert
  ; your real password here)
  if ($nick == NickServ) { ns identify mypassword }
}

Alright, so what have we done? This event listens for NickServ to send you a notice requesting that you identify yourself to this registered nickname. If that event triggers, next thing we do is check to make sure the nickname who sent us the notice was actually NickServ (security purposes, optional but recommended). Finally, if the nickname was NickServ, send the identification command which includes our password.

Note: For the most part, most NickServ requests like this are defaulted for cross-platform compatibility. Using this example is most-likely fine, but do some research for your own NickServ's requests to properly utilize the above event.

Next, let's check for when NickServ acknowledges that we've properly been identified by letting us know our vHost is now applied:

ON *:NOTICE:*Your vhost*activated*:?: {
  ; Send the delayAutoJoin signal to all listening scripts
  signal delayAutoJoin
}

This event waits for the NickServ notice letting us know our vHost has been activated, and then sends a signal with the name delayAutoJoin to all currently loaded scripts. The auto identifier portion of our example is finished. Now we will move on to the auto join, where we will create our signal listener, and perform the auto join function. Remember, this portion of code belongs in the auto join, not the auto identifier:

ON *:SIGNAL:delayAutoJoin: {
  join #mychannel
}

So, now our auto join script will listen for the signal, which will be triggered once our vHost has been successfully activated, and then join the channel(s) it has been coded to join. For all intense purposes, this event has been trimmed to the simplest possible explanation. It could be made much more extravagant, with an auto join list read from a hash table or an INI file.

Compatibility[edit]

Added: mIRC v6.0
Added on: 03 Feb 2002
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also[edit]

v · d · e mIRC commands list

A /abook, /action, /add, /ajinvite, /alias, /aline, /ame, /amsg, /anick, /aop, /auser, /auto, /autojoin, /avoice, /away

B /background, /ban, /bcopy, /beep, /bindip, /bread, /break, /breplace, /bset, /btrunc, /bunset, /bwrite

C /channel, /clear, /clearall, /clearial, /cline, /clipboard, /close, /closechats, /closedccs, /closefserves, /closemsg, /cnick, /color, /colour, /comclose, /comlist, /commands, /comopen, /comreg, /continue, /copy, /creq, /ctcp, /ctcpreply, /ctcps

D /dcc, /dccserver, /dde, /ddeserver, /debug, /dec, /describe, /dialog, /did, /didtok, /disable, /disconnect, /dlevel, /dline, /dll, Template:mIRC/donotdisturb, /dns, /dqwindow, /drawcopy, /drawdot, /drawfill, /drawline, /drawpic, /drawrect, /drawreplace, /drawrot, /drawsave, /drawscroll, /drawsize /drawtext

E /ebeeps, /echo, /editbox, /else, /elseif, /emailaddr, /enable, /events, /exit

F /fclose, /filter, /findtext, /finger, /firewall, /flash, /flist, /flood, /flush, /flushini, /fnord, /font, /fopen, /fseek, /fsend, /fserve, /fullname, /fupdate, /fwrite

G /ghide, /gload, /gmove, /gopts, /goto, /gplay, /gpoint, /gqreq, /groups, /gshow, /gsize, /gstop, /gtalk, /gunload, /guser

H /hadd, /halt, /haltdef, /hdec, /hdel, /help, /hfree, /hinc, /hload, /hmake, /hotlink, /hop, /hsave

I /ial, /ialclear, /ialmark, /identd, /if, /ignore, /iline, /inc, /iuser

J /join

L /leave, /linesep, /links, /list, /load, /loadbuf, /localinfo, /log, /logview

M /maxdepth, /mdi, /me, /menubar, /mkdir, /mnick, /mode, /msg

N /noop, /notice, /notify

O /onotice, /omsg

P /pareline, /part, /partall, /pdcc, /perform, /play, /playctrl, /pop, /protect, /proxy, /pvoice

Q /qme, /qmsg, /query, /queryrn, /quit, /quote

R /raw, /registration, /reload, /remini, /remote, /remove, /rename, /renwin, /reseterror, /resetidle, /return, /returnex, /rlevel, /rline, /rmdir, /run, /ruser

S /save, /savebuf, /saveini, /say, /scid, /scon, /server, /set, /setlayer, /showmirc, /signal, /sline, /sockaccept, /sockclose, /socklist, /socklisten, /sockmark, /sockopen, /sockpause, /sockread, /sockrename, /sockudp, /sockwrite, /sound, /speak, /splay, /sreq, /strip, /switchbar

T /timer, /timestamp, /tip, /tips, /titlebar, /tnick, /tokenize, /toolbar, /topic /tray, /treebar

U /ulist, /unload, /unset, /unsetall, /updatenl, /url, /username, /uwho

V /var, /vcadd, /vcmd, /vcrem, /vol

W

X /xyzzy