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