Description:
This event reacts when a ban is placed on a channel that you are on.
Format:
on LEVEL:BAN:#: commands
Identifier Information:
$nick returns the nickname that placed the ban
$chan returns the channel the ban was placed in
$banmask returns the address that was placed
$ialchan($banmask,#,0) returns the number of people affected by the ban
$ialchan($banmask,#,1).nick returns the first nickname affected by the ban
$level($banmask) returns a userlevel that the ban might match or be similar to
$level($nick) returns the userlevel of the person that placed the ban
Points to Note:
- $bnick only returns the nickname the ban was placed against IF the nickname is specified in the $banmask. This is hardly ever the case, $ialchan($banmask,#,1).nick is usually more effective.
Examples:
The below event changes the default screen output for a ban:
on ^*:BAN:#: echo $colour(mode) # [[ $+ $fulladdress $+ ]] mode +b $banmask | haltdef
The below event unbans the banmask if it matches or affects an OP userlevel:
on @*:BAN:#: {
if ($level($banmask) == OP) {
.mode # -b $banmask
.notice $nick Please don't ban an OP in my userlist!
}
}
The below event unbans a banmask that affects you:
on *:BAN:#: {
if ($banmask iswm $address($me,5)) {
if ($me isop #) .mode # -b $banmask
else chanserv unban # $me
.notice $nick Please don't ban me!
}
}
The below event colours everyone who was banned red (in the nicklist):
on *:BAN:#: {
; This event requires your IAL list to be on and full
; That is, /ial ON, /who #channel
var %i = 0 | var %t = $ialchan($banmask,#,0)
while (%i < %t) { inc %i | cline 4 # $ialchan($banmask,#,%i).nick }
}
The below event lists everyone who was banned by the banmask:
on *:BAN:#: {
; This event requires your IAL list to be on and full
; That is, /ial ON, /who #channel
; Note: Large channels may break the script as %nicks has a limited size (c.950 chrs)
var %i = 0 | var %t = $ialchan($banmask,#,0)
while (%i < %t) { inc %i | set %nicks $addtok(%nicks,$ialchan($banmask,#,%i).nick,44) }
echo $colour(mode) # [[ $+ $banmask $+ ]] affects: %nicks
}
Ideas for the Mind:
- Ban Protection for yourself, your users, etc...
- Ban Flood protection
- You could make a script that would only allow authorized bans to be placed (e.g. if ($readini bans.ini ban $banmask == $null) mode # -b $banmask)
- You could colour the affected nicknames in the nicklist
- You could unban any bans affecting more than, say, 75% of the channel.
- You could count the number of times each ban is placed, then create a report identifying the most common bans and possibly suggest an akick or something similar for them.
***************************************************************************************************
Description:
The on CHAT event reacts when someone says something in a DCC Chat
Format:
on *:CHAT:matchtext: commands
Identifier Information:
$nick returns the nickname of the person who just chatted
$1- returns what they said
$chat($nick).ip returns their IP address
$chat(0) returns the total number of open chats
$chat(N) return's the name of the N'th open chat
$chat(Nick,N) also works
Points to Note:
- The on CHAT event does not work with userlevels. This is due to the way DCC works.
- You may have multiple dcc chats to one nickname so /close -c2 nick would close the 2nd dcc chat with the nick
- When replying back to the person use /msg =$nick not /msg $nick. The = makes it goto the DCC not through the IRC server
Examples:
The below code repeats whatever the person said back to themselves:
on *:CHAT:*: msg =$nick $1-
The below event closes the dcc chat if the person swears:
on *:CHAT:*: {
if (shit isin $1-) || (dick isin $1-) || (fuck isin $1-) {
msg =$nick I don't like that swearing buddy!
close -c $nick
}
}
Ideas for the Mind:
- Write a partyline. This may be quite difficult and result in lots of DCC Chat windows, however it is _probably_ easier to do for a non-expert scripter than using sockets
***************************************************************************************************
Description:
The on INVITE event reacts when someone invites you to a channel using the /invite command.
Format:
on LEVEL:INVITE:<#[,#]>: commands
Identifier Information:
$nick returns the nickname that invited you
$chan returns the channel you were invited to
$fulladdress returns the full address of the nickname
$level($fulladdress) returns what userlevel the person is
Points to Note:
- You can halt the default text of this event
- You can join a channel that you were invited to using the /join -i switch
- This event works for only the /invite command, not when people /msg or /notice you to invite you.
- $chan relates to the channel you were invited to, not the channel the person is on, this is important when kicking as you will have to use $comchan($nick,N)
Examples:
The below event automatically joins any channels that a person on your OP userlevel invited you to:
on OP:INVITE:#: join -i
The below event replaces the default text:
on ^*:INVITE:#: echo $colour(invite) [[ $+ $fulladdress $+ ]] invited you to join $chan | haltdef
The below event kicks anyone who tries to invite you but is not on your OP userlevel:
on *:INVITE:#:{
if ($level($fulladdress) != OP) && ($me isop $comchan($nick,1)) {
ban $comchan($nick,1) $nick 11
kick $comchan($nick,1) $nick Don't invite me!
}
}
Ideas for the Mind:
- If you are a regular in certain invite only channels and don't want to have to do the entire manual request invite via bot/channel service, then type out /join #channel etc, you could use this event to speed up the process
- You can use this event to detect spammers and mass inviters (However, only mass inviters using the /invite command).
***************************************************************************************************
Description:
The on CONNECT event reacts when you connect to an IRC server (Right after the mOTD is displayed)
Format:
on *:CONNECT: commands
Identifier Information:
$server returns the server you connected to
$me returns your nickname
$time returns the time you connected to the server
$port returns the port that you are connected to
$network returns what IRC network you are on (As displayed in raw 001)
$usermode returns you current usermodes (however they probably are not set yet)
Points to Note:
- For the level you only need to use a * because the event on relates to when you are connecting to an IRC server
- Do not assume that if $network returns DALnet that you are on the actual DALnet IRC Network, some irc server software avaliable for download has factory presets such as the network being DALnet or UnderNet etc...
- Do not assume that $server returns the actual server you connected to. The information that $server uses is derrived from a raw reply. A sneaky IRC server admin could change what is sent in order to think you are on a different network
- The above two points come down to this point: Don't use the on CONNECT event as a way to auto identify to your nickname. Consider using an access list - most nickname services have one.
Examples:
The below event automatically joins the channels #hdtest and #helpdesk
on *:CONNECT: join #HDTest | join #HelpDesk
The below event automatically joins the channels in %autojoin.channels (%autojoin.channels = #hdtest #helpdesk):
on *:CONNECT: {
var %t = $numtok(%autojoin.channels,32)
while (%t > 0) {
join $gettok(%autojoin.channels,%t,32)
dec %t
}
}
The below event automatically joins the channels in %autojoin.channels.$network (Network being evaluated to DALnet or UnderNet or whatever. e.g. %autojoin.channels.DALnet = #HDTest #HelpDesk):
on *:CONNECT: {
var %temp = %autojoin.channels. [ $+ [ $network ] ]
if (%temp) {
var %t = $numtok(%temp,32)
while (%t > 0) {
join $gettok(%temp,%t,32)
dec %t
}
}
}
Ideas for the Mind:
- Well if you look at the examples, one idea is an AutoJoin script. You could make it join different channels depending on what $server you connect to, what $network you connect to, what nickname ($me) you are using etc...
- If you run a bot you probably need to do a few start up routines whenever you connect to the server (e.g. remove any temp userlevels, create a backup of the bot)
- You can check to see if $server is the same server that you indended to connect to. You need to create an alias e.g.
alias secure.connect server $1- | dns $1-
then you should compare the on DNS's $iaddress for the $server and the $1-. If they are the same then its a good indication you are on the correct server (however some servers like irc.dal.net redirect you to different individual servers, so in those cases the $iaddress's won't match).
- You could start a self lagg check, and if the lagg reply is too much, reconnect to a different server in the group until you get to a server that has 'acceptable' lag
***************************************************************************************************
Description:
The on JOIN event reacts when someone joins a channel.
Format:
on LEVEL:JOIN:#[,#]: commands
Identifier Information:
$chan returns the channel that the person joined
$nick returns the nickname that joined the channel
$fulladdress returns the full nick!user@host.domain address for the user
$address returns user@host.domain for the user
$wildsite returns *!*@host.domain for the user
Points to Note:
- There is no identifier to return what channels the person is on that you are not also on, which is why if ($nick ison #channel) only works when both you and that person are both on the #channel. So don't use the on JOIN event to check to see if people are in 'bad' channels, use the on JOIN event to /whois $nick, which will return a raw with the channels that they are on.
- When you first join a channel, even though you may be an AutoOp of some sort, the on JOIN event will not see you as being an op because the actual opping usually takes place after you join the channel. If you need to issue some op-only command when you join the channel then I suggest you use a timer.
Examples:
The below event says to the channel "Gidday, nickname =)" when someone joins #MyChannel:
on *:JOIN:#MyChannel: .msg # Gidday, $nick =)
The below event replaces mIRC's standard output by using the /haltdef command:
on ^*:JOIN:#: echo $colour(join) # [[ $+ $fulladdress $+ ]] joined: $chan | haltdef
The below event updates your IAL whenever YOU join a channel:
on me:*:JOIN:#: who #
The below event shows how many users are on the channel which have the same $wildsite as the person who just joined (You need your /ial on, and the ial list full by typing /who #):
on *:JOIN:#: echo $colour(join) *** There are $ialchan($wildsite,#,0) users who come from $wildsite
The below event lists all the clones for the person who just joined:
on *:JOIN:#: {
var %t = $ialchan($wildsite,#,0)
if (%t == 1) return
var %i = 0
while (%i < %t) {
inc %i
var %names = $addtok(%names,$ialchan($wildsite,#,%i).nick,44)
}
echo $colour(join) *** There are %i users who come from $wildsite $+ : %names
}
The below event counts how many visitors have visited your channel:
on *:JOIN:#Your_Channel: {
inc %join.count. [ $+ [ $chan ] ]
.notice $nick You are visitor number %join.count. [ $+ [ $chan ] ] to join #
}
The below event kicks any 'Guest' user (Mainly for DALnet and IRC Networks with NickServ type services):
on @*:JOIN:#: if (Guest????? iswm $nick) { ban -u30 # $nick 11 | kick # $nick No Guests Allowed! }
Ideas for the Mind:
- Create a clone scanner that checks how many clones there are for the person who just joined
- Use this and other events to create a seen script
- Kick people with offensive nicknames
- Op people who match a certain userlevel e.g.
on @OPLIST:JOIN:#chan: mode # +o $nick
- Make an autogreet, or a rules notice
- Kick out people who are not supposed to be in the channel (e.g. if there is a meeting going on)
****************************************************************************************************
Description:
This event reacts when a user is kicked from a channel that you are in
Format:
on LEVEL:KICK:#: commands
Identifier Information:
$knick returns the nickname thas was kicked out of the channel
$nick returns the channel operator that kicked the person out of the channel
$chan returns the channel that the kick took place in
$1- returns the kick message specified by the $nick
$level($ulist($address($knick,5))) returns the first matching level of the person who was kicked
$level($ulist($address($nick,5))) returns the first matching level of the operator who did the kicking
Points to Note:
- People often get confused between $knick and $nick. $knick is the person who was KICKED. $nick is the person who did the KICKING.
Examples:
The below event replaces mIRC's standard output by using the /haltdef command:
on ^*:KICK:#: {
echo $colour(kick) # [[ $+ $fulladdress $+ ]] kicked $knick ( $+ $iif($1,$1-,No Reason) $+ )
haltdef
}
The below event invites anyone on your FRIEND userlevel who was kicked back into the channel:
on FRIEND:KICK:#: invite $nick #
The below event makes you rejoin the channel if you are kicked:
on *:KICK:#: if ($nick == $me) && ($knick != $me) join #
The below event counts how many kicks you have seen (can be annoying!!)
on *:KICK:#: {
inc %kick.count
.notice $nick Hah! You are the $ord(%kick.count) person I have seen kicked!!
}
Ideas for the Mind:
- You could include this event in a seen script - to record when the person left the channel
- You could use this to detect if an op is doing mass kicks
- You can record all kicks and their reasons, and let users retrieve at a later date those reasons. e.g. /notice Bot !WhyKick Nickname -> -Bot- Nickname was last kicked on #SuchAChan for Reason: Some_Reason.
****************************************************************************************************
Description:
The on LOAD event reacts when you load a script. That is, when you type /load -rs scriptname.ext
Format:
on LEVEL:LOAD: commands>
Identifier Information:
$script returns the filename of the currently executing script.
$script(N/Filename) returns the N'th loaded filename, or if you specify Filename and it is not loaded, it returns $null
$scriptdir returns the directory that the currently executing script is in
$version returns what mIRC version the user is running
$bits returns either 16 or 32, which is either the 16bit mIRC version or the 32bit version
$os returns what operating system the user is running
Points to Note:
- The on LOAD event has nothing to do with the on START event. The on LOAD event only reacts when you load the script. The on START event reacts when you start mIRC
- In most cases the user is prompted with a warning asking if it should execute the commands in your on LOAD event. If the user chooses no, then the commands in your on LOAD event will not be executed
Examples:
The below code checks to see if you are running mIRC 5.71 or higher (32bits). If you are not the script unload's itself:
on *:LOAD: {
if ($version < 5.71) || ($bits != 32) {
echo 4 -a *** You must be running a mIRC 5.71 32bit or higher! Unloading script....
unload -rs $script
}
else echo 3 -a *** Script has been loaded!
}
The below code loads further scripts:
on *:LOAD: {
echo 3 -a *** Loading other scripts for this addon
load -rs file1.mrc
load -rs file2.mrc
}
Ideas for the Mind:
- If you have more than one remote file in your script, make it easier on the user by getting them to only load one (e.g. addon-install.mrc) which then in turn loads the rest of the files
- Remeber to use the on LOAD event to check to see if the user is running a compatiable version of mIRC (See the Examples). If the person isn't, you should unload the script and tell them to upgrade.
****************************************************************************************************
Description:
The on START event reacts when mIRC is started (e.g. you double click on the mirc32.exe program)
Format:
on LEVEL:START: commands
Identifier Information:
$me returns your current nickname
$time returns the current time
$appstate returns what state mIRC is in (e.g. maximized)
Points to Note:
- When mIRC first starts your $IP may not return your current IP as mIRC obtains that information when you connect to an IRC server. So don't plan to use a script that needs $ip in an on START
- The on START event differs from the on LOAD event as the on START event reacts EVERY time mIRC is started, however the on LOAD event reacts only when a script is loaded.
Examples:
The below script makes you automatically connect to the last server you were on:
on *:START: server
The below script simply reports the date and your current nickname:
on *:START: {
echo 3 -a *** The time is $time and you are called $me and what a wonderful day it is outside =P~
}
The below script tells you how many times you have used the script:
on *:START: inc %times.used | echo 3 -a *** This script has been used %times.used times
Ideas for the Mind:
- The most obvious idea is to clear any records that were left over since mIRC was last used, the on START event is mainly used for startup routines like starting a web server script or a proxy script or whatever your heart desires
****************************************************************************************************
Description:
The on OP event reacts when a person is opped in a channel that you are in.
Format:
on LEVEL:OP:<#,[#]>: commands
Identifier Information:
$nick returns the nickname that opped the person
$opnick returns the nickname that was opped
$chan returns what channel the person was opped in
$dlevel returns the current default user level
$clevel returns the matching event level for a triggered event
$ulevel returns the user level that was matched by the current event
$level($ulist($address($opnick,5))) returns the first matching level for the person who was opped
Points to Note:
- People often get confused between $opnick and $nick. $opnick is the person who was opped by $nick
- The on DEOP/VOICE/DEVOICE/HELP/DEHELP events all accept $opnick as the person who was deopped/voiced/devoiced/helped/dehelped. They also accept $vnick and $hnick
- The LEVEL is the level of the person who was opped - $opnick
- The on RAWMODE event triggers BEFORE the on OP event. This may not be important to most people, but for some it may make a difference
Examples:
The below event replaces mIRC's standard output by using the /haltdef command:
on ^*:OP:#: echo $colour(mode) # [[ $+ $fulladdress $+ ]] opped $opnick | haltdef
The below event only allows people with the userlevel MASTER to gain ops:
on @*:OP:#:{
if ($level($opnick) != MASTER) {
mode # -o $opnick
.notice $opnick Only Masters are allowed ops in #
}
}
The below event thanks the person who opped you:
on *:OP:#: if ($opnick == $Me) && ($nick != $me) .msg # Thanks for the @ $nick !
The below event deop's yourself if you are currently set away:
on *:OP:#: if ($away == $true) { mode # -o $me | .notice $nick Please do not op me while I am away }
The below event colour's the nickname on the nicklist when they are opped:
on *:OP:#: cline 10 # $opnick
Ideas for the Mind:
- You could include this event in a seen script - to record when a user was last opped
- You could restrict ops to only those who have identified to your bot some how (Use $level or $ulist() to check their level)
- You could detect op mode floods and deop the person flooding
- You could colour the person on the nicklist when they are opped, deoped, voiced, devoiced, banned, etc...
- You could track how long the person was opped/voiced in the channel. Could be useful if you want to know how 'active' your people are
***************************************************************************************************
Description:
This event reacts when a window opens. Window types include: Query Windows, Custom Windows, DCC Chat Windows, DCC Fserve Windows.
Format:
on LEVEL:OPEN:<?|@|=|!|*>: commands
? = Query Window
@ = Custom Window
= = DCC Chat Window
! = DCC Fserve Window
Extended format:
on LEVEL:OPEN:<?|=|!>:matchtext: commands
This format allows you to use the matchtext within the on open event, thus not having to wait for the on text event.
Identifier Information:
$target returns the name of the window that was opened
$nick returns the name of the nickname, if applicable
$1- returns the text the person said, if applicable.
Points to Note:
- There is not always a $nick, $level or $fulladdress. This is the case with custom windows obviously, however $level and $fulladdress also do not work in any DCC windows as DCC is seperate and distinct from your IRC session. Thus on LEVEL:OPEN:=: will only work if level is 1 or *.
- You can haltdef this event. If you do prefix this event with the ^ symbol, and halt (thats halt, not haltdef) the event, no further on TEXT event will trigger.
- If you wish to message a someone in the DCC connection, you need to use /msg =$nick .Please note the = sign in front of the $nick, this tells mIRC to send the text to the DCC connection, not to someone on IRC called $nick.
- The OPEN event does not trigger for custom windows.
Examples:
This event triggers when someone tries to open a query window with you, and you don't want to accept messages. It tells the person you do not wish to recieve messages, and ignores any private messages from them for 10 seconds:
on ^*:OPEN:?: {
.notice $nick I am not accepting private messages, please use the channel instead
.ignore -pu10 $nick
halt
}
This event messages the DCC Chat user when you open the DCC Chat connection:
on *:OPEN:=: msg =$nick Hi!
This event displays a small 'infoline' for a DCC Fileserver (Fserver) that you might be running:
on *:OPEN:!: msg =$nick Welcome to my Fserve. For help, type .help or /help /fserve
This event only lets ops or voices in channel #x message you (substitute x for a channel of your choice):
on ^*:OPEN:?: {
if ($nick !isop #x) && ($nick !isvo #x) {
.notice $nick I am not accepting private messages
.ignore -pu10 $nick
halt
}
}
Or alternatively, this event only lets people who are on a channel that you are on (that is, ANY channel), message you:
on ^*:OPEN:?: {
if ($comchan($nick,0) == 0) {
.notice $nick I am not accepting private messages
.ignore -pu10 $nick
halt
}
}
Ideas for the Mind:
- You could use this event to stop people from messaging you without permission.
- You could display a greeting when someone enters your fileserver (and you could use variables, identifiers, etc...)
- You could use it to detect when a @custom window is closed, and as such trigger some events to restore the window, or cancel any timers running that would normally send text to the @custom window.
- You could use this event, in conjunction with the on TEXT event, to create a custom window for your query messages (e.g., halt & haltdef the event, but /aline the text to the @window)
*****************************************************************************************************
Description:
The on QUIT event reacts when someone quits IRC.
Format:
on LEVEL:QUIT: commands
Identifier Information:
$comchan($nick,0) returns the number of channels that both you and the person were on
$nick returns the nickname that quit IRC
$fulladdress returns the full nick!user@host.domain address for the user
$wildsite returns *!*@host.domain for the user
$1- returns the quitmessage, if any
Points to Note:
- The $chan identifier will not return a channel because of the way a quit works. When you quit IRC a line is sent to every IRC user which was on a channel that you were also on. It does not contain any information about what channels the user was on because the user is quitting IRC, not just parting A single channel. This is why you need to use $comchan($nick,N) to find the channels that both you and the person was on.
- When there is a netsplit you see lots of people 'quit' IRC. In their quit message is the two servers that had split for them (Bad explanation, but go with it anyway). Thus you can use the on QUIT event to detect a netsplit.
Examples:
The below event replaces mIRC's standard output by using the /haltdef command:
on ^*:QUIT:{
echo $colour(part) -s [[ $+ $fulladdress $+ ]] quit IRC: $1-
var %i = 0
while (%i < $comchan($nick,0)) {
inc %i
echo $colour(part) $comchan($nick,%i) [[ $+ $fulladdress $+ ]] quit IRC: $1-
}
haltdef
}
The below event will detect a netsplit. You may want to modify it not to repeat (Hint: Use a timer):
on *:QUIT: {
if (*.*.* iswm $1) && (*.*.* iswm $2) {
echo 4 -a *** Netsplit between $chr(2) $+ $1 $+ $chr(2) and $chr(2) $+ $2 $+ $chr(2)
}
}
The below event bans a user who quit with the EXcESS FLOOD reason:
on *:QUIT:{
if ($1 != excess) && ($2 != flood) return
var %i = 0
while (%i < $comchan($nick,0)) {
inc %i
ban $comchan($nick,%i) $nick 3
}
}
Ideas for the Mind:
- Use the on QUIT event in conjunction with other events to make a seen script
- Make a netsplit detector, or go one futher and make a bot that automatically creates another bot that 'jumps' to the split server (Hint: Don't make it use the same nickname as the original bot!)
- Detect offensive words or advertisements in the quit message and ban the person
*****************************************************************************************************
Description:
The on VOICE event reacts when a person is opped in a channel that you are in.
Format:
on LEVEL:VOICE:<#,[#]>: commands
Identifier Information:
$nick returns the nickname that voiced the person
$opnick returns the nickname that was voiced
$chan returns what channel the person was voiced in
$dlevel returns the current default user level
$clevel returns the matching event level for a triggered event
$ulevel returns the user level that was matched by the current event
$level($ulist($address($opnick,5))) returns the first matching level for the person who was voiced
Points to Note:
- People often get confused between $opnick and $nick. $opnick is the person who was voiced by $nick
- The on OP/DEOP/DEVOICE/HELP/DEHELP events all accept $opnick as the person who was opped/deopped/devoiced/helped/dehelped. They also accept $vnick and $hnick
- The LEVEL is the level of the person who was voiced- $opnick
- The on RAWMODE event triggers BEFORE the on VOICEevent. This may not be important to most people, but for some it may make a difference
Examples:
The below event replaces mIRC's standard output by using the /haltdef command:
on ^*:VOICE:#: echo $colour(mode) # [[ $+ $fulladdress $+ ]] voiced $opnick | haltdef
The below event only allows people with the userlevel AVOICE to gain voice:
on @*:VOICE:#:{
if ($level($opnick) != AVOICE) {
mode # -o $opnick
.notice $opnick Only AVOICE's are allowed a voice in #
}
}
The below event thanks the person who voiced you:
on *:VOICE:#: if ($opnick == $Me) && ($nick != $me) .msg # Thanks for the + $nick !
The below event colour's the nickname on the nicklist when they are voiced:
on *:VOICE:#: if ($opnick !isop #) cline 12 # $opnick
Ideas for the Mind:
- You could include this event in a seen script - to record when a user was last voiced
- You could restrict voicesto only those who have identified to your bot some how (Use $level or $ulist() to check their level)
- You could detect voicemode floods and deop the person flooding
- You could colour the person on the nicklist when they are opped, deoped, voiced, devoiced, banned, etc...
- You could track how long the person was opped/voiced in the channel. Could be useful if you want to know how 'active' your people are