Project

General

Profile

Actions

Scripting » History » Revision 177

« Previous | Revision 177/246 (diff) | Next »
Per Amundsen, 08/28/2013 12:28 AM


Scripting changes as of 1.9.1

Implemented mIRC events so far:

raw <numeric>:<matchtext>:<commands>

ctcp <level>:<matchtext>:<*|#|?>:<commands>

on 1:sockopen:name:commands

on 1:sockread:name:commands

on 1:socklisten:name:commands

on 1:sockclose:name:commands

on *:SIGNAL:name:command

on <level>:LOGON:*:<commands>

on <level>:DNS:<commands>

on <level>:CTCPREPLY:<matchtext>:<commands>

on <level>:OPEN|CLOSE:<?|@|=|!|*>:<matchtext>:<commands>

on <level>:ACTIVE:<*#?=!@>:<commands>

on <level>:HOTLINK:<matchtext>:<*#?=!@>:<commands>

on <level>:INVITE:<#[,#]>:<commands>

on <level>:TABCOMP:<*#?=!@>:<commands>

on <level>:WALLOPS:<matchtext>:<commands>

on <level>:ERROR:<matchtext>:<commands>

on <level>:RAWMODE:#:<commands>

on <level>:DEHELP:<#[,#]>:<commands>

on <level>:HELP:<#[,#]>:<commands>

on <level>:DEVOICE:<#[,#]>:<commands>

on <level>:VOICE:<#[,#]>:<commands>

on <level>:DEOP:<#[,#]>:<commands>

on <level>:OP:<#[,#]>:<commands>

on <level>:INPUT:<*#?=!@>:<commands>

on <level>:UNBAN:<#[,#]>:<commands>

on <level>:BAN:<#[,#]>:<commands>

on <level>:CHAT:<matchtext>:<commands>

on <level>:KICK:<#[,#]>:<commands>

on <level>:NOTIFY:<commands>

on <level>:UNNOTIFY:<commands>

on <level>:NICK:<commands>

on <level>:QUIT:<commands>

on <level>:LOAD:<commands>

on <level>:UNLOAD:<commands>'

on <level>:START:<commands>

on <level>:EXIT:<commands>

on <level>:DNS:<commands>

on <level>:CONNECTFAIL:<commands>

on <level>:CONNECT:<commands>

on <level>:DISCONNECT:<commands>

on <level>:TOPIC:<#[,#]>:<commands>

on <level>:USERMODE:<commands>

on <level>:MODE:<#[,#]>:<commands>

on <level>:PART:<#[,#]>:<commands>

on <level>:JOIN:<#[,#]>:<commands>

on <level>:SNOTICE:<matchtext>:<commands>

on <level>:NOTICE:<matchtext>:<*><?><#[,#]>:<commands>

on <level>:ACTION:<matchtext>:<*><?><#[,#]>:<commands>

on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands>

This event is added as a replacement for OnSongChanged
on <level>:SONG:<commands>

Supported prefixes so far are ^ to enable halt events (hide default text output from the event), ! to ignore events made by you, @ to only trigger if you have channel op, $ to indicate the wildcard text is a regular expression.

User access will come later.

identifiers added so far

