Project

General

Profile

Scripting » History » Version 172

Per Amundsen, 08/02/2013 02:27 AM

1 167 Per Amundsen
h1. Scripting changes as of 1.9.1
2 39 Per Amundsen
3 166 Per Amundsen
h1. Implemented mIRC events so far:
4 1 Per Amundsen
5 166 Per Amundsen
<pre>
6
raw <numeric>:<matchtext>:<commands>
7 1 Per Amundsen
8 166 Per Amundsen
ctcp <level>:<matchtext>:<*|#|?>:<commands>
9 38 Per Amundsen
10 166 Per Amundsen
on 1:sockopen:name:commands
11 1 Per Amundsen
12 166 Per Amundsen
on 1:sockread:name:commands
13 1 Per Amundsen
14 166 Per Amundsen
on 1:socklisten:name:commands
15 1 Per Amundsen
16 166 Per Amundsen
on 1:sockclose:name:commands
17 149 Per Amundsen
18 1 Per Amundsen
on *:SIGNAL:name:command
19 167 Per Amundsen
20
on <level>:LOGON:*:<commands>
21 1 Per Amundsen
22 166 Per Amundsen
on <level>:DNS:<commands>
23 149 Per Amundsen
24 166 Per Amundsen
on <level>:CTCPREPLY:<matchtext>:<commands>
25 1 Per Amundsen
26 166 Per Amundsen
on <level>:OPEN|CLOSE:<?|@|=|!|*>:<matchtext>:<commands>
27 149 Per Amundsen
28 166 Per Amundsen
on <level>:ACTIVE:<*#?=!@>:<commands>
29 1 Per Amundsen
30 166 Per Amundsen
on <level>:HOTLINK:<matchtext>:<*#?=!@>:<commands>
31 1 Per Amundsen
32 166 Per Amundsen
on <level>:INVITE:<#[,#]>:<commands>
33 1 Per Amundsen
34 166 Per Amundsen
on <level>:TABCOMP:<*#?=!@>:<commands>
35 1 Per Amundsen
36 166 Per Amundsen
on <level>:WALLOPS:<matchtext>:<commands>
37 1 Per Amundsen
38 166 Per Amundsen
on <level>:ERROR:<matchtext>:<commands>
39 1 Per Amundsen
40 166 Per Amundsen
on <level>:RAWMODE:#:<commands>
41 1 Per Amundsen
42 166 Per Amundsen
on <level>:DEHELP:<#[,#]>:<commands>
43 1 Per Amundsen
44 166 Per Amundsen
on <level>:HELP:<#[,#]>:<commands>
45 1 Per Amundsen
46 166 Per Amundsen
on <level>:DEVOICE:<#[,#]>:<commands>
47 1 Per Amundsen
48 166 Per Amundsen
on <level>:VOICE:<#[,#]>:<commands>
49 1 Per Amundsen
50 166 Per Amundsen
on <level>:DEOP:<#[,#]>:<commands>
51 1 Per Amundsen
52 166 Per Amundsen
on <level>:OP:<#[,#]>:<commands>
53 1 Per Amundsen
54 166 Per Amundsen
on <level>:INPUT:<*#?=!@>:<commands>
55 1 Per Amundsen
56 166 Per Amundsen
on <level>:UNBAN:<#[,#]>:<commands>
57 1 Per Amundsen
58 166 Per Amundsen
on <level>:BAN:<#[,#]>:<commands>
59 149 Per Amundsen
60 166 Per Amundsen
on <level>:CHAT:<matchtext>:<commands>
61 1 Per Amundsen
62 166 Per Amundsen
on <level>:KICK:<#[,#]>:<commands>
63 1 Per Amundsen
64 166 Per Amundsen
on <level>:NOTIFY:<commands>
65 1 Per Amundsen
66 166 Per Amundsen
on <level>:UNNOTIFY:<commands>
67 1 Per Amundsen
68 166 Per Amundsen
on <level>:NICK:<commands>
69 1 Per Amundsen
70 166 Per Amundsen
on <level>:QUIT:<commands>
71 1 Per Amundsen
72 166 Per Amundsen
on <level>:LOAD:<commands>
73 1 Per Amundsen
74 166 Per Amundsen
on <level>:UNLOAD:<commands>'
75 1 Per Amundsen
76 166 Per Amundsen
on <level>:START:<commands>
77 1 Per Amundsen
78 166 Per Amundsen
on <level>:EXIT:<commands>
79 1 Per Amundsen
80 166 Per Amundsen
on <level>:DNS:<commands>
81 1 Per Amundsen
82 166 Per Amundsen
on <level>:CONNECTFAIL:<commands>
83 1 Per Amundsen
84 166 Per Amundsen
on <level>:CONNECT:<commands>
85 1 Per Amundsen
86 166 Per Amundsen
on <level>:DISCONNECT:<commands>
87 1 Per Amundsen
88 166 Per Amundsen
on <level>:TOPIC:<#[,#]>:<commands>
89 1 Per Amundsen
90 166 Per Amundsen
on <level>:USERMODE:<commands>
91 1 Per Amundsen
92 166 Per Amundsen
on <level>:MODE:<#[,#]>:<commands>
93 1 Per Amundsen
94 166 Per Amundsen
on <level>:PART:<#[,#]>:<commands>
95 1 Per Amundsen
96 166 Per Amundsen
on <level>:JOIN:<#[,#]>:<commands>
97 1 Per Amundsen
98 166 Per Amundsen
on <level>:SNOTICE:<matchtext>:<commands>
99 1 Per Amundsen
100 166 Per Amundsen
on <level>:NOTICE:<matchtext>:<*><?><#[,#]>:<commands>
101 1 Per Amundsen
102 166 Per Amundsen
on <level>:ACTION:<matchtext>:<*><?><#[,#]>:<commands>
103 1 Per Amundsen
104 166 Per Amundsen
on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands>
105 1 Per Amundsen
106 166 Per Amundsen
This event is added as a replacement for OnSongChanged
107
on <level>:SONG:<commands>
108
109 1 Per Amundsen
</pre>
110
111 166 Per Amundsen
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.
112 1 Per Amundsen
113 166 Per Amundsen
User access will come later. 
114 1 Per Amundsen
115 169 Per Amundsen
h1. identifiers added so far
116 166 Per Amundsen
117
<pre>
118 1 Per Amundsen
$0
119 169 Per Amundsen
$abs
120
$acos
121 1 Per Amundsen
$active
122 166 Per Amundsen
$activeserver
123
$activewid
124
$adate
125 1 Per Amundsen
$address
126 169 Per Amundsen
$addtok
127
$addtokcs
128 166 Per Amundsen
$adiircdir
129
$adiircexe
130
$adiircini
131
$album
132 169 Per Amundsen
$and
133 1 Per Amundsen
$anick
134 166 Per Amundsen
$appactive
135
$appstate
136
$artist
137 169 Per Amundsen
$asc
138
$asctime
139
$asin
140
$atan
141 166 Per Amundsen
$audio
142
$away
143 1 Per Amundsen
$awaymsg
144
$awaytime
145 169 Per Amundsen
$base
146
$bfind
147
$bindip
148
$bitoff
149
$biton
150 166 Per Amundsen
$bitrate
151 169 Per Amundsen
$bvar
152 166 Per Amundsen
$bwdown
153 1 Per Amundsen
$bwdownb
154
$bwname
155
$bwspeed
156
$bwup
157
$bwupb
158 169 Per Amundsen
$bytes
159
$calc
160 1 Per Amundsen
$cb
161 169 Per Amundsen
$ceil
162 1 Per Amundsen
$chan
163
$chanmodes
164
$channel
165
$chantypes
166 169 Per Amundsen
$chat
167
$chr
168 1 Per Amundsen
$cid
169
$clevel
170 166 Per Amundsen
$cmdline
171 169 Per Amundsen
$color
172
$colour
173
$comchan
174 1 Per Amundsen
$comment
175 169 Per Amundsen
$cos
176
$count
177
$countcs
178 166 Per Amundsen
$cpucache
179
$cpucount
180
$cpuident
181
$cpuload
182
$cpumhz
183 1 Per Amundsen
$cpuname
184 166 Per Amundsen
$cr
185 169 Per Amundsen
$crc
186 1 Per Amundsen
$crlf
187
$ctime
188
$date
189 169 Per Amundsen
$datediff
190
$datematch
191 166 Per Amundsen
$day
192
$daylight
193 169 Per Amundsen
$decode
194
$decrypt
195
$deltok
196
$dialog
197
$did
198
$didreg
199
$didtok
200
$didwm
201 166 Per Amundsen
$disk
202 1 Per Amundsen
$diskfree
203 169 Per Amundsen
$diskmenu
204 1 Per Amundsen
$disktotal
205
$dlevel
206 169 Per Amundsen
$dns
207
$dotnet
208 166 Per Amundsen
$duration
209 169 Per Amundsen
$editbox
210
$encode
211
$encodingmenu
212
$encrypt
213 166 Per Amundsen
$error
214 1 Per Amundsen
$event
215 169 Per Amundsen
$exists
216 1 Per Amundsen
$false
217
$feof
218 166 Per Amundsen
$ferr
219 169 Per Amundsen
$fgetc
220
$file
221
$finddir
222
$findfile
223
$findtok
224
$findtokcs
225
$fline
226
$floop
227
$floor
228
$fopen
229
$frand
230
$fread
231 1 Per Amundsen
$frequency
232
$fulladdress
233 166 Per Amundsen
$fulldate
234 1 Per Amundsen
$fulltitle
235 166 Per Amundsen
$genre
236
$getdir
237 169 Per Amundsen
$getdot
238
$gettok
239 1 Per Amundsen
$gfx
240 166 Per Amundsen
$gfxram
241 1 Per Amundsen
$gmt
242 169 Per Amundsen
$group
243
$height
244
$hfind
245
$hget
246 166 Per Amundsen
$highlight
247
$host
248
$ial
249 169 Per Amundsen
$ialchan
250
$ibl
251 166 Per Amundsen
$ident
252
$idle
253 169 Per Amundsen
$iel
254 166 Per Amundsen
$ignore
255 169 Per Amundsen
$iil
256
$inellipse
257
$ini
258 166 Per Amundsen
$inmidi
259
$inpaste
260 169 Per Amundsen
$inpoly
261
$input
262
$inrect
263
$insert
264 166 Per Amundsen
$insong
265 169 Per Amundsen
$instok
266
$int
267
$invitemenu
268 166 Per Amundsen
$inwave
269
$ip
270 169 Per Amundsen
$isalias
271
$isbit
272
$isdir
273
$isfile
274 166 Per Amundsen
$isid
275 169 Per Amundsen
$islower
276
$istok
277
$istokcs
278
$istype
279
$isupper
280 166 Per Amundsen
$layer
281
$left
282 169 Per Amundsen
$len
283 166 Per Amundsen
$length
284 169 Per Amundsen
$lf
285
$line
286
$lines
287
$log
288 166 Per Amundsen
$logdir
289
$logstamp
290 1 Per Amundsen
$logstampfmt
291 169 Per Amundsen
$longfn
292
$longip
293
$lower
294 166 Per Amundsen
$ltimer
295
$maddress
296 169 Per Amundsen
$mask
297 166 Per Amundsen
$matchkey
298 169 Per Amundsen
$matchtok
299
$matchtokcs
300
$md5
301 166 Per Amundsen
$me
302
$memfree
303
$memfreep
304
$memtotal
305 169 Per Amundsen
$menu
306
$mid
307 166 Per Amundsen
$mircdir
308
$mircexec
309
$mircini
310 169 Per Amundsen
$mkfn
311
$mklogfn
312
$mknickfn
313 166 Per Amundsen
$mnick
314
$mode
315
$modespl
316
$motherboard
317 169 Per Amundsen
$mouse
318
$mp3
319
$msfile
320 166 Per Amundsen
$mversion
321
$myhost
322
$myident
323
$network
324
$newnick
325
$nick
326 169 Per Amundsen
$nofile
327
$nopath
328
$noqt
329
$not
330
$notify
331 166 Per Amundsen
$now
332
$null
333
$numeric
334 169 Per Amundsen
$numtok
335 166 Per Amundsen
$online
336 169 Per Amundsen
$or
337
$ord
338 166 Per Amundsen
$os
339
$osbuild
340
$osedition
341 169 Per Amundsen
$osinstalldate
342 166 Per Amundsen
$osmajor
343
$osminor
344
$osname
345
$osservicepack
346
$osversion
347
$percentl
348
$percentp
349 169 Per Amundsen
$pic
350 166 Per Amundsen
$playcount
351
$player
352
$port
353 169 Per Amundsen
$portfree
354
$pos
355
$poscs
356 166 Per Amundsen
$position
357
$prefix
358
$progress
359 169 Per Amundsen
$prop
360
$puttok
361
$qt
362
$query
363 166 Per Amundsen
$r
364
$r0
365 169 Per Amundsen
$rand
366 166 Per Amundsen
$raw0
367
$rawbytes
368
$rawmsg
369 169 Per Amundsen
$read
370
$readini
371
$realname
372
$regex
373
$regml
374
$regsub
375
$regsubex
376
$remove
377
$removecs
378
$remtok
379
$remtokcs
380
$replace
381
$replacecs
382
$replacex
383
$replacexcs
384
$reptok
385
$reptokcs
386 166 Per Amundsen
$result
387 169 Per Amundsen
$rgb
388
$right
389
$round
390
$scid
391
$scon
392 166 Per Amundsen
$screen
393
$screenb
394
$screenh
395
$screenw
396
$script
397
$scriptdir
398
$scriptline
399 169 Per Amundsen
$sdir
400 166 Per Amundsen
$server
401
$serverip
402 169 Per Amundsen
$sfile
403
$sha1
404
$shortfn
405 166 Per Amundsen
$show
406 169 Per Amundsen
$sin
407 166 Per Amundsen
$site
408
$size
409 169 Per Amundsen
$slapsmenu
410
$sline
411
$snick
412
$sock
413 166 Per Amundsen
$sockbr
414
$song
415 169 Per Amundsen
$sorttok
416
$sorttokcs
417
$sqrt
418 166 Per Amundsen
$status
419 169 Per Amundsen
$str
420
$strip
421
$style
422
$submenu
423
$tan
424 166 Per Amundsen
$target
425
$ticks
426
$time
427 169 Per Amundsen
$timer
428 166 Per Amundsen
$timestamp
429
$timestampfmt
430
$timezone
431 169 Per Amundsen
$tip
432 166 Per Amundsen
$title
433 169 Per Amundsen
$token
434
$toolbar
435 166 Per Amundsen
$totaltracks
436
$track
437
$true
438 169 Per Amundsen
$trust
439 166 Per Amundsen
$ulevel
440
$updays
441
$uphours
442
$upmins
443 169 Per Amundsen
$upper
444
$uptime
445
$user
446 166 Per Amundsen
$usermode
447 169 Per Amundsen
$utfdecode
448
$utfencode
449
$var
450 166 Per Amundsen
$version
451 169 Per Amundsen
$vol
452 166 Per Amundsen
$volume
453
$volumeb
454
$volumep
455
$wid
456 169 Per Amundsen
$width
457 166 Per Amundsen
$wildsite
458 169 Per Amundsen
$wildtok
459
$wildtokcs
460 166 Per Amundsen
$window
461 169 Per Amundsen
$xor
462 166 Per Amundsen
$year
463
</pre>
464 149 Per Amundsen
465 166 Per Amundsen
All operaters are added.
466
467 154 Per Amundsen
h1. Example scripts
468
469
Simple kickcounter script:
470
471
<pre>
472 166 Per Amundsen
alias kick { 
473
	if (!%kickcount) %kickcount = 0
474 154 Per Amundsen
475 166 Per Amundsen
	inc %kickcount
476 154 Per Amundsen
		 
477 166 Per Amundsen
	if (!$3) { 
478
		kick # $$2 Kick number %kickcount
479 154 Per Amundsen
		halt
480
	} 
481
}
482
</pre>
483
484
Kickban example
485
<pre>
486 166 Per Amundsen
alias kb {
487 154 Per Amundsen
	if (!$1) {
488 166 Per Amundsen
		echo /kb - Nick missing
489 154 Per Amundsen
		return
490
	}
491
492 166 Per Amundsen
	var %msg = $iif(#, $2-, $3-)
493
	var %chan = $iif(#, #, $2)
494 154 Per Amundsen
		
495 166 Per Amundsen
	; Set this for default ban reason, or remove for no default reason
496
	; Can be shortened to %msg = $iif(%msg, %msg, GTFO)
497
	if (!%msg) %msg = GTFO
498 154 Per Amundsen
499
	if ($me isop %chan) {
500 166 Per Amundsen
		MODE %chan +b $wildsite
501
		KICK %chan $1 %msg
502 154 Per Amundsen
	} 
503 166 Per Amundsen
	else echo You are not oper on %chan
504 154 Per Amundsen
}
505
</pre>
506
507
Simple calculator script:
508
<pre>
509 166 Per Amundsen
alias calc {
510 154 Per Amundsen
	if (!$1) {
511 166 Per Amundsen
		echo /calc - Parameters missing
512 154 Per Amundsen
		return
513
	}
514
		
515 166 Per Amundsen
	; typing /calc -p <expression> sends output to channel
516 154 Per Amundsen
	if ($1 == -p) {
517 166 Per Amundsen
		msg # Calculating : $2-
518
		msg # Result is : $calc($2-)
519 154 Per Amundsen
	} else {
520 166 Per Amundsen
		echo Calculating : $1-
521
		echo Result is : $calc($1-)
522 154 Per Amundsen
	}
523
}
524
</pre>
525
526
Colored version
527
<pre>
528 166 Per Amundsen
alias calc {
529 154 Per Amundsen
	if (!$1) {
530 166 Per Amundsen
		echo /calc - Parameters missing
531 154 Per Amundsen
		return
532
	}
533 156 Per Amundsen
	
534
	# typing /calc -p <expression> sends output to channel
535 154 Per Amundsen
	if ($1 == -p) {
536 166 Per Amundsen
		msg # $chr(3)4Calculating : $2-
537
		msg # $chr(3)4Result is : $calc($2-)
538 154 Per Amundsen
	} else {
539 166 Per Amundsen
		echo $chr(3)4Calculating : 4$1-
540
		echo $chr(3)4Result is : $calc($1-)
541 154 Per Amundsen
	}
542 166 Per Amundsen
}
543 154 Per Amundsen
</pre>
544
545
CTCP flood detection example
546
547
<pre>
548 166 Per Amundsen
CTCP *:*:*:{
549
	if (!%count) set -u10 %count 1
550
	else inc -u10 %count 1
551 154 Per Amundsen
552 166 Per Amundsen
	if (%count > 4) ignore -tu30 $wildsite
553 154 Per Amundsen
}
554
</pre>
555
556
Mass mode example
557
558
<pre>
559 166 Per Amundsen
alias mass {
560 154 Per Amundsen
	if (!$2) {
561 166 Per Amundsen
		echo /mass - Parameters missing [+/-<mode> <nick> <nick> <nick>]
562 154 Per Amundsen
		return
563
	}
564
565
	%len = 2
566
	
567 166 Per Amundsen
	; equal to while (%len <= $count(%1-, $chr(32)))
568
	while (%len <= $0) {
569
		if ($(%len) ison #) mode # $1 $($ $+ %len)
570
		inc %len
571 154 Per Amundsen
	}
572
}
573
</pre>
574
575
Shows info about servers, channels and users
576
<pre>
577 166 Per Amundsen
on *:JOIN:#: {
578 154 Per Amundsen
	var %s = $server(0), %c = 0, %u = 0, %t = 0, %c2 = 0;
579
	
580
	while (%t < %s) {
581 166 Per Amundsen
		inc %t
582
		setserver $server(%t);
583 154 Per Amundsen
		%c += $chan(0)
584
	
585
		%c2 = 0
586
		while (%c2 < $chan(0)) {
587 166 Per Amundsen
			in %c2
588 154 Per Amundsen
			%u += $user($chan(%c2), 0)
589
		}
590
	}
591
592 166 Per Amundsen
	/echo You are on ( $+ %s $+ ) servers, ( $+ %c $+ ) channels with ( $+ %u $+ ) users
593 154 Per Amundsen
}
594
</pre>
595
596
It is possible to use scripts as functions.
597
These functions are fully nested like the client functions.
598
599
Lets say you make a /mycalc like this.
600
<pre>
601 166 Per Amundsen
alias mycalc {
602
	return $calc($$1 + $$2);
603 154 Per Amundsen
}
604
</pre>
605
606
Then you can call this function with eiter /mycalc <number> <number> the normal way or $mycalc(<number, <number>)
607
Typing /testcalc will show the result.
608
<pre>
609 166 Per Amundsen
alias testcalc {
610
	echo -a $1 + $2 is $mycalc($1, $2);
611
	echo -a 5 + 4 is $mycalc(5, 4);
612 154 Per Amundsen
}
613
</pre>
614
615
Simple convert temperature C to F or F to C
616
/temp C 20 will print 68 F
617
618
<pre>
619 166 Per Amundsen
alias temp {
620
	if ($1 == C) echo $calc(($2 * 9/5) + 32) F
621
	else if ($1 == F) echo $round($calc(($2 - 32) * 5/9), 1) C
622
	else echo Temp missing
623 154 Per Amundsen
}
624
</pre>
625
626 166 Per Amundsen
Announce song changes in a channel or to a user
627 154 Per Amundsen
<pre>
628 166 Per Amundsen
On *:SONG:{ 
629
	nmsg <network> <channel/Nick> $1-
630 154 Per Amundsen
}
631 158 Per Amundsen
</pre>
632
633 166 Per Amundsen
Announce to several channels with:
634 158 Per Amundsen
<pre>
635 166 Per Amundsen
On *:SONG:{ 
636
	nmsg <network> <channel1/Nick>,<channel2/Nick> $1-
637
	nmsg <network2> <channel3/Nick> $1- 
638 158 Per Amundsen
}
639 166 Per Amundsen
</pre>
640 158 Per Amundsen
641 166 Per Amundsen
Automatically find the summary of a imdb url
642
<pre>
643
On *:TEXT:*:#k: {
644
    var %reg = $regex($1-, http://www\.imdb\.com(/title/[a-z0-9]+/))
645
    if (!%reg) { return }
646
    sockclose imdb
647
    unset %data
648
    %imdb = $regml(1) $+ plotsummary
649
    %imdbchan = #
650
    sockopen imdb www.imdb.com 80
651 1 Per Amundsen
}
652
653 166 Per Amundsen
on *:sockopen:imdb: {
654
    sockwrite -n imdb GET %imdb HTTP/1.1
655
    sockwrite -n imdb Host: www.imdb.com
656
    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
657
    sockwrite -n imdb Referer: http://www.imdb.com
658
    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
659
    sockwrite -n imdb Accept-Language: en-us, en;q=0.50
660
    sockwrite -n imdb Connection: Close $+ $crlf $+ $crlf
661 1 Per Amundsen
}
662
663 166 Per Amundsen
on *:sockread:imdb:{
664
    sockread %text
665
    %data = %data $+ %text 
666 1 Per Amundsen
}
667
668 166 Per Amundsen
on *:sockclose:imdb: {
669
    if ($regex(%data, <p class="plotpar">([\s\S]*?)<i>)) {
670
        msg %imdbchan $regml(1)
671
    }
672 1 Per Amundsen
673 166 Per Amundsen
    unset %data
674 1 Per Amundsen
}
675
</pre>
676 170 Per Amundsen
677 171 Per Amundsen
h1. More information
678 172 Per Amundsen
679 170 Per Amundsen
You can find many mIRC scripts at places such as http://www.hawkee.com/mirc/scripts/ and http://mircscripts.com/
680
681 1 Per Amundsen
Not everyone will work, if you find one that dosen't, please open a new issue with a link to the script.
682
683 172 Per Amundsen
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