Merged 0.7.99 irssi.
[runtime.git] / apps / irssi / docs / perl.txt
1  Running Perl scripts
2  --------------------
3
4 First you'll need to have Perl support on. By default irssi compiles
5 Perl as a module, so /LOAD perl probably helps. If you want to do this
6 automatically at startup put the "/LOAD perl" to ~/.irssi/startup file.
7 After that you can run scripts with /RUN script (you don't need to give
8 the .pl extension). If /RUN complains about "unknown command", you
9 don't have Perl module loaded, or maybe Perl support wasn't compiled at
10 all.
11
12 Place new scripts to ~/.irssi/scripts/ or /usr/local/lib/irssi/scripts/
13 directory. Scripts in ~/.irssi/scripts/autorun/ directory are
14 automatically run at startup.
15
16 Using /PERLFLUSH closes and reopens the perl interpreter removing all
17 Perl scripts from memory. There's currently no way to unload a single
18 Perl script (/SCRIPT REMOVE will probably work soon). You can however
19 run same script multiple times, and irssi will remove the old version
20 from memory before running the new version.
21
22
23  Irssi's signals
24  ---------------
25
26 Irssi is pretty much based on sending and handling different signals.
27 Like when you receive a message from server, say
28
29   :nick!user@there.org PRIVMSG you :blahblah
30
31 Irssi will first send a signal:
32
33   "server incoming", SERVER_REC, "nick!user@there PRIVMSG ..."
34
35 You probably don't want to use this signal. Default handler for this
36 signal interprets the header and sends a signal:
37
38   "server event", SERVER_REC, "PRIVMSG ...", "nick", "user@there.org"
39
40 You probably don't want to use this either, since this signal's default
41 handler parses the event string and sends a signal:
42
43   "event privmsg", SERVER_REC, "you :blahblah", "nick", "user@there.org"
44
45 You can at any point grab the signal, do whatever you want to do with
46 it and optionally stop it from going any further by calling
47 Irssi::signal_stop();
48
49 For example:
50
51   sub event_privmsg {
52     # $data = "nick/#channel :text"
53     my ($server, $data, $nick, $address) = @_;
54     my ($target, $text) = split(/ :/, $data, 2);
55
56     Irssi::signal_stop() if ($text =~ /free.*porn/ || $nick =~ /idiot/);
57   }
58
59 Irssi::signal_add("event privmsg", "event_privmsg")
60
61 This will hide all public or private messages that match the regexp
62 "free.*porn" or the sender's nick contain the word "idiot". Yes, you
63 could use /IGNORE instead for both of these :)
64
65 You can also use signal_add_last() if you wish to let the Irssi's internal
66 functions be run before yours.
67
68 A list of signals that irssi sends can be found from signals.txt file.
69
70
71  Creating/replacing /COMMANDS
72  ----------------------------
73
74 You can create your own commands, or replace existing ones with
75 Irssi::command_bind(). The command handling work internally pretty much
76 the same as signal handlers, so if you replace existing command and don't
77 wish to let it run, call Irssi::signal_stop().
78
79 Here's an example:
80
81   # Usage: /HELLO [<nick>]
82   sub cmd_hello {
83     # data - contains the parameters for /HELLO
84     # server - the active server in window
85     # witem - the active window item (eg. channel, query)
86     #         or undef if the window is empty
87     my ($data, $server, $witem) = @_;
88
89     if (!$server || !$server->{connected}) {
90       Irssi::print("Not connected to server");
91       return;
92     }
93
94     if ($data) {
95       $server->command("/MSG $data Hello!");
96     } elsif ($witem && ($witem->{type} eq "CHANNEL" ||
97                         $witem->{type} eq "QUERY")) {
98       # there's query/channel active in window
99       $witem->command("/MSG ".$witem->{name}." Hello!");
100     } else {
101       Irssi::print("Nick not given, and no active channel/query in window");
102     }
103   }
104
105   Irssi::command_bind('hello', 'cmd_hello');
106
107
108  Message levels
109  --------------
110
111 Several functions expect message levels. They're used to roughly
112 classify messages. They're used by a lot of things including logging,
113 ignoring, highlighting, etc. so you should use as good level as
114 possible. It's possible to have several levels in one message, like
115 ACTIONS+PUBLIC or ACTIONS+MSGS.
116
117 Here's all the levels that irssi supports currently:
118
119   CRAP, MSGS, PUBLIC, NOTICES, SNOTES, CTCPS, ACTIONS, JOINS, PARTS
120   QUITS, KICKS, MODES, TOPICS, WALLOPS, INVITES, NICKS, DCC, DCCMSGS,
121   CLIENTNOTICE, CLIENTCRAP, CLIENTERROR
122
123 And a few special ones that could be included with the levels above:
124
125   HILIGHT - text is highlighted
126   NOHILIGHT - don't check highlighting for this message
127   NO_ACT - don't trigger channel activity when printing this message
128   NEVER - never ignore or log this message (not a good idea usually)
129
130 You can use them with a MSGLEVEL_ prefix, for example:
131
132   $server->print("#channel", 'Hello, world', MSGLEVEL_CLIENTCRAP);
133
134 Writes text to #channel window with CLIENTCRAP level.
135
136
137  Window items
138  ------------
139
140 Meaning of "window" should be pretty clear, but "window item" is
141 something I couldn't really figure out a better name for :) They're
142 simply something that's inside a window, a channel or a query usually.
143 Windows can have multiple items inside them. It's possible to create
144 non-channel/query window items too, currently the third possible window
145 item is created by /EXEC -interactive.
146
147 In scripts, I think you can quite safely assume that the window item is
148 query or channel if the script is intended to be run in one of them.
149 Stupid users won't probably have other window items, and smart users
150 know where to run the script, or at least later figure out why it
151 didn't work :)
152
153
154  Functions that you can use in Irssi's Perl scripts
155  --------------------------------------------------
156
157 If there's a "Xxxx::" text before the command, it means that it belongs to
158 that package. Like "Server::command" means that you should either call it as
159   Irssi::Server::command($server, $cmd);
160 or more easily:
161   $server->command($cmd);
162
163 Commands that don't have the Xxxx prefix are called as Irssi::command();
164
165 Information from most objects can be fetched with $object->{data}, for
166 example current nick in server could be read with $server->{nick}. List
167 of all the information that are in objects are in "Object->{}" sections
168 below.
169
170 Commands are split in two groups, generic ones that could be used with
171 any chat protocol, and IRC specific commands. If you want to use IRC
172 specific commands, or use IRC specific ->{data} in your scripts, you'll
173 need to add "use Irssi::Irc" to your scripts. IRC specific commands are
174 listed after the generic ones.
175
176
177  *** General
178
179 Window active_win() - return active window
180 Server active_server() - return server in active window
181
182 windows() - return list of all windows
183 servers() - return list of all servers
184 reconnects() - return list of all server reconnections
185 channels() - return list of all channels
186 queries() - return list of all queries
187 commands() - return list of all commands
188 logs() - return list of all log files
189 ignores() - returns list of all ignores
190
191 Server::channels() - return list of channels in server
192 Server::queries() - return list of queries in server
193
194 print(str[, level])
195 Server::print(channel, str[, level])
196 Window::print(str[, level])
197 Windowitem::print(str[, level])
198   Print `str'. Default level is MSGLEVEL_CLIENTNOTICE.
199
200 command(cmd)
201 Server::command(cmd)
202 Window::command(cmd)
203 Windowitem::command(cmd)
204   Send a command `cmd' (in current channel). This will work just as if you
205   had typed `cmd' in command line, so you'll need to use /COMMANDS or the
206   text will be sent to the channel.
207
208   Just like above, except different calling method.
209
210
211  *** Themes
212
213 You can have user configurable texts in scripts that work just like
214 irssi's internal texts that can be changed in themes.
215
216 First you'll have to register the formats:
217
218 Irssi::theme_register([
219   'format_name', '{hilight my perl format!}',
220   'format2', 'testing.. nick = $0, channel = $1'
221 ]);
222
223 Printing happens with one of the functions:
224
225 printformat(level, format, ...)
226 Window::printformat(level, format, ...)
227 Server::printformat(target, level, format, ...)
228 Windowitem::printformat(level, format, ...)
229
230 For example:
231
232   $channel->printformat(MSGLEVEL_CRAP, 'format2',
233                         'nick', $channel->{name});
234
235
236  *** Settings
237
238 settings_get_str(key)
239 settings_get_int(key)
240 settings_get_bool(key)
241   Return value for setting.
242
243 settings_add_str(section, key, def)
244 settings_add_int(section, key, def)
245 settings_add_bool(section, key, def)
246   Create new setting.
247
248 settings_remove(key)
249   Remove a setting.
250
251
252  *** Signals
253
254 signal_emit(signal, ...)
255   Send signal `signal'. You can give 6 parameters at maximum.
256
257 signal_add(signal, func)
258   Bind `signal' to function `func'.
259
260 signal_add_first(signal, func)
261   Bind `signal' to function `func'. Call `func' as soon as possible.
262
263 signal_add_last(signal, func)
264   Bind `signal' to function `func'. Call `func' as late as possible.
265
266 signal_remove(signal, func)
267   Unbind `signal' from function `func'.
268
269 signal_stop()
270   Stop the signal that's currently being emitted.
271
272 signal_stop_by_name(signal)
273   Stop the signal with name `signal' that's currently being emitted.
274
275
276   *** timeouts / IO listener
277
278 timeout_add(msecs, func, data)
279   Call `func' every `msecs' milliseconds (1000 = 1 second) with
280   parameter `data'. Returns tag which can be used to stop the timeout.
281
282 timeout_remove(tag)
283   Remove timeout with tag.
284
285 input_add(source, condition, func, data)
286   Call `func' with parameter `data' when specified IO happens.
287   `source' is the file handle that is being listened. `condition' can
288   be INPUT_READ, INPUT_WRITE or both. Returns tag which can be used to
289   remove the listener.
290
291 input_remove(tag)
292   Remove listener with tag.
293
294
295  *** Message levels
296
297 level2bits(level)
298   Level string -> number
299
300 bits2level(bits)
301   Level number -> string
302
303 combine_level(level, str)
304   Combine level number to level string ("+level -level").
305   Return new level number.
306
307
308  *** Commands
309
310 Command->{}
311   cmd - Command name
312   category - Category
313
314 command_bind(cmd, func[, category])
315   Bind command `cmd' to call function `func'. `category' is the
316   category where the command is displayed in /HELP.
317
318 command_runsub(cms, data, server, item)
319   Run subcommands for `cmd'. First word in `data' is parsed as
320   subcommand. `server' is Irssi::Server rec for current
321   Irssi::Windowitem `item'.
322   
323   Call command_runsub in handler function for `cmd' and bind
324   with command_bind("`cmd' `subcmd'", subcmdfunc[, category]);
325
326 command_unbind(cmd, func)
327   Unbind command `cmd' from function 'func.
328
329
330  *** Windows
331
332 UI::Window->{}
333   refnum - Reference number
334   name - Name
335
336   width - Width
337   height - Height
338
339   history_name - Name of named historylist for this window
340
341   active - Active window item
342   active_server - Active server
343
344   servertag - active_server must be either undef or have this same tag
345               (unless there's items in this window). This is used by
346               /WINDOW SERVER -sticky
347   level - Current window level
348
349   sticky_refnum - 1 if reference number is sticky
350
351   data_level - Current data level
352   hilight_color - Current activity hilight color
353
354   last_timestamp - Last time timestamp was written in window
355   last_line - Last time text was written in window
356
357   theme_name - Active theme in window, undef = default
358
359 UI::TextDest->{}
360   window - Window where the text will be written
361   server - Target server
362   target - Target channel/query/etc name
363   level - Text level
364
365   hilight_priority - Priority for the hilighted text
366   hilight_color - Color for the hilighted text
367
368
369 Window::items()
370   Return a list of items in window.
371
372 Window
373 window_create(automatic)
374 Windowitem::window_create(automatic)
375   Create a new window.
376
377 Window::destroy()
378   Destroy the window.
379
380 Irssi::Window
381 Windowitem::window()
382   Returns parent window for window item.
383
384 Window
385 window_find_name(name)
386   Find window with name.
387
388 Window
389 window_find_refnum(refnum)
390   Find window with reference number.
391
392 Window
393 window_find_level(level)
394 Server::window_find_level(level)
395   Find window with level.
396
397 Window
398 window_find_closest(name, level)
399 Server::window_find_closest(name, level)
400   Find window that matches best to given arguments. `name' can be either
401   window name or name of one of the window items.
402
403 Window
404 window_find_item(name)
405 Server::window_find_item(name)
406   Find window which contains window item with specified name/server.
407
408 Windowitem
409 window_item_find(name)
410 Server::window_item_find(name)
411 Window::item_find(server, name)
412   Find window item that matches best to given arguments.
413
414 window_refnum_prev(refnum, wrap)
415 window_refnum_next(refnum, wrap)
416   Return refnum for window that's previous/next in windows list.
417
418 windows_refnum_last()
419   Return refnum for last window.
420
421 Window::item_add(item, automatic)
422 Window::item_remove(item)
423 Window::item_destroy(item)
424   Add/remove/destroy window item
425
426 Window::set_active()
427   Set window active.
428
429 Window::change_server(server)
430 Window::set_refnum(refnum)
431 Window::set_name(name)
432 Window::set_history(name)
433 Window::set_level(level)
434   Change server/refnum/name/history/level in window.
435
436 Windowitem::set_active()
437   Change window item active in parent window.
438
439 Window::item_prev()
440 Window::item_next()
441   Change to previous/next window item.
442
443 Windowitem::change_server(server)
444   Change server in window item.
445
446 Windowitem::is_active()
447   Returns 1 if window item is the active item in parent window.
448
449 Window::get_active_name()
450   Return active item's name, or if none is active, window's name
451
452
453  *** Server Connects
454
455 Connect->{}
456   type - "SERVER CONNECT" text
457   chat_type - String ID of chat protocol, for example "IRC"
458
459   address - Address where we connected (irc.blah.org)
460   port - Port where we connected
461   chatnet - Chat network
462
463   password - Password we used in connection.
464   wanted_nick - Nick which we would prefer to use
465   username - User name
466   realname - Real name
467
468 Connect
469 server_create_conn(address[, port=6667[, password=''[, nick=''[, channels='']]]])
470   Create new server connection.
471
472
473  *** Server functions
474
475 Server->{}
476   type - "SERVER" text
477   chat_type - String ID of chat protocol, for example "IRC"
478
479   (..contains all the same data as Connect above..)
480
481   connect_time - Time when connect() to server finished
482   real_connect_time - Time when server sent "connected" message
483
484   tag - Unique server tag
485   nick - Current nick
486
487   connected - Is connection finished? 1|0
488   connection_lost - Did we lose the connection (1) or was
489                     the connection just /DISCONNECTed (0)
490
491   rawlog - Rawlog object for the server
492
493   version - Server version
494   last_invite - Last channel we were invited to
495   server_operator - Are we server operator (IRC op) 1|0
496   usermode_away - Are we marked as away? 1|0
497   away_reason - Away reason message
498   banned - Were we banned from this server? 1|0
499   lag - Current lag to server in milliseconds
500
501 Server
502 Connect::connect()
503   Connect to server.
504
505 Server::disconnect()
506   Disconnect from server.
507
508 Server
509 server_find_tag(tag)
510   Find server with tag
511
512 Server
513 server_find_chatnet(chatnet)
514   Find first server that is in `chatnet'
515
516 Server::isnickflag(flag)
517   Returns 1 if flag is a nick mode flag (@, + or % in IRC)
518
519 Server::ischannel(data)
520   Returns 1 if start of `data' seems to mean channel.
521
522 Server::get_nick_flags()
523   Returns nick flag characters in order: op, voice, halfop ("@+%" in IRC).
524
525 Server::send_message(target, msg)
526   Sends a message to nick/channel.
527
528
529  *** Server reconnections
530
531 Reconnect->{}
532   type - "RECONNECT" text
533   chat_type - String ID of chat protocol, for example "IRC"
534
535   (..contains all the same data as Connect above..)
536
537   tag - Unique numeric tag
538   next_connect - Unix time stamp when the next connection occurs
539
540
541  *** Chat networks
542
543 Chatnet->{}
544   type - "CHATNET" text
545   chat_type - String ID of chat protocol, for example "IRC"
546
547   name - name of chat network
548
549   nick - if not empty, nick preferred in this network
550   username - if not empty, username preferred in this network
551   realname - if not empty, realname preferred in this network
552
553   own_host - address to use when connecting this network
554   autosendcmd - command to send after connecting to this network
555
556 chatnet_find(name)
557   Find chat network with name.
558
559
560  *** Server redirections
561
562 This is a powerful feature of Irssi that I haven't seen in other IRC
563 clients. You can EASILY grab the server's reply for a command you send
564 to server without any horrible kludges.
565
566 redirect_register(command, remote, timeout, start, stop, opt)
567    Register new redirection command. By default irssi has already
568    registered at least: whois, whowas, who, list, ison, userhost, ping,
569    "mode channel" (/MODE #channel), "mode b" (/MODE #channel b), "mode e"
570    and "mode I".
571
572    `command' specifies the name of the command to register, it doesn't
573    have to be a real command name, but something you just specify to
574    redirect_event() when using this redirection.
575
576    `remote' specifies if the command is by default a remote command
577    (eg. sent to another server). redirect_event() may override this.
578
579    `timeout' - If remote is TRUE, specifies how many seconds to wait for
580    reply before aborting.
581
582    `start', `stop', `opt' - hash references with "event" => argpos entries.
583    List of events that start and stop this redirection.
584    Start event list may be empty, but there must be at least one
585    stop event. Optional events are checked only if they are received
586    immediately after one of the stop-events. `argpos' specifies the
587    word number in event string which is compared to wanted argument,
588    -1 = don't compare, TRUE always.
589
590   Example (already done by irssi):
591
592   Irssi::redirect_register('mode channel', 0, 0,
593         undef, # no start events
594         { # stop events
595           "event 324" => 1, # MODE-reply
596           "event 403" => 1, # no such channel
597           "event 442" => 1, # "you're not on that channel"
598           "event 479" => 1  # "Cannot join channel (illegal name)"
599         }, { # optional events
600           "event 329", 1 # Channel create time
601         } );
602
603 Server::redirect_event(command, count, arg, remote, failure_signal, signals)
604    Specify that the next command sent to server will be redirected.
605    NOTE: This command MUST be called before sending the command to server.
606
607    `command' - Name of the registered redirection that we're using.
608
609    `count' - How many times to execute the redirection. Some commands may
610    send multiple stop events, like MODE #a,#b.
611
612    `arg' - The argument to be compared in event strings. You can give multiple
613    arguments separated with space.
614
615    `remote' - Specifies if the command is a remote command, -1 = use default.
616
617    `failure_signal' - If irssi can't find the stop signal for the redirection,
618    this signal is called.
619
620    `signals' - hash reference with "event" => "redir signal" entries.
621    If the event is "", all the events belonging to the redirection but not
622    specified here, will be sent there.
623
624   Example:
625
626   # ignore all events generated by whois query, except 311.
627   $server->redirect_event("whois", 1, "cras", 0, undef, {
628                           "event 311" => "redir whois",
629                           "" => "event empty" });
630   $server->send_raw("WHOIS :cras");
631
632
633  *** Window items
634
635 Windowitem->{}
636   type - Type of the window item, for example "CHANNEL" or "QUERY"
637   chat_type - String ID of chat protocol, for example "IRC"
638
639   server - Active server for item
640   name - Name of the item
641
642   createtime - Time the window item was created
643   data_level - 0=no new data, 1=text, 2=msg, 3=highlighted text
644   hilight_color - Color of the last highlighted text
645
646
647  *** Channels
648
649 Channel->{}
650   type - "CHANNEL" text
651   chat_type - String ID of chat protocol, for example "IRC"
652
653   (..contains all the same data as Windowitem above..)
654
655   topic - Channel topic
656   topic_by - Nick who set the topic
657   topic_time - Timestamp when the topic was set
658
659   no_modes - Channel is modeless
660   mode - Channel mode
661   limit - Max. users in channel (+l mode)
662   key - Channel key (password)
663
664   chanop - You are channel operator
665   names_got - /NAMES list has been received
666   wholist - /WHO list has been received
667   synced - Channel is fully synchronized
668
669   joined - JOIN event for this channel has been received
670   left - You just left the channel (for "channel destroyed" event)
671   kicked - You was just kicked out of the channel (for
672            "channel destroyed" event)
673
674 Server::channels_join(channels, automatic)
675   Join to channels in server. `channels' may also contain keys for
676   channels just like with /JOIN command. `automatic' specifies if this
677   channel was joined "automatically" or if it was joined because join
678   was requested by user. If channel join is "automatic", irssi doesn't
679   jump to the window where the channel was joined.
680
681 Channel
682 Server::channel_create(name, automatic)
683   Create new channel.
684
685 Channel
686 channel_create(chat_type, name, automatic)
687   Create new channel with specified chat type.
688   FIXME: should this be removed? is this useful for anything?
689
690 Channel::destroy()
691   Destroy channel.
692
693 Channel
694 channel_find(channel)
695   Find channel from any server.
696
697 Channel
698 Server::channel_find(channel)
699   Find channel from specified server.
700
701
702  *** Nick list
703
704 Nick->{}
705   type - "NICK" text
706   chat_type - String ID of chat protocol, for example "IRC"
707
708   nick - Plain nick
709   host - Host address
710   realname - Real name
711   hops - Hop count to the server the nick is using
712
713   gone, serverop - User status, 1 or 0
714   op, voice, halfop - Channel status, 1 or 0
715
716   last_check - timestamp when last checked gone/ircop status.
717   send_massjoin - Waiting to be sent in a "massjoin" signal, 1 or 0
718
719 Nick
720 Channel::nick_insert(nick, op, voice, send_massjoin)
721   Add nick to nicklist.
722
723 Channel::nick_remove(nick)
724   Remove nick from nicklist.
725
726 Nick
727 Channel::nick_find(mask)
728   Find nick from nicklist.
729
730 Channel::nicks(channel)
731   Return a list of all nicks in channel.
732
733 Server::nicks_get_same(nick)
734   Return all nick objects in all channels in server. List is in format:
735   Channel, Nick, Channel, ...
736
737
738  *** Queries
739
740 Query->{}
741   type - "QUERY" text
742   chat_type - String ID of chat protocol, for example "IRC"
743
744   (..contains all the same data as Windowitem above..)
745
746   address - Host address of the queries nick
747   server_tag - Server tag used for this nick (doesn't get erased if
748                server gets disconnected)
749   unwanted - 1 if the other side closed or some error occured (DCC chats)
750
751 Query
752 query_create(chat_type, server_tag, nick, automatic)
753   Create a new query.
754
755 Query::destroy()
756   Destroy the query.
757
758 Query::query_change_server(server)
759   Change the active server of the query.
760
761 Query
762 query_find(nick)
763   Find query from any server.
764
765 Query
766 Server::query_find(nick)
767   Find query from specified server.
768
769
770  *** Masks
771
772 You should use the Server version of the function if possible, since
773 with different chat protocols the mask matching could be different.
774
775 mask_match(mask, nick, user, host)
776 Server::mask_match(mask, nick, user, host)
777   Return 1 if `mask' matches nick!user@host.
778
779 mask_match_address(mask, nick, address)
780 Server::mask_match_address(mask, nick, address)
781   Return 1 if `mask' matches nick!address.
782
783 masks_match(masks, nick, address)
784 Server::masks_match(masks, nick, address)
785   Return 1 if any mask in the `masks' (string separated with spaces)
786   matches nick!address.
787
788
789  *** Rawlog
790
791 Rawlog->{}
792   logging - The rawlog is being written to file currently
793   nlines - Number of lines in rawlog
794
795 Rawlog
796 rawlog_create()
797   Create a new rawlog.
798
799 Rawlog::destroy()
800   Destroy the rawlog.
801
802 Rawlog::get_lines()
803   Returns all lines in rawlog.
804
805 rawlog_set_size(lines)
806   Set the default rawlog size for new rawlogs.
807
808 Rawlog::open(filename)
809   Start logging new messages in rawlog to specified file.
810
811 Rawlog::close()
812   Stop logging to file.
813
814 Rawlog::save(filename)
815   Save the current rawlog history to specified file.
816
817 Rawlog::input(str)
818   Send `str' to raw log as input text.
819
820 Rawlog::output(str)
821   Send `str' to raw log as output text.
822
823 Rawlog::redirect(str)
824   Send `str' to raw log as redirection text.
825
826
827  *** Logging
828
829 Log->{}
830   fname - Log file name
831   real_fname - The actual opened log file (after %d.%m.Y etc. are expanded)
832   opened - Log file is open
833   level - Log only these levels
834   last - Timestamp when last message was written
835   autoopen - Automatically open log at startup
836   failed - Opening log failed last time
837   temp - Log isn't saved to config file
838   items - List of log items
839
840 Logitem->{}
841   type - 0=target, 1=window refnum
842   name - Name
843   servertag - Server tag
844
845 Log
846 log_create_rec(fname, level)
847   Create log file.
848
849 Log::update()
850   Add log to list of logs / save changes to config file.
851
852 Log
853 log_find(fname)
854   Find log with file name.
855
856 Log::close()
857   Destroy log file.
858
859 Log::start_logging()
860   Open log file and start logging.
861
862 Log::stop_logging()
863   Close log file.
864
865 Log::item_add(type, name, server)
866   Add log item to log.
867
868 Log::item_destroy(item)
869   Remove log item from log.
870
871 Logitem
872 Log::item_find(type, item, server)
873   Find item from log.
874
875
876  *** Ignores
877
878 Ignore->{}
879   mask - Ignore mask
880   servertag - Ignore only in server
881   channels - Ignore only in channels (list of names)
882   pattern - Ignore text pattern
883
884   level - Ignore level
885
886   exception - This is an exception ignore
887   regexp - Regexp pattern matching
888   fullword - Pattern matches only full words
889
890 ignore_add_rec(ignore)
891   Add ignore record.
892
893 ignore_update_rec(ignore)
894   Update ignore record in configuration
895
896 ignore_check(nick, host, channel, text, level)
897 Server::ignore_check(nick, host, channel, text, level)
898   Return 1 if ignoring matched.
899
900
901  ***
902  *** IRC specific functions. All objects below this are prefixed with Irc::
903  ***
904
905  *** IRC servers
906
907 Irc::Server->{}
908   (..contains all the same data as core Server object..)
909   real_address - Address the IRC server gives
910   usermode - User mode in server
911   userhost - Your user host in server
912
913 Irc::Connect->{}
914   (..contains all the same data as core Connect object..)
915   alternate_nick - Alternate nick to use if default nick is taken.
916
917 Connect::connect()
918   Connect to IRC server.
919
920 Server::get_channels(server)
921   Return a string of all channels (and keys, if any have them) in server,
922   like "#a,#b,#c,#d x,b_chan_key,x,x" or just "#e,#f,#g"
923
924 Server::send_raw(cmd)
925   Send raw message to server, it will be flood protected so you
926   don't need to worry about it.
927
928 Server::send_raw_now(cmd)
929   Send raw message to server immediately without flood protection.
930
931 Server::send_raw_split(cmd, nickarg, max_nicks)
932   Split the `cmd' into several commands so `nickarg' argument has only
933   `max_nicks' number of nicks.
934
935   Example:
936     $server->send_raw_split("KICK #channel nick1,nick2,nick3 :byebye", 3, 2);
937
938   Irssi will send commands "KICK #channel nick1,nick2 :byebye" and
939   "KICK #channel nick3 :byebye" to server.
940
941 Server::ctcp_send_reply(data)
942   Send CTCP reply. This will be "CTCP flood protected" so if there's too
943   many CTCP requests in buffer, this reply might not get sent. The data
944   is the full raw command to be sent to server, like
945     "NOTICE nick :\001VERSION irssi\001"
946
947
948  *** IRC channels
949
950 Ban->{}
951   ban - The ban
952   setby - Nick of who set the ban
953   time - Timestamp when ban was set
954
955 Channel
956 Server::channel_create(name, automatic)
957   Create new channel.
958
959 Channel::bans()
960   Return a list of bans in channel.
961
962 Channel::ebans()
963   Return a list of ban exceptions in channel.
964
965 Channel::invites()
966   Return invite list (+I) of channel.
967
968 Channel::ban_get_mask(nick)
969   Get ban mask for `nick'.
970
971 Channel::banlist_add(ban, nick, time)
972    Add a new ban to channel.
973
974 Channel::banlist_remove(ban)
975    Remove a ban from channel.
976
977 Channel::banlist_exception_add(ban, nick, time)
978    Add a new ban exception to channel.
979
980 Channel::banlist_exception_remove(ban)
981    Remove a ban exception from channel.
982
983 Channel::invitelist_add(mask)
984    Add a new invite mask to channel.
985
986 Channel::invitelist_remove(mask)
987    Remove invite mask from channel.
988
989 modes_join(old, mode, channel)
990   Add `mode' to `old' - return newly allocated mode. If `channel' is 1,
991   we're parsing channel mode and we should try to join mode arguments too.
992
993
994  *** DCC
995
996 Dcc->{}
997   type - Type of the DCC: chat, send, get
998   orig_type - Original DCC type that was sent to us - same as type except
999               GET and SEND are swapped
1000   created - Time stamp when the DCC record was created
1001
1002   server - Server record where the DCC was initiated.
1003   servertag - Tag of the server where the DCC was initiated.
1004   mynick - Our nick to use in DCC chat.
1005   nick - Other side's nick name.
1006
1007   chat - Dcc chat record if the request came through DCC chat
1008   target - Who the request was sent to - your nick, channel or empty
1009            if you sent the request
1010   arg - Given argument .. file name usually
1011
1012   addr - Other side's IP address.
1013   port - Port we're connecting in.
1014
1015   starttime - Unix time stamp when the DCC transfer was started
1016   transfd - Bytes transferred
1017
1018 Dcc::Chat->{}
1019   id - Unique identifier - usually same as nick
1020   mirc_ctcp - Send CTCPs without the CTCP_MESSAGE prefix
1021   connection_lost - Other side closed connection
1022
1023 Dcc::Get->{}
1024   (..contains all the same data as core Dcc object..)
1025   size - File size
1026   skipped - Bytes skipped from start (resuming file)
1027
1028   get_type - What to do if file exists? 0=default, 1=rename, 2=overwrite,
1029              3=resume
1030   file - The real file name which we use.
1031   file_quoted - 1 if file name was received quoted ("file name")
1032
1033 Dcc::Send->{}
1034   (..contains all the same data as core Dcc object..)
1035   size - File size
1036   skipped - Bytes skipped from start (resuming file)
1037
1038   file_quoted - 1 if file name was received quoted ("file name")
1039   waitforend - File is sent, just wait for the replies from the other side
1040   gotalldata - Got all acks from the other end
1041
1042
1043 dccs() - return list of all dcc connections
1044
1045 Dcc::destroy()
1046   Destroy DCC connection.
1047
1048 Dcc
1049 dcc_find_item(type, nick, arg)
1050   Find DCC connection.
1051
1052 Dcc
1053 dcc_find_by_port(nick, port)
1054   Find DCC connection by port.
1055
1056 Dcc
1057 Windowitem::get_dcc(item)
1058   If `item' is a query of a =nick, return DCC chat record of nick.
1059
1060 Dcc::chat_send(data)
1061   Send `data' to dcc chat.
1062
1063 Server::dcc_ctcp_message(target, notice, msg)
1064 Dcc::ctcp_message(target, notice, msg)
1065   Send a CTCP message/notify to target.
1066
1067
1068  *** Netsplits
1069
1070 Netsplit->{}
1071   nick - Nick
1072   address - Nick's host
1073   destroy - Timestamp when this record should be destroyed
1074   server - Netsplitserver object
1075   channels - list of channels (Netsplitchannel objects) the nick was in
1076
1077 Netsplitserver->{}
1078   server - The server nick was in
1079   destserver - The other server where split occured.
1080   count - Number of splits in server
1081
1082 Netsplitchannel->{}
1083   name - Channel name
1084   nick - Nick object
1085
1086 Netsplit
1087 Server::netsplit_find(nick, address)
1088   Check if nick!address is on the other side of netsplit. Netsplit records
1089   are automatically removed after 30 minutes (current default)..
1090
1091 Nick
1092 Server::netsplit_find_channel(nick, address, channel)
1093   Find nick record for nick!address in channel `channel'.
1094
1095
1096  *** Notify list
1097
1098 Notifylist->{}
1099   mask - Notify nick mask
1100   away_check - Notify away status changes
1101   idle_check_time - Notify when idle time is reset and idle was bigger
1102                     than this (seconds)
1103   ircnets - List of ircnets (strings) the notify is checked
1104
1105 notifies() - Return list of all notifies
1106
1107 Notifylist
1108 notifylist_add(mask, ircnets, away_check, idle_check_time)
1109   Add new item to notify list.
1110
1111 notifylist_remove(mask)
1112   Remove item from notify list.
1113
1114 Notifylist
1115 notifylist_find(mask, ircnet)
1116   Find notify.
1117
1118 Server
1119 notifylist_ison(nick, serverlist)
1120   Check if `nick' is in IRC. `serverlist' is a space separated
1121   list of server tags. If it's empty string, all servers will be checked.
1122
1123 Server::notifylist_ison_server(nick)
1124   Check if `nick' is on IRC server.
1125
1126 Notifylist::ircnets_match(ircnet)
1127   Returns 1 if notify is checked in `ircnet'.
1128
1129
1130  *** /EXEC processes
1131
1132 Process->{}
1133   id - ID for the process
1134   name - Name for the process (if given)
1135   args - The command that is being executed
1136
1137   pid - PID for the executed command
1138   target - send text with /msg <target> ...
1139   target_win - print text to this window
1140
1141   shell - start the program via /bin/sh
1142   notice - send text with /notice, not /msg if target is set
1143   silent - don't print "process exited with level xx"