$0
$abs
$acos
$active
$activeserver
$activewid
$adate
$address
$addtok
$addtokcs
$adiircdir
$adiircexe
$adiircini
$album
$and
$anick
$appactive
$appstate
$artist
$asc
$asctime
$asin
$atan
$audio
$away
$awaymsg
$awaytime
$base
$bfind
$bindip
$bitoff
$biton
$bitrate
$bvar
$bwdown
$bwdownb
$bwname
$bwspeed
$bwup
$bwupb
$bytes
$calc
$cb
$ceil
$chan
$chanmodes
$channel
$chantypes
$chat
$chr
$cid
$clevel
$cmdline
$color
$colour
$comchan
$comment
$cos
$count
$countcs
$cpucache
$cpucount
$cpuident
$cpuload
$cpumhz
$cpuname
$cr
$crc
$crlf
$ctime
$date
$datediff
$datematch
$day
$daylight
$decode
$decrypt
$deltok
$dialog
$did
$didreg
$didtok
$didwm
$disk
$diskfree
$diskmenu
$disktotal
$dlevel
$dns
$dotnet
$duration
$editbox
$encode
$encodingmenu
$encrypt
$error
$event
$exists
$false
$feof
$ferr
$fgetc
$file
$finddir
$findfile
$findtok
$findtokcs
$fline
$floop
$floor
$fopen
$frand
$fread
$frequency
$fulladdress
$fulldate
$fulltitle
$genre
$getdir
$getdot
$gettok
$gfx
$gfxram
$gmt
$group
$height
$hfind
$hget
$highlight
$host
$ial
$ialchan
$ibl
$ident
$idle
$iel
$ignore
$iil
$inellipse
$ini
$inmidi
$inpaste
$inpoly
$input
$inrect
$insert
$insong
$instok
$int
$invitemenu
$inwave
$ip
$isalias
$isbit
$isdir
$isfile
$isid
$islower
$istok
$istokcs
$istype
$isupper
$layer
$left
$len
$length
$lf
$line
$lines
$log
$logdir
$logstamp
$logstampfmt
$longfn
$longip
$lower
$ltimer
$maddress
$mask
$matchkey
$matchtok
$matchtokcs
$md5
$me
$memfree
$memfreep
$memtotal
$menu
$mid
$mircdir
$mircexec
$mircini
$mkfn
$mklogfn
$mknickfn
$mnick
$mode
$modespl
$motherboard
$mouse
$mp3
$msfile
$mversion
$myhost
$myident
$network
$newnick
$nick
$nofile
$nopath
$noqt
$not
$notify
$now
$null
$numeric
$numtok
$online
$or
$ord
$os
$osbuild
$osedition
$osinstalldate
$osmajor
$osminor
$osname
$osservicepack
$osversion
$percentl
$percentp
$pic
$playcount
$player
$port
$portfree
$pos
$poscs
$position
$prefix
$progress
$prop
$puttok
$qt
$query
$r
$r0
$rand
$raw0
$rawbytes
$rawmsg
$read
$readini
$realname
$regex
$regml
$regsub
$regsubex
$remove
$removecs
$remtok
$remtokcs
$replace
$replacecs
$replacex
$replacexcs
$reptok
$reptokcs
$result
$rgb
$right
$round
$scid
$scon
$screen
$screenb
$screenh
$screenw
$script
$scriptdir
$scriptline
$sdir
$server
$serverip
$sfile
$sha1
$shortfn
$show
$sin
$site
$size
$slapsmenu
$sline
$snick
$sock
$sockbr
$song
$sorttok
$sorttokcs
$sqrt
$status
$str
$strip
$style
$submenu
$tan
$target
$ticks
$time
$timer
$timestamp
$timestampfmt
$timezone
$tip
$title
$token
$toolbar
$totaltracks
$track
$true
$trust
$ulevel
$updays
$uphours
$upmins
$upper
$uptime
$user
$usermode
$utfdecode
$utfencode
$var
$version
$vol
$volume
$volumeb
$volumep
$wid
$width
$wildsite
$wildtok
$wildtokcs
$window
$xor
$year

All operaters are added.

Example scripts

Simple kickcounter script:

alias kick { 
    if (!%kickcount) %kickcount = 0

    inc %kickcount

    if (!$3) { 
        kick # $$2 Kick number %kickcount
        halt
    } 
}

Kickban example

