Project

General

Profile

Scripting » History » Version 161

Per Amundsen, 08/14/2012 12:11 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 153 Per Amundsen
*user set variables:*
213 159 Per Amundsen
All user set variables starts with %
214
215 149 Per Amundsen
var %variable = 4242, %variable2 = 4343; will create local variables that gets deleted when the script is done.
216
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.
217 1 Per Amundsen
218 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.
219
220 157 Per Amundsen
Commands for manipulating variables:
221 1 Per Amundsen
<pre>
222 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
223 1 Per Amundsen
224 149 Per Amundsen
/unset [var] / deletes a variable
225 1 Per Amundsen
226 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
227 1 Per Amundsen
228 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
229 1 Per Amundsen
230 149 Per Amundsen
/vars shows a list of all variables and their values
231
</pre>
232 1 Per Amundsen
233 150 Per Amundsen
*functions:*
234 149 Per Amundsen
Several functions are exsists, they are all recursive and you can use any %variable or $variable as parameters:
235
They are also usable inside if () else if () while () statements.
236
All variable numbers are floats and all functions supports floats for precise calculations.
237 36 Per Amundsen
238
<pre>
239 149 Per Amundsen
$replace(text, text2, text3) / replace all occurrences of text2 in text with text3
240
$upper(text) / return text uppercase
241
$lower(text) return text lowercase
242
$mid(text, startpos, endpos) / return part of text from startpos to endpos
243
$substr(text, startpos, endpos) / return part of text from startpos to endpos
244
$left(text, pos) / return pos characters starting from left of the text
245
$right(text, pos) / return pos characters starting from right of the text
246
$remove(text, text2) / replace all occurrences of text2 from text
247
$len(text) / return length of text
248
$count(text, text2) / counts all occurrences of text2 in text
249
$pos(text, text2) / returns first occurrences position of text2 in text
250
$lastpos(text, text2) / returns last occurrences position of text2 in text
251
$strip(text) / removes all color and font tags
252
$repeat(text, times) / repeats text X times
253
$insert(text, text2, pos) / inserts text2 into pos of text
254
$chr(num) / returns ascii character from the number num
255
$char(num) / returns ascii character from the number num
256 1 Per Amundsen
257 149 Per Amundsen
$calc(formula) / calculate any variation of +-*/
258
$formatdate(date, text) / formats a unix timestamp into date using date variables %d %m %y etc
259
$fdate(date, text) / formats a unix timestamp into date using date variables %d %m %y etc
260
$ctime(datestamp) / converts most variations of a date stamp to unix/ctime
261
$datediff(ctime1, ctime2) / diffs two unix/ctime and fills the $datematch array with values
262
$datematch(num) / returns part of a $datediff, 0 = milliseconds, 1 = seconds, 2 = minutes, 3 = hours, 4 = days
263
$host(nick) / returns the hostmask of nick
264
$ident(nick) / returns the ident of nick
265
$(number) / dynamically gets a $0 $1 $2 variable e.g $(1) is same as $1 (not sure if final function name)
266
$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
267
$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
268
$round(num, decimals) / rounds down a float to X decimals
269
$regex(text, pattern) / does a regular expression test if text matches pattern, then returns the matched part
270
$regmatch(num) / returns the captured group at pos num from a $regex. 0 returns group count
271
$regreplace(text, pattern, text2) / replace any occurence in text of patterh with text2 where pattern is a regular expression
272 3 Per Amundsen
273 149 Per Amundsen
$file(path) / reads file to end and returns the entire output without newlines
274
$fileloop(path) / reads through a file one line at the time, line increases +1 every time the same file is called
275
$floop(path) / reads through a file one line at the time, line increases +1 every time the same file is called
276
$filerandom(path) / returns a random line from a file
277
$frand(path) / returns a random line from a file
278
$fread(name) / reads a line from current pos in file named name
279
$fileread(name) / reads a line from current pos in file named name
280
$freadc(name) / reads a char/byte from current pos in file named name
281
$freadchar(name) / reads a char/byte from current pos in file named name
282
$fsize(file) / returns size off file in bytes
283
$filesize(file) / returns size off file in bytes
284
$fpos(name) / returns current position/byte in file named name
285
$filepos(name) / returns current position/byte in file named name
286
$flines(file) / returns amount of lines in file
287
$filelines(file) / returns amount of lines in file
288
$fileexists(file) / returns if file exists or not
289
$isfile(file) / returns if file exists or not
290 1 Per Amundsen
291 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
292
$user(#chan, num) / if num is 0 returns how many users are on this #chan else returns nick in position num
293
$nick(#chan, num) / if num is 0 returns how many users are on this #chan else returns nick in position num
294
$server(num) / if num is 0 returns how many servers you are connected to else returns server id in position num
295 1 Per Amundsen
296 149 Per Amundsen
$sread(name) / reads available bytes from socket named name (on sockread)
297
$sockread(name) / reads available bytes from socket named name (on sockread)
298
$sbytes(name) / returns amount of available bytes to be read from socket named name
299
$sockbytes(name) / returns amount of available bytes to be read from socket named name
300 1 Per Amundsen
</pre>
301
302 158 Per Amundsen
*operators:*
303
304
All operators can use ! to reverse the logic e.g !ison. 
305
If no operators are added it will test if remaining text is not null if (%test), if ($channel) or if (!$channel) etc.
306
307
<pre>
308
> / Will try and cast left and right variable to int and try "int1 greater than int2"
309
< / Will try and cast left and right variable to int and try "int1 lower than int2"
310
>= / Will try and cast left and right variable to int and try "int1 greater than or equal to int2"
311
<= / Will try and cast left and right variable to int and try "int1 lower than or equal to int2"
312
isbetween / Will try and cast left variable to int and right variable have to be int-int, e.g "40 isbetween 30-50"
313
ison / check if ($nick ison $channel) nick is the channel
314
isop / check if ($nick isop $channel) is operator on the channel
315
ishop / check if ($nick ishop $channel) is half operator on the channel
316
issop / check if ($nick issop $channel) is special operator on the channel
317
isowner / check if ($nick isowner $channel) is channel owner
318
hasvoice / check if ($nick hasvoice $channel) have voice on the channel
319
inchan / check if i am in chan (#channel inchan) (#channel !inchan)
320
isnum / check something is a number (5 isnum) (5 !isnum)
321
ismatch / will check if left contains right value or right contains left value
322
isin / same as ismatch except only checking if left value is in right value, ismatch checks both
323
</pre>
324
325
*tips:*
326
/ is not needed to execute a command in scripts e.g /echo and echo is the same.
327
use null to check for nothing "if ($nick == null)"
328
Comment out a line with # or several lines with /* code */
329 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.
330
All characters that needs to be escaped before used as strings are \ { } ;
331
In some cases you might have to escape ( ) | , # $ %
332
; as a newline "/echo 1; /echo 2" is the same as
333
/echo 1
334
/echo 2
335
336
"halt" will halt the script immediately, telling the client to eat the event and ignoring the rest of the script.
337
"return" will halt immediately, ignoring rest of the script, but not eat anything.
338 158 Per Amundsen
339 155 Per Amundsen
h1. Example scripts
340 154 Per Amundsen
341
Simple kickcounter script:
342
343
<pre>
344
OnBefore OnCommand { 
345
	if ($0 != /kick)  return
346
		
347
	if (%kickcount == null) %kickcount = 0
348
349
	%kickcount++
350
		 
351
	if ($2 == null) { 
352
		/kick $channel $1 Kick number %kickcount
353
		halt
354
	} 
355
}
356
</pre>
357
358
Kickban example
359
<pre>
360
OnCommand /kb {
361
	if (!$1) {
362
		/echo /kb - Nick missing
363
		return
364
	}
365
366
	var %msg = $iif($channel, $2-, $3-)
367
	var %chan = $iif($channel, $channel, $2)
368
		
369
	# Set this for default ban reason, or remove for no default reason
370
	# Can be shortened to %msg = $iif(%msg, %msg, GTFO)
371
	if (%msg == null) %msg = GTFO
372
373
	if ($me isop %chan) {
374
		/raw MODE %chan +b *!$ident($1)@$host($1)
375
		/raw KICK %chan $1 %msg
376
	} 
377
	else /echo You are not oper on %chan
378
}
379
</pre>
380
381
Simple calculator script:
382
<pre>
383
OnCommand /calc {
384
	if (!$1) {
385
		/echo /calc - Parameters missing
386
		return
387
	}
388
		
389
	# typing /calc -p <expression> sends output to channel
390
	if ($1 == -p) {
391
		/msg $channel Calculating : $2-
392
		/msg $channel Result is : $calc($2-)
393
	} else {
394
		/echo Calculating : $1-
395
		/echo Result is : $calc($1-)
396
	}
397
}
398
</pre>
399
400
Colored version
401
<pre>
402
OnCommand /calc {
403
	if (!$1) {
404
		/echo /calc - Parameters missing
405
		return
406
	}
407
	
408
	# typing /calc -p <expression> sends output to channel
409
	if ($1 == -p) {
410
		/msg $channel $chr(3)4Calculating : $2-
411
		/msg $channel $chr(3)4Result is : $calc($2-)
412
	} else {
413
		/echo $chr(3)4Calculating : 4$1-
414
		/echo $chr(3)4Result is : $calc($1-)
415
	}
416
}*/
417
</pre>
418
419
CTCP flood detection example
420
421
<pre>
422
On OnCTCPRequest {
423
	if (%count == null) /set -u 10 %count 1
424
	else /inc -u 10 %count 1
425
426
	if (%count > 4) /ignore  -u 30 -t $nick!$ident@$host
427
}
428
</pre>
429
430
Mass mode example
431
432
<pre>
433
OnCommand /mass {
434
	if (!$2) {
435
		/echo /mass - Parameters missing [+/-<mode> <nick> <nick> <nick>]
436
		return
437
	}
438
439
	%len = 2
440
	
441
	# equal to while (%len <= $count(%0-, $chr(32)))
442
	while (%len <= $!) {
443
		if ($(%len) ison $channel) /mode $channel $1 $(%len)
444
		/inc %len
445
	}
446
}
447
</pre>
448
449
Shows info about servers, channels and users
450
<pre>
451
On JOIN {
452
	var %s = $server(0), %c = 0, %u = 0, %t = 0, %c2 = 0;
453
	
454
	while (%t < %s) {
455
		%t++
456
		/setserver $server(%t);
457
		%c += $chan(0)
458
	
459
		%c2 = 0
460
		while (%c2 < $chan(0)) {
461
			%c2++
462
			%u += $user($chan(%c2), 0)
463
		}
464
	}
465
466
	/echo You are on (%s) servers, (%c) channels with (%u) users
467
}
468
</pre>
469
470 156 Per Amundsen
It is possible to use scripts as functions.
471
These functions are fully nested like the client functions.
472 154 Per Amundsen
473
Lets say you make a /mycalc like this.
474
<pre>
475
OnCommand /mycalc {
476
	return $calc($0+$1);
477
}
478
</pre>
479
480
Then you can call this function with eiter /mycalc <number> <number> the normal way or $mycalc(<number, <number>)
481
Typing /testcalc will show the result.
482
<pre>
483
OnCommand /testcalc {
484
	/echo $0 + $1 is $mycalc($0, $1);
485
	/echo 5 + 4 is $mycalc(5, 4);
486
}
487
</pre>
488
489
Simple convert temperature C to F or F to C
490
/temp C 20 will print 68 F
491
492
<pre>
493
OnCommand /temp {
494
	if ($1 == C) /echo $calc(($2 * 9/5) + 32) F
495
	else if ($1 == F) /echo $round($calc(($2 - 32) * 5/9), 1) C
496
	else /echo Temp missing
497
}
498
</pre>
499
500
Test if input contains a link
501
<pre>
502
OnCommand /testlink {
503
	if (!$1) {
504
		/echo Link missing
505
		return
506
	}
507
508
	/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)
509
}
510
511
</pre>
512
513
Retrives plot summary from captured imbd links
514
<pre>
515
On PRIVMSG {
516
	var %reg = $regex($0-, http://www\\.imdb\\.com(/title/[a-z0-9]+/))
517
	if (!%reg) { return }
518
		
519
	/sockclose imdb
520
	%text = null
521
	%imdb = $regmatch(1)plotsummary
522
	%imdbchan = $channel
523
	/sockopen imdb www.imdb.com 80
524
}
525
526
On SockOpen {
527
	if ($1 != imdb) { return }
528
529
	/sockwrite -n imdb GET %imdb HTTP/1.1
530
	/sockwrite -n imdb Host: www.imdb.com
531
	/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
532
	/sockwrite -n imdb Referer: http://www.imdb.com
533
	/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
534
	/sockwrite -n imdb Accept-Language: en-us, en\;q=0.50
535
	/sockwrite -n imdb Connection: Close$crlf
536
}
537
538
On SockRead {
539
	if ($1 != imdb) { return }
540
		
541
	%text += $sockread(imdb)
542
}
543
544
On SockClose {
545
	if ($1 != imdb) { return }
546
	
547
	if ($regex(%text, <p class="plotpar">([\\s\\S]*?)<i>)) {
548
		/msg %imdbchan $regmatch(1)
549
	}
550
551
	%text = null
552
}
553
</pre>
554
555
An example showing the difference between dates
556
<pre>
557
OnCommand /test {
558
	$datediff($ctime(1/1 2042), $now)
559
	
560
	var %text = Difference is
561
	%text += $chr(32)$datematch(4) $iif($datematch(4) == 1, day, days)
562
	%text += $chr(32)$datematch(3) $iif($datematch(3) == 1, hour, hours) 
563
	%text += $chr(32)$datematch(2) $iif($datematch(3) == 1, minut, minutes) 
564
    
565
	/echo %text
566
}
567
</pre>
568 158 Per Amundsen
569
Announce song changes in a channel or to a user
570
<pre>
571
On OnSongChanged { 
572
	/nmsg <network> <channel/Nick> $0-
573
}
574
</pre>
575
576
Announce to several channels with:
577
<pre>
578
On OnSongChanged { 
579
	/nmsg <network> <channel1/Nick>,<channel2/Nick> $0-
580
	/nmsg <network2> <channel3/Nick> $0- 
581
}
582 154 Per Amundsen
</pre>