Project

General

Profile

Scripting » History » Version 162

Per Amundsen, 08/14/2012 12:13 PM

1 149 Per Amundsen
h1. Notice: this is info for 1.8.10 and higher.
2 39 Per Amundsen
3 1 Per Amundsen
h1. Scripting
4
5 148 Per Amundsen
*[[Scripting BETA]] Click here to see scripting in the latest beta versions.*
6 1 Per Amundsen
7 149 Per Amundsen
You can write full scripts in Commands -> Edit Scripts or you can create one liners in Commands -> Edit Commands
8 38 Per Amundsen
9 149 Per Amundsen
h1. Custom Commands:
10 1 Per Amundsen
11 149 Per Amundsen
Custom Commands are created in Commands -> Edit Commands
12 1 Per Amundsen
13 149 Per Amundsen
Custom commands consists of differents ways to execute a script either by making your own command, or use a hotkey, you can also enter a full script as a one liner (for legacy reasons)
14 1 Per Amundsen
15 150 Per Amundsen
*Alias*
16 149 Per Amundsen
<pre>
17
/hello /msg $channel hello everybody
18
</pre>
19 1 Per Amundsen
20 149 Per Amundsen
This creates a alias named "/hello", everytime you type "/hello" the script "/msg $channel hello everybody" will be executed, you can use any script features here.
21 1 Per Amundsen
22 150 Per Amundsen
*Hot keys*
23 149 Per Amundsen
<pre>
24
Ctrl&r /msg $channel hello everybody i pressed 'ctrl' and 'r'
25
</pre>
26 1 Per Amundsen
27 149 Per Amundsen
Every time you press ctrl + r, the script "/msg $channel hello everybody i pressed 'ctrl' and 'r'" will be executed, you can use any script features her.
28 1 Per Amundsen
29 149 Per Amundsen
You can comment out a command by putting a # in front of it.
30 1 Per Amundsen
31 149 Per Amundsen
It is also possible to use a full script, but it has to be on one line, and the script editor is preferred.
32 1 Per Amundsen
33 149 Per Amundsen
h1. Scripts:
34 1 Per Amundsen
35 150 Per Amundsen
*Events:*
36 149 Per Amundsen
There are different ways to listen to the irc client/server events for legacy reasons.
37 158 Per Amundsen
On/OnEvent will be executed after the event
38
OnBefore/OnBeforeEvent will be executed before the event
39
40 149 Per Amundsen
<pre>
41
OnEvent if ($event == PRIVMSG) { /EXECUTE }
42
OnBeforeEvent if ($event == PRIVMSG) { /EXECUTE }
43 1 Per Amundsen
44 149 Per Amundsen
On PRIVMSG { /EXECUTE }
45
OnBefore PRIVMSG { /EXECUTE }
46 1 Per Amundsen
47 149 Per Amundsen
OnBefore OnCommand { /EXECUTE }
48
OnCommand /mode { /EXECUTE }
49
</pre>
50 1 Per Amundsen
51 150 Per Amundsen
*Available events:*
52 149 Per Amundsen
<pre>
53 161 Per Amundsen
SockOpen / Called when a script opens a socket
54
SockRead / Called when a socket have data to read
55
SockOpen / Called when a script socket is closed
56 160 Per Amundsen
57 149 Per Amundsen
OnLoad / Called when the script is loaded
58
OnUnload / Called when the script is unloaded
59
OnReload / Called when the script is reloaded
60
OnConnecting / Called when a server is connecting
61
OnLookingUp / Called when a server is looking up the hostname
62
OnConnected / Called when a server is connected
63
OnDisconnect / Called when a server gets disconnected
64
OnCommand / Called whenever a user types a /slash command in the client ($0- will hold the full command, $0 will be the first word, $1 the second and so on)
65 1 Per Amundsen
66 149 Per Amundsen
OnCTCPRequest / Called when a user recives a CTCP request
67
OnCTCPReply / Called when a user recives a CTCP reply
68
OnDCCRequest / Called when a user recived a DCC request
69 1 Per Amundsen
70 149 Per Amundsen
OnNickChanged / Called when a user's nick changes, will only trigger on the user unlike NICK who triggers for everyone
71
OnSongChanged / Called when a song is changed in the selected media player
72 1 Per Amundsen
73 149 Per Amundsen
OnDeVoice / Called when a user gets devoiced
74
OnVoice / Called when a user gets voiced
75
OnDeHop / Called when a user gets dehalfoppeed
76
OnHop / Called when a user gets halfopped
77
OnOp / Called when a user gets opped
78
OnDeOp / Called when a user gets deopped
79
OnDeOwner/ Called when a user gets owner deopped
80
OnOwner/ Called when a user gets owner opped
81
OnDeSop / Called when a user gets special deopped
82
OnSop / Called when a user gets special opped
83 1 Per Amundsen
84 149 Per Amundsen
MODE / Called whenever a channel or user mode is changed
85
JOIN / Called whenever a user joins a channel
86
PART / Called when a user parts a channel 
87
NICK / Called when a user changes their nick
88
TOPIC / Called when a topic is set/changed
89
KICK / Called when any user gets kicked
90
NOTICE / Called when any notice is recived
91
QUIT / Called when a user quits irc
92
PRIVMSG / Called when any message is recived
93
WHOIS / Called when any whois reply is recived
94
LIST / Called when a user gets a /list
95
KILL / Called when a user gets killed
96
ACTION / Called when a user recives a ACTION (/me) message
97 1 Per Amundsen
98 149 Per Amundsen
<irc numeric> / Called when a raw irc line with <irc numeric> is recived
99
<irc textual> / Called when a raw irc line with <irc textual> is recived
100
</pre>
101 1 Per Amundsen
102 150 Per Amundsen
*if/else if/else blocks:*
103 1 Per Amundsen
104 149 Per Amundsen
You can use any combination of if, else if, else and while
105
<pre>
106
OnEvent if ($event == PRIVMSG) { 
107
	if (%test == null) { 
108
		/echo Hello world
109
		if (%test == null) { 
110
			/echo Hello world
111
		}
112
		else /echo Hello World
113
	} else if (%test == null) { 
114
		/echo Hello world
115
	} else (%test == null) { 
116
		/echo Hello world 
117
	} 
118 1 Per Amundsen
119 149 Per Amundsen
	if (%test == null) { 
120
		/echo Hello world
121
		while (%test == null) {
122
			/echo Hello world
123
		}
124
	}
125 1 Per Amundsen
126 149 Per Amundsen
	if(%test == null)/echo Hello World
127
	else if(%test == null)/echo Hello World
128
	else/echo Hello world
129
	
130
	if(%test == null){/echo Hello World
131
	}else if(%test == null){/echo Hello World
132
	}else{/echo Hello World
133
	}
134 1 Per Amundsen
135 149 Per Amundsen
	if(%test == null){/echo Hello World}else if(%test == null){/echo Hello World}else{/echo Hello World}
136
}
137
</pre>
138 1 Per Amundsen
139 150 Per Amundsen
*while blocks:*
140 151 Per Amundsen
<pre>
141 149 Per Amundsen
On JOIN {
142
	var %t = 0
143
	/echo There are ($user($chan, 0)) users in ($chan)
144
	
145
	while (%t < $user($chan, 0)) {
146
		%t++
147
		var %nick = $user($chan, %t)
148
		/echo User (%t) is (%nick) and is $iif(%nick isop $chan, opped, not opped)
149
	}
150
}
151
</pre>
152 1 Per Amundsen
153 150 Per Amundsen
*goto/label:*
154 1 Per Amundsen
155
<pre>
156 149 Per Amundsen
OnCommand /goto {
157
	var %loop = 0 
158
	if ($1 == 1) {
159
		goto 1
160
	} else if ($1 == 2) {
161
		goto 2
162
	} else if ($1 == loop) {
163
		:3
164
		/echo you typed loop
165
		%loop++
166
		if (%loop < 5) {
167
			goto 3
168
		}
169
		return
170
	} else {
171
		goto 4
172
	}
173 1 Per Amundsen
174 149 Per Amundsen
	:1
175
	/echo You typed 1
176
	return
177
	:2
178
	/echo You typed 2
179
	return
180
	:4
181
	/echo The end
182
	return
183
}
184
</pre>
185 1 Per Amundsen
186 150 Per Amundsen
*client variables:*
187 159 Per Amundsen
All client variables starts with $
188
189 152 Per Amundsen
<pre>
190 1 Per Amundsen
$event / current event, e.g PRIVMSG 001 MODE and so forth
191
$channel / the channel the event occurred on, if any
192
$msg / the message to the channel/user or the message in a raw irc line e.g whois [kr0n] is a registered nick
193
$nick / the nick the event was sent from, can be a irc.server.com, a nick or null
194
$me / my current nick
195
$network / the network the event occured on e.g Quakenet
196
$ident / the from user ident if any
197
$host / the from user hostname if any
198
$myident / my ident
199
$myhost / my host
200
$server / host from the server e.g irc.server.com
201 149 Per Amundsen
$now / returns unixtime/ctime from current time.
202
$active / returns the current window Status/#channel/Nick.
203
$activeserver / returns an id for current server
204
$status / returns current server status
205
$crlf / returns newline \r\n
206
$0-$9 / will return parts of the $msg, $<number>- will combine parts of the $msg from 0 to <number>. $0- will return everything
207
$! / returns how many $0 $1 etc variables are filled (not sure if final name of it)
208
$raw0-$raw9 / will return parts of the raw message, $raw<number>- will combine parts of the raw message from 0 to <number>. $raw0- will return everything
209 1 Per Amundsen
$r! / returns how many $raw0 $raw1 etc variables are filled (not sure if final name of it)
210 159 Per Amundsen
$+ / use to combine variables output e.g "$now $+ $server"
211 152 Per Amundsen
</pre>
212 162 Per Amundsen
213
All sysinfo/mediaplayer variables are available as well.
214
215 153 Per Amundsen
*user set variables:*
216 159 Per Amundsen
All user set variables starts with %
217
218 149 Per Amundsen
var %variable = 4242, %variable2 = 4343; will create local variables that gets deleted when the script is done.
219
using += instead of = will append to the variable, if both variable and new value is numbers it will combine them to a new number %variable += 4242.
220 1 Per Amundsen
221 149 Per Amundsen
If a variable is created without var, the variable will be available to all scripts, saved to a file and restored when AdiIRC is started.
222
223 157 Per Amundsen
Commands for manipulating variables:
224 1 Per Amundsen
<pre>
225 149 Per Amundsen
/set {-u seconds/-d] [%var] [value] / create or update a variable with value -u seconds, will delete the variable after X seconds, -d will decrease its value by 1 every second, then remove it
226 1 Per Amundsen
227 149 Per Amundsen
/unset [var] / deletes a variable
228 1 Per Amundsen
229 149 Per Amundsen
/inc {-u seconds/-d] [%var] [value] / increases a variable with value (only if value and var is ints) -u seconds, will delete the variable after X seconds, -d will decrease its value by 1 every second, then remove it
230 1 Per Amundsen
231 149 Per Amundsen
/dec {-u seconds/-d] [%var] [value] / decreases a variable with value (only if value and var is ints) -u seconds, will delete the variable after X seconds, -d will decrease its value by 1 every second, then remove it
232 1 Per Amundsen
233 149 Per Amundsen
/vars shows a list of all variables and their values
234
</pre>
235 1 Per Amundsen
236 150 Per Amundsen
*functions:*
237 149 Per Amundsen
Several functions are exsists, they are all recursive and you can use any %variable or $variable as parameters:
238
They are also usable inside if () else if () while () statements.
239
All variable numbers are floats and all functions supports floats for precise calculations.
240 36 Per Amundsen
241
<pre>
242 149 Per Amundsen
$replace(text, text2, text3) / replace all occurrences of text2 in text with text3
243
$upper(text) / return text uppercase
244
$lower(text) return text lowercase
245
$mid(text, startpos, endpos) / return part of text from startpos to endpos
246
$substr(text, startpos, endpos) / return part of text from startpos to endpos
247
$left(text, pos) / return pos characters starting from left of the text
248
$right(text, pos) / return pos characters starting from right of the text
249
$remove(text, text2) / replace all occurrences of text2 from text
250
$len(text) / return length of text
251
$count(text, text2) / counts all occurrences of text2 in text
252
$pos(text, text2) / returns first occurrences position of text2 in text
253
$lastpos(text, text2) / returns last occurrences position of text2 in text
254
$strip(text) / removes all color and font tags
255
$repeat(text, times) / repeats text X times
256
$insert(text, text2, pos) / inserts text2 into pos of text
257
$chr(num) / returns ascii character from the number num
258
$char(num) / returns ascii character from the number num
259 1 Per Amundsen
260 149 Per Amundsen
$calc(formula) / calculate any variation of +-*/
261
$formatdate(date, text) / formats a unix timestamp into date using date variables %d %m %y etc
262
$fdate(date, text) / formats a unix timestamp into date using date variables %d %m %y etc
263
$ctime(datestamp) / converts most variations of a date stamp to unix/ctime
264
$datediff(ctime1, ctime2) / diffs two unix/ctime and fills the $datematch array with values
265
$datematch(num) / returns part of a $datediff, 0 = milliseconds, 1 = seconds, 2 = minutes, 3 = hours, 4 = days
266
$host(nick) / returns the hostmask of nick
267
$ident(nick) / returns the ident of nick
268
$(number) / dynamically gets a $0 $1 $2 variable e.g $(1) is same as $1 (not sure if final function name)
269
$cond(cond, execute1, execute2) / checks if cond is true then executes execute1, else executes execute2, will return string if not at the begining of the line
270
$iif(cond, execute1, execute2) / checks if cond is true then executes execute1, else executes execute2, will return string if not at the begining of the line
271
$round(num, decimals) / rounds down a float to X decimals
272
$regex(text, pattern) / does a regular expression test if text matches pattern, then returns the matched part
273
$regmatch(num) / returns the captured group at pos num from a $regex. 0 returns group count
274
$regreplace(text, pattern, text2) / replace any occurence in text of patterh with text2 where pattern is a regular expression
275 3 Per Amundsen
276 149 Per Amundsen
$file(path) / reads file to end and returns the entire output without newlines
277
$fileloop(path) / reads through a file one line at the time, line increases +1 every time the same file is called
278
$floop(path) / reads through a file one line at the time, line increases +1 every time the same file is called
279
$filerandom(path) / returns a random line from a file
280
$frand(path) / returns a random line from a file
281
$fread(name) / reads a line from current pos in file named name
282
$fileread(name) / reads a line from current pos in file named name
283
$freadc(name) / reads a char/byte from current pos in file named name
284
$freadchar(name) / reads a char/byte from current pos in file named name
285
$fsize(file) / returns size off file in bytes
286
$filesize(file) / returns size off file in bytes
287
$fpos(name) / returns current position/byte in file named name
288
$filepos(name) / returns current position/byte in file named name
289
$flines(file) / returns amount of lines in file
290
$filelines(file) / returns amount of lines in file
291
$fileexists(file) / returns if file exists or not
292
$isfile(file) / returns if file exists or not
293 1 Per Amundsen
294 149 Per Amundsen
$chan(num) / if num is 0 returns how many channels you are joined on this server else returns channel name in position num
295
$user(#chan, num) / if num is 0 returns how many users are on this #chan else returns nick in position num
296
$nick(#chan, num) / if num is 0 returns how many users are on this #chan else returns nick in position num
297
$server(num) / if num is 0 returns how many servers you are connected to else returns server id in position num
298 1 Per Amundsen
299 149 Per Amundsen
$sread(name) / reads available bytes from socket named name (on sockread)
300
$sockread(name) / reads available bytes from socket named name (on sockread)
301
$sbytes(name) / returns amount of available bytes to be read from socket named name
302
$sockbytes(name) / returns amount of available bytes to be read from socket named name
303 1 Per Amundsen
</pre>
304
305 158 Per Amundsen
*operators:*
306
307
All operators can use ! to reverse the logic e.g !ison. 
308
If no operators are added it will test if remaining text is not null if (%test), if ($channel) or if (!$channel) etc.
309
310
<pre>
311
> / Will try and cast left and right variable to int and try "int1 greater than int2"
312
< / Will try and cast left and right variable to int and try "int1 lower than int2"
313
>= / Will try and cast left and right variable to int and try "int1 greater than or equal to int2"
314
<= / Will try and cast left and right variable to int and try "int1 lower than or equal to int2"
315
isbetween / Will try and cast left variable to int and right variable have to be int-int, e.g "40 isbetween 30-50"
316
ison / check if ($nick ison $channel) nick is the channel
317
isop / check if ($nick isop $channel) is operator on the channel
318
ishop / check if ($nick ishop $channel) is half operator on the channel
319
issop / check if ($nick issop $channel) is special operator on the channel
320
isowner / check if ($nick isowner $channel) is channel owner
321
hasvoice / check if ($nick hasvoice $channel) have voice on the channel
322
inchan / check if i am in chan (#channel inchan) (#channel !inchan)
323
isnum / check something is a number (5 isnum) (5 !isnum)
324
ismatch / will check if left contains right value or right contains left value
325
isin / same as ismatch except only checking if left value is in right value, ismatch checks both
326
</pre>
327
328
*tips:*
329
/ is not needed to execute a command in scripts e.g /echo and echo is the same.
330
use null to check for nothing "if ($nick == null)"
331
Comment out a line with # or several lines with /* code */
332 159 Per Amundsen
All paths needs to be escaped e.g c:\\users\\kr0n\\file.txt if only a filename is entered, the script directory will be used.
333
All characters that needs to be escaped before used as strings are \ { } ;
334
In some cases you might have to escape ( ) | , # $ %
335
; as a newline "/echo 1; /echo 2" is the same as
336
/echo 1
337
/echo 2
338
339
"halt" will halt the script immediately, telling the client to eat the event and ignoring the rest of the script.
340
"return" will halt immediately, ignoring rest of the script, but not eat anything.
341 158 Per Amundsen
342 155 Per Amundsen
h1. Example scripts
343 154 Per Amundsen
344
Simple kickcounter script:
345
346
<pre>
347
OnBefore OnCommand { 
348
	if ($0 != /kick)  return
349
		
350
	if (%kickcount == null) %kickcount = 0
351
352
	%kickcount++
353
		 
354
	if ($2 == null) { 
355
		/kick $channel $1 Kick number %kickcount
356
		halt
357
	} 
358
}
359
</pre>
360
361
Kickban example
362
<pre>
363
OnCommand /kb {
364
	if (!$1) {
365
		/echo /kb - Nick missing
366
		return
367
	}
368
369
	var %msg = $iif($channel, $2-, $3-)
370
	var %chan = $iif($channel, $channel, $2)
371
		
372
	# Set this for default ban reason, or remove for no default reason
373
	# Can be shortened to %msg = $iif(%msg, %msg, GTFO)
374
	if (%msg == null) %msg = GTFO
375
376
	if ($me isop %chan) {
377
		/raw MODE %chan +b *!$ident($1)@$host($1)
378
		/raw KICK %chan $1 %msg
379
	} 
380
	else /echo You are not oper on %chan
381
}
382
</pre>
383
384
Simple calculator script:
385
<pre>
386
OnCommand /calc {
387
	if (!$1) {
388
		/echo /calc - Parameters missing
389
		return
390
	}
391
		
392
	# typing /calc -p <expression> sends output to channel
393
	if ($1 == -p) {
394
		/msg $channel Calculating : $2-
395
		/msg $channel Result is : $calc($2-)
396
	} else {
397
		/echo Calculating : $1-
398
		/echo Result is : $calc($1-)
399
	}
400
}
401
</pre>
402
403
Colored version
404
<pre>
405
OnCommand /calc {
406
	if (!$1) {
407
		/echo /calc - Parameters missing
408
		return
409
	}
410
	
411
	# typing /calc -p <expression> sends output to channel
412
	if ($1 == -p) {
413
		/msg $channel $chr(3)4Calculating : $2-
414
		/msg $channel $chr(3)4Result is : $calc($2-)
415
	} else {
416
		/echo $chr(3)4Calculating : 4$1-
417
		/echo $chr(3)4Result is : $calc($1-)
418
	}
419
}*/
420
</pre>
421
422
CTCP flood detection example
423
424
<pre>
425
On OnCTCPRequest {
426
	if (%count == null) /set -u 10 %count 1
427
	else /inc -u 10 %count 1
428
429
	if (%count > 4) /ignore  -u 30 -t $nick!$ident@$host
430
}
431
</pre>
432
433
Mass mode example
434
435
<pre>
436
OnCommand /mass {
437
	if (!$2) {
438
		/echo /mass - Parameters missing [+/-<mode> <nick> <nick> <nick>]
439
		return
440
	}
441
442
	%len = 2
443
	
444
	# equal to while (%len <= $count(%0-, $chr(32)))
445
	while (%len <= $!) {
446
		if ($(%len) ison $channel) /mode $channel $1 $(%len)
447
		/inc %len
448
	}
449
}
450
</pre>
451
452
Shows info about servers, channels and users
453
<pre>
454
On JOIN {
455
	var %s = $server(0), %c = 0, %u = 0, %t = 0, %c2 = 0;
456
	
457
	while (%t < %s) {
458
		%t++
459
		/setserver $server(%t);
460
		%c += $chan(0)
461
	
462
		%c2 = 0
463
		while (%c2 < $chan(0)) {
464
			%c2++
465
			%u += $user($chan(%c2), 0)
466
		}
467
	}
468
469
	/echo You are on (%s) servers, (%c) channels with (%u) users
470
}
471
</pre>
472
473 156 Per Amundsen
It is possible to use scripts as functions.
474
These functions are fully nested like the client functions.
475 154 Per Amundsen
476
Lets say you make a /mycalc like this.
477
<pre>
478
OnCommand /mycalc {
479
	return $calc($0+$1);
480
}
481
</pre>
482
483
Then you can call this function with eiter /mycalc <number> <number> the normal way or $mycalc(<number, <number>)
484
Typing /testcalc will show the result.
485
<pre>
486
OnCommand /testcalc {
487
	/echo $0 + $1 is $mycalc($0, $1);
488
	/echo 5 + 4 is $mycalc(5, 4);
489
}
490
</pre>
491
492
Simple convert temperature C to F or F to C
493
/temp C 20 will print 68 F
494
495
<pre>
496
OnCommand /temp {
497
	if ($1 == C) /echo $calc(($2 * 9/5) + 32) F
498
	else if ($1 == F) /echo $round($calc(($2 - 32) * 5/9), 1) C
499
	else /echo Temp missing
500
}
501
</pre>
502
503
Test if input contains a link
504
<pre>
505
OnCommand /testlink {
506
	if (!$1) {
507
		/echo Link missing
508
		return
509
	}
510
511
	/echo $iif($regex($1, (?i)\\b((?:[a-z][\\w-]+:(?:/\{1\,3\}|[a-z0-9%])|www\\d\{0\,3\}[.]|[a-z0-9.\\-]+[.][a-z]\{2\,4\}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]\\\{\\\}\\\;:'".\,<>?«»“”‘’]))), yes, no)
512
}
513
514
</pre>
515
516
Retrives plot summary from captured imbd links
517
<pre>
518
On PRIVMSG {
519
	var %reg = $regex($0-, http://www\\.imdb\\.com(/title/[a-z0-9]+/))
520
	if (!%reg) { return }
521
		
522
	/sockclose imdb
523
	%text = null
524
	%imdb = $regmatch(1)plotsummary
525
	%imdbchan = $channel
526
	/sockopen imdb www.imdb.com 80
527
}
528
529
On SockOpen {
530
	if ($1 != imdb) { return }
531
532
	/sockwrite -n imdb GET %imdb HTTP/1.1
533
	/sockwrite -n imdb Host: www.imdb.com
534
	/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
535
	/sockwrite -n imdb Referer: http://www.imdb.com
536
	/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
537
	/sockwrite -n imdb Accept-Language: en-us, en\;q=0.50
538
	/sockwrite -n imdb Connection: Close$crlf
539
}
540
541
On SockRead {
542
	if ($1 != imdb) { return }
543
		
544
	%text += $sockread(imdb)
545
}
546
547
On SockClose {
548
	if ($1 != imdb) { return }
549
	
550
	if ($regex(%text, <p class="plotpar">([\\s\\S]*?)<i>)) {
551
		/msg %imdbchan $regmatch(1)
552
	}
553
554
	%text = null
555
}
556
</pre>
557
558
An example showing the difference between dates
559
<pre>
560
OnCommand /test {
561
	$datediff($ctime(1/1 2042), $now)
562
	
563
	var %text = Difference is
564
	%text += $chr(32)$datematch(4) $iif($datematch(4) == 1, day, days)
565
	%text += $chr(32)$datematch(3) $iif($datematch(3) == 1, hour, hours) 
566
	%text += $chr(32)$datematch(2) $iif($datematch(3) == 1, minut, minutes) 
567
    
568
	/echo %text
569
}
570
</pre>
571 158 Per Amundsen
572
Announce song changes in a channel or to a user
573
<pre>
574
On OnSongChanged { 
575
	/nmsg <network> <channel/Nick> $0-
576
}
577
</pre>
578
579
Announce to several channels with:
580
<pre>
581
On OnSongChanged { 
582
	/nmsg <network> <channel1/Nick>,<channel2/Nick> $0-
583
	/nmsg <network2> <channel3/Nick> $0- 
584
}
585 154 Per Amundsen
</pre>