alias kb {
  if (!$1) {
    echo /kb - Nick missing
    return
  }

  var %msg = $iif(#, $2-, $3-)
  var %chan = $iif(#, #, $2)

  ; Set this for default ban reason, or remove for no default reason
  ; Can be shortened to %msg = $iif(%msg, %msg, GTFO)
  if (!%msg) %msg = GTFO

  if ($me isop %chan) {
    MODE %chan +b $wildsite
    KICK %chan $1 %msg
  } 
  else echo You are not oper on %chan
}

Simple calculator script:

alias calc {
  if (!$1) {
    echo /calc - Parameters missing
    return
  }

  ; typing /calc -p <expression> sends output to channel
  if ($1 == -p) {
    msg # Calculating : $2-
    msg # Result is : $calc($2-)
  } else {
    echo Calculating : $1-
    echo Result is : $calc($1-)
  }
}

Colored version

alias calc {
  if (!$1) {
    echo /calc - Parameters missing
    return
  }

  # typing /calc -p <expression> sends output to channel
  if ($1 == -p) {
    msg # $chr(3)4Calculating : $2-
    msg # $chr(3)4Result is : $calc($2-)
  } else {
    echo $chr(3)4Calculating : 4$1-
    echo $chr(3)4Result is : $calc($1-)
  }
}

CTCP flood detection example

CTCP *:*:*:{
  if (!%count) set -u10 %count 1
  else inc -u10 %count 1

  if (%count > 4) ignore -tu30 $wildsite
}

Mass mode example

alias mass {
  if (!$2) {
    echo /mass - Parameters missing [+/-<mode> <nick> <nick> <nick>]
    return
  }

  %len = 2

  ; equal to while (%len <= $count(%1-, $chr(32)))
  while (%len <= $0) {
    if ($(%len) ison #) mode # $1 $($ $+ %len)
    inc %len
  }
}

Shows info about servers, channels and users

on *:JOIN:#: {
  var %s = $scon(0), %c = 0, %u = 0, %t = 0, %c2 = 0;

  while (%t < %s) {
    inc %t
    scon $scon(%t);
    inc %c $chan(0)

    %c2 = 0
    while (%c2 < $chan(0)) {
      inc %c2
      inc %u $user($chan(%c2), 0)
    }
  }

  /echo You are on ( $+ %s $+ ) servers, ( $+ %c $+ ) channels with ( $+ %u $+ ) users
}

It is possible to use scripts as functions.
These functions are fully nested like the client functions.

Lets say you make a /mycalc like this.

alias mycalc {
  return $calc($$1 + $$2);
}

Then you can call this function with eiter /mycalc <number> <number> the normal way or $mycalc(<number, <number>)
Typing /testcalc will show the result.

alias testcalc {
  echo -a $1 + $2 is $mycalc($1, $2);
  echo -a 5 + 4 is $mycalc(5, 4);
}

Simple convert temperature C to F or F to C
/temp C 20 will print 68 F

alias temp {
  if ($1 == C) echo $calc(($2 * 9/5) + 32) F
  else if ($1 == F) echo $round($calc(($2 - 32) * 5/9), 1) C
  else echo Temp missing
}

Announce song changes in a channel or to a user

On *:SONG:{ 
  nmsg <network> <channel/Nick> $1-
}

Announce to several channels with:

On *:SONG:{ 
  nmsg <network> <channel1/Nick>,<channel2/Nick> $1-
  nmsg <network2> <channel3/Nick> $1- 
}

Automatically find the summary of a imdb url

On *:TEXT:*:#k: {
  var %reg = $regex($1-, http://www\.imdb\.com(/title/[a-z0-9]+/))
  if (!%reg) { return }
  sockclose imdb
  unset %data
  %imdb = $regml(1) $+ plotsummary
  %imdbchan = #
  sockopen imdb www.imdb.com 80
}

on *:sockopen:imdb: {
  sockwrite -n imdb GET %imdb HTTP/1.1
  sockwrite -n imdb Host: www.imdb.com
  sockwrite -n imdb User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.24 Safari/536.5
  sockwrite -n imdb Referer: http://www.imdb.com
  sockwrite -n imdb Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
  sockwrite -n imdb Accept-Language: en-us, en;q=0.50
  sockwrite -n imdb Connection: Close $+ $crlf $+ $crlf
}

on *:sockread:imdb:{
  sockread %text
  %data = %data $+ %text 
}

on *:sockclose:imdb: {
  if ($regex(%data, <p class="plotpar">([\s\S]*?)<i>)) {
    msg %imdbchan $regml(1)
  }

  unset %data
}

More information

You can find many mIRC scripts at places such as http://www.hawkee.com/mirc/scripts/ and http://mircscripts.com/

Not everyone will work, if you find one that dosen't, please open a new issue with a link to the script.

For more on mIRC scripting and how it works, check out http://www.zigwap.com/mirc/docs/ and http://www.mirc.org/mishbox/index.htm

Updated by Per Amundsen over 11 years ago · 177 revisions

Also available in: PDF HTML TXT