(→Event prefixes) |
(→& prefix) |
||
Line 100: | Line 100: | ||
=== & prefix === | === & prefix === | ||
− | The '''& prefix''' can be used to prevent the event from being executed if the previous event called the {{mIRC|/haltdef }} or {{mIRC|/halt}} commands. | + | The '''& prefix''' can be used to prevent the event from being executed if the previous event called the {{mIRC|/haltdef }} or {{mIRC|/halt}} commands (if $halted is $true). |
For example, given the following two on TEXT events placed in separate files... | For example, given the following two on TEXT events placed in separate files... |
Revision as of 15:18, 27 September 2015
- On events
- Access levels
- Raw Events
- Ctcp Events
Access levels in mIRC are a mechanism by which events can be restricted to certain user levels or named groups. Almost all events have a level parameter that specifies the event's access level.
Contents
User list
The list of users and their access is stored in the "users" tab of the script editor. Only a single address is stored per line and must follow the following syntax:
<levels>:<address> <additional info>
Access levels are comma-delimited values that define the levels of the user. Although usually, the levels are numeric, you can use a name instead like "botAdmin" or "friends".
The <info> parameter is an optional parameter that can be used to store some additional information about the user or other useful miscellaneous data.
10,20:some!one@example.com friend:dan!z@some.isp.net high school friend
Adding/Removing users
There are two commands that can be used to add a user to the access list, /auser and /guser. They follow this syntax:
/auser [-a] <levels> <name|address> [info] /guser [-a] <levels> <name> [addressType] [info]
Both /auser and /guser do the same thing, they add a specific user to the user list with the access levels specified (Comma delimited). The -a switch can be used to simply add additional access levels to an existing user, otherwise all the old levels gets replaced with the new ones. The fundamental difference between /auser and /guser is that /guser can be used to look up the address of a user while /auser requires you to provide it beforehand.
;Add joe (address mask type 2), access level 'friend' /guser friend joe 2 neighbor
The /ruser command can be used to remove a user completely from the access list or simply remove one of his levels.
/ruser [levels] <name|address> [type]
For example:
/ruser madman 2 /ruser 2,10 foobar
The user info parameter can be changed at any time using the /iuser command:
/iuser <name|address> [info]
Usage
The <level> parameter of an event is used to indicate which level/group can activate that event. For example:
on 10:text:.hello:#:{ msg $chan Hello $nick $+ ! }
Notice the access level defined is 10. In this case any user in your access list level 10 or above will trigger this event.
Event prefixes
mIRC offers a lot of prefixes to slightly alter how the event activates.
me prefix
The 'me' prefix can be used to get an event to trigger only if you triggered it (only if $nick == $me)
Note: the me prefix is a bit special, it requires a new colon before others prefixes.
For example:
on me:*:join:#support:{ msg $chan Hello $chan $+ , I need help! }
! prefix
The exclamation mark prefix can be used to prevent an event from being activated by you (if ($nick != $me)).
For example:
on !1:join:#support:{ msg $chan Hello $nick $+ , do you need help? }
The event above will never get activated by you joining #support, only other people.
@ prefix
The @ symbol can be used as a prefix to indicate that the event can only be activated if you are an operator in the channel. You can think of it as "if ($me isop $chan) {"
For example:
on @10:text:.op:#myChan:{ mode $chan +o-v $nick $nick }
The code above will only work if you are an operator in #myChan at the time the user typed ".o".
& prefix
The & prefix can be used to prevent the event from being executed if the previous event called the /haltdef or /halt commands (if $halted is $true).
For example, given the following two on TEXT events placed in separate files...
script1.mrc
on *:TEXT:!test:?:haltdef
script2.mrc
on &*:TEXT:*:?:echo -ga I triggered because $!halted == $halted $+ !
The second event will trigger upon recieving any msg sent via query except !test, because the first event calls the haltdef command upon receiving !test.
* prefix
This prefix can be used to allow any user to activate the event regardless of their access level.
For Example:
on *:text:.calc *:#:{ notice $nick $2- = $calc($replace($2-, pi, $pi)) }
+ prefix
By default, the numeric prefix means that level and any level higher can trigger that event. Using the + prefix, you can limit the event to be exactly the level specified.
For example:
on +5:text:.h:#myChan:{ mode $chan +h $nick }
The code above will only work for users with access level of exactly 5. Any user with higher access level will not activate that event.
$ prefix
This event prefix means the matchtext of the event is a regular expression, the delimiter are required.
on $*:text:/^([!@.])test$/:#myChan:{ msg $chan $nick triggered test with $regml(1) }
Named access levels
Sometimes it's beneficial to give an access group a name instead of a numeric value. A good example is bot admins, friends, or even channel members. You can define such groups using the normal /guser and /auser commands:
/guser BotAdmin Mike123 2 /guser BotAdmin Joe73 2 /guser BotAdmin Dave12 2
With that you can use the named group level in events, for example:
on BotAdmin:text:!example:#:{ msg $chan Hello Bot Admin! }