Project

General

Profile

Scripting » History » Version 159

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