Project

General

Profile

Scripting » History » Version 163

Per Amundsen, 08/14/2012 12:15 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 163 Per Amundsen
== / Will check if left and right string or int is the same
312 158 Per Amundsen
> / Will try and cast left and right variable to int and try "int1 greater than int2"
313
< / Will try and cast left and right variable to int and try "int1 lower than int2"
314
>= / Will try and cast left and right variable to int and try "int1 greater than or equal to int2"
315
<= / Will try and cast left and right variable to int and try "int1 lower than or equal to int2"
316
isbetween / Will try and cast left variable to int and right variable have to be int-int, e.g "40 isbetween 30-50"
317
ison / check if ($nick ison $channel) nick is the channel
318
isop / check if ($nick isop $channel) is operator on the channel
319
ishop / check if ($nick ishop $channel) is half operator on the channel
320
issop / check if ($nick issop $channel) is special operator on the channel
321
isowner / check if ($nick isowner $channel) is channel owner
322
hasvoice / check if ($nick hasvoice $channel) have voice on the channel
323
inchan / check if i am in chan (#channel inchan) (#channel !inchan)
324
isnum / check something is a number (5 isnum) (5 !isnum)
325
ismatch / will check if left contains right value or right contains left value
326
isin / same as ismatch except only checking if left value is in right value, ismatch checks both
327
</pre>
328
329
*tips:*
330
/ is not needed to execute a command in scripts e.g /echo and echo is the same.
331
use null to check for nothing "if ($nick == null)"
332
Comment out a line with # or several lines with /* code */
333 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.
334
All characters that needs to be escaped before used as strings are \ { } ;
335
In some cases you might have to escape ( ) | , # $ %
336
; as a newline "/echo 1; /echo 2" is the same as
337
/echo 1
338
/echo 2
339
340
"halt" will halt the script immediately, telling the client to eat the event and ignoring the rest of the script.
341
"return" will halt immediately, ignoring rest of the script, but not eat anything.
342 158 Per Amundsen
343 155 Per Amundsen
h1. Example scripts
344 154 Per Amundsen
345
Simple kickcounter script:
346
347
<pre>
348
OnBefore OnCommand { 
349
	if ($0 != /kick)  return
350
		
351
	if (%kickcount == null) %kickcount = 0
352
353
	%kickcount++
354
		 
355
	if ($2 == null) { 
356
		/kick $channel $1 Kick number %kickcount
357
		halt
358
	} 
359
}
360
</pre>
361
362
Kickban example
363
<pre>
364
OnCommand /kb {
365
	if (!$1) {
366
		/echo /kb - Nick missing
367
		return
368
	}
369
370
	var %msg = $iif($channel, $2-, $3-)
371
	var %chan = $iif($channel, $channel, $2)
372
		
373
	# Set this for default ban reason, or remove for no default reason
374
	# Can be shortened to %msg = $iif(%msg, %msg, GTFO)
375
	if (%msg == null) %msg = GTFO
376
377
	if ($me isop %chan) {
378
		/raw MODE %chan +b *!$ident($1)@$host($1)
379
		/raw KICK %chan $1 %msg
380
	} 
381
	else /echo You are not oper on %chan
382
}
383
</pre>
384
385
Simple calculator script:
386
<pre>
387
OnCommand /calc {
388
	if (!$1) {
389
		/echo /calc - Parameters missing
390
		return
391
	}
392
		
393
	# typing /calc -p <expression> sends output to channel
394
	if ($1 == -p) {
395
		/msg $channel Calculating : $2-
396
		/msg $channel Result is : $calc($2-)
397
	} else {
398
		/echo Calculating : $1-
399
		/echo Result is : $calc($1-)
400
	}
401
}
402
</pre>
403
404
Colored version
405
<pre>
406
OnCommand /calc {
407
	if (!$1) {
408
		/echo /calc - Parameters missing
409
		return
410
	}
411
	
412
	# typing /calc -p <expression> sends output to channel
413
	if ($1 == -p) {
414
		/msg $channel $chr(3)4Calculating : $2-
415
		/msg $channel $chr(3)4Result is : $calc($2-)
416
	} else {
417
		/echo $chr(3)4Calculating : 4$1-
418
		/echo $chr(3)4Result is : $calc($1-)
419
	}
420
}*/
421
</pre>
422
423
CTCP flood detection example
424
425
<pre>
426
On OnCTCPRequest {
427
	if (%count == null) /set -u 10 %count 1
428
	else /inc -u 10 %count 1
429
430
	if (%count > 4) /ignore  -u 30 -t $nick!$ident@$host
431
}
432
</pre>
433
434
Mass mode example
435
436
<pre>
437
OnCommand /mass {
438
	if (!$2) {
439
		/echo /mass - Parameters missing [+/-<mode> <nick> <nick> <nick>]
440
		return
441
	}
442
443
	%len = 2
444
	
445
	# equal to while (%len <= $count(%0-, $chr(32)))
446
	while (%len <= $!) {
447
		if ($(%len) ison $channel) /mode $channel $1 $(%len)
448
		/inc %len
449
	}
450
}
451
</pre>
452
453
Shows info about servers, channels and users
454
<pre>
455
On JOIN {
456
	var %s = $server(0), %c = 0, %u = 0, %t = 0, %c2 = 0;
457
	
458
	while (%t < %s) {
459
		%t++
460
		/setserver $server(%t);
461
		%c += $chan(0)
462
	
463
		%c2 = 0
464
		while (%c2 < $chan(0)) {
465
			%c2++
466
			%u += $user($chan(%c2), 0)
467
		}
468
	}
469
470
	/echo You are on (%s) servers, (%c) channels with (%u) users
471
}
472
</pre>
473
474 156 Per Amundsen
It is possible to use scripts as functions.
475
These functions are fully nested like the client functions.
476 154 Per Amundsen
477
Lets say you make a /mycalc like this.
478
<pre>
479
OnCommand /mycalc {
480
	return $calc($0+$1);
481
}
482
</pre>
483
484
Then you can call this function with eiter /mycalc <number> <number> the normal way or $mycalc(<number, <number>)
485
Typing /testcalc will show the result.
486
<pre>
487
OnCommand /testcalc {
488
	/echo $0 + $1 is $mycalc($0, $1);
489
	/echo 5 + 4 is $mycalc(5, 4);
490
}
491
</pre>
492
493
Simple convert temperature C to F or F to C
494
/temp C 20 will print 68 F
495
496
<pre>
497
OnCommand /temp {
498
	if ($1 == C) /echo $calc(($2 * 9/5) + 32) F
499
	else if ($1 == F) /echo $round($calc(($2 - 32) * 5/9), 1) C
500
	else /echo Temp missing
501
}
502
</pre>
503
504
Test if input contains a link
505
<pre>
506
OnCommand /testlink {
507
	if (!$1) {
508
		/echo Link missing
509
		return
510
	}
511
512
	/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)
513
}
514
515
</pre>
516
517
Retrives plot summary from captured imbd links
518
<pre>
519
On PRIVMSG {
520
	var %reg = $regex($0-, http://www\\.imdb\\.com(/title/[a-z0-9]+/))
521
	if (!%reg) { return }
522
		
523
	/sockclose imdb
524
	%text = null
525
	%imdb = $regmatch(1)plotsummary
526
	%imdbchan = $channel
527
	/sockopen imdb www.imdb.com 80
528
}
529
530
On SockOpen {
531
	if ($1 != imdb) { return }
532
533
	/sockwrite -n imdb GET %imdb HTTP/1.1
534
	/sockwrite -n imdb Host: www.imdb.com
535
	/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
536
	/sockwrite -n imdb Referer: http://www.imdb.com
537
	/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
538
	/sockwrite -n imdb Accept-Language: en-us, en\;q=0.50
539
	/sockwrite -n imdb Connection: Close$crlf
540
}
541
542
On SockRead {
543
	if ($1 != imdb) { return }
544
		
545
	%text += $sockread(imdb)
546
}
547
548
On SockClose {
549
	if ($1 != imdb) { return }
550
	
551
	if ($regex(%text, <p class="plotpar">([\\s\\S]*?)<i>)) {
552
		/msg %imdbchan $regmatch(1)
553
	}
554
555
	%text = null
556
}
557
</pre>
558
559
An example showing the difference between dates
560
<pre>
561
OnCommand /test {
562
	$datediff($ctime(1/1 2042), $now)
563
	
564
	var %text = Difference is
565
	%text += $chr(32)$datematch(4) $iif($datematch(4) == 1, day, days)
566
	%text += $chr(32)$datematch(3) $iif($datematch(3) == 1, hour, hours) 
567
	%text += $chr(32)$datematch(2) $iif($datematch(3) == 1, minut, minutes) 
568
    
569
	/echo %text
570
}
571
</pre>
572 158 Per Amundsen
573
Announce song changes in a channel or to a user
574
<pre>
575
On OnSongChanged { 
576
	/nmsg <network> <channel/Nick> $0-
577
}
578
</pre>
579
580
Announce to several channels with:
581
<pre>
582
On OnSongChanged { 
583
	/nmsg <network> <channel1/Nick>,<channel2/Nick> $0-
584
	/nmsg <network2> <channel3/Nick> $0- 
585
}
586 154 Per Amundsen
</pre>