diff --git a/docs/perl.txt b/docs/perl.txt index 4ebbdaed..1976fee7 100644 --- a/docs/perl.txt +++ b/docs/perl.txt @@ -1,90 +1,105 @@ Running Perl scripts -------------------- -FIXME: part of this file is out of date.. -UPDATE: 0.7.96 - this is even yet more out of date ;) See scripts in -samples/ directory, they'll help you get started :) +First you'll need to have Perl support on. By default irssi compiles +Perl as a module, so /LOAD perl probably helps. After that you can run +scripts with /RUN script (you don't need to give the .pl extension). If +/RUN complains about "unknown command", you don't have Perl module +loaded, or maybe Perl support wasn't compiled at all. -Place new scripts to ~/.irssi/scripts/, or /usr/lib/irssi/scripts/ -directory and run then with /RUN script. Or you could also run the -script from another place by specifying the whole path to it. Scripts -in ~/.irssi/scripts/autorun/ directory are automatically run at -startup. +Place new scripts to ~/.irssi/scripts/ or /usr/local/lib/irssi/scripts/ +directory. Scripts in ~/.irssi/scripts/autorun/ directory are +automatically run at startup. Using /PERLFLUSH closes and reopens the perl interpreter removing all -Perl scripts from memory. There's currently no way to unload a single Perl -script. Also, Irssi doesn't check if you run the same script twice or -different scripts use signal_add() for the same named function - it will -probably crash or do some weird things then. +Perl scripts from memory. There's currently no way to unload a single +Perl script (/SCRIPT REMOVE will probably work soon). You can however +run same script multiple times, and irssi will remove the old version +from memory before running the new version. Irssi's signals --------------- Irssi is pretty much based on sending and handling different signals. -Like when you receive a message from server, say, -":nick!user@there.org PRIVMSG you :blahblah". Irssi will first send a -"server incoming" signal with the raw line as it's first parameter. You -probably don't want to use this signal. Next thing Irssi does is to -interpret the header and send a "server event" signal with arguments -"PRIVMSG you...", server, "nick", "user@there.org". You probably don't -want to use this either, since next irssi will send an "event privmsg" -signal with the "you :blahblah" as it's argument. You can at any point -grab the signal, do whatever you want to do with it and optionally stop -it from going any further by returning from the function with value 1. +Like when you receive a message from server, say + + :nick!user@there.org PRIVMSG you :blahblah + +Irssi will first send a signal: + + "server incoming", SERVER_REC, "nick!user@there PRIVMSG ..." + +You probably don't want to use this signal. Default handler for this +signal interprets the header and sends a signal: + + "server event", SERVER_REC, "PRIVMSG ...", "nick", "user@there.org" + +You probably don't want to use this either, since this signal's default +handler parses the event string and sends a signal: + + "event privmsg", SERVER_REC, "you :blahblah", "nick", "user@there.org" + +You can at any point grab the signal, do whatever you want to do with +it and optionally stop it from going any further by calling +Irssi::signal_stop(); For example: -------------------------------------------------------- sub event_privmsg { - # $data = "nick/#channel :text" - my ($data, $server, $nick, $address) = @_; - my ($target, $text) = $data =~ /^(\S*)\s:(.*)/; + # $data = "nick/#channel :text" + my ($server, $data, $nick, $address) = @_; + my ($target, $text) = split(/ :/, $data, 2); - return 1 if ($text =~ /free.*porn/); - return 1 if ($nick =~ /idiot/); + Irssi::signal_stop() if ($text =~ /free.*porn/ || $nick =~ /idiot/); } Irssi::signal_add("event privmsg", "event_privmsg") -------------------------------------------------------- This will hide all public or private messages that match the regexp -"free.*porn" or the sender's nick contain the word "idiot". +"free.*porn" or the sender's nick contain the word "idiot". Yes, you +could use /IGNORE instead for both of these :) You can also use signal_add_last() if you wish to let the Irssi's internal functions be run before yours. -A list of signals that irssi send can be found from SIGNALS file. +A list of signals that irssi send can be found from signals.txt file. Message levels -------------- -Several functions expect message levels. Sometimes numeric and sometimes -alphabetic. Yes, it's stupid, will fix it :) For now you can use -Irssi::level2bits() function to convert the level string to numeric. Here's -all the levels that irssi supports currently: +Several functions expect message levels. They're used to roughly +classify messages. They're used by a lot of things including logging, +ignoring, highlighting, etc. so you should use as good level as +possible. It's possible to have several levels in one message, like +ACTIONS+PUBLIC or ACTIONS+MSGS. -CRAP, MSGS, PUBLIC, NOTICES, SNOTES, CTCPS, ACTIONS, JOINS, PARTS -QUITS, KICKS, MODES, SMODES, TOPICS, WALLOPS, INVITES, NICKS, PONGS -DCC, CLIENTNOTICE, CLIENTCRAP, CLIENTERROR, HILIGHT -(and NOHILIGHT if you don't want the message to be hilighted ever..) +Here's all the levels that irssi supports currently: -For example: + CRAP, MSGS, PUBLIC, NOTICES, SNOTES, CTCPS, ACTIONS, JOINS, PARTS + QUITS, KICKS, MODES, TOPICS, WALLOPS, INVITES, NICKS, DCC, DCCMSGS, + CLIENTNOTICE, CLIENTCRAP, CLIENTERROR -$server->printtext("#channel", Irssi::level2bits('clientcrap'), 'Hello, world'); +And a few special ones that could be included with the levels above: -Writes text to #channel window with clientcrap level. + HILIGHT - message is highlighted + NOHILIGHT - don't check highlighting from message + NO_ACT - don't trigger channel activity when printing this message + NEVER - never ignore or log this message (not a good idea usually) + +You can use them with a MSGLEVEL_ prefix, for example: + + $server->print("#channel", 'Hello, world', MSGLEVEL_CLIENTCRAP); + +Writes text to #channel window with CLIENTCRAP level. Functions that you can use in Irssi's Perl scripts -------------------------------------------------- -This is just my very first implementation and things will probably change. - -Commands marked with (!!) mean that you shouldn't use it unless you -know what you're doing.. - If there's a "Xxxx::" text before the command, it means that it belongs to that package. Like "Server::command" means that you should either call it as Irssi::Server::command($server, $cmd); @@ -93,41 +108,133 @@ or more easily: Commands that don't have the Xxxx prefix are called as Irssi::command(); +Information from most objects can be fetched with $object->{data}, for +example current nick in server could be read with $server->{nick}. List +of all the information that are in objects are in "Object->{}" sections +below. + +Commands are split in two groups, generic ones that could be used with +any chat protocol, and IRC specific commands, you'll need to put +"use Irssi::Irc;" to your scripts. IRC specific commands are listed +after the generic ones. + *** General -Window active_win() - return current window -Server active_server() - return current server +Window active_win() - return active window +Server active_server() - return server in active window -channels() - return list of all channels +windows() - return list of all windows servers() - return list of all servers +reconnects() - return list of all server reconnections +channels() - return list of all channels +queries() - return list of all queries commands() - return list of all commands -dccs() - return list of all dcc connections logs() - return list of all log files +ignores() - returns list of all ignores -print(str, [level]) - Print `str' to some window (status/current probably), default level is - "Irssi notice". +Server::channels() - return list of channels in server +Server::queries() - return list of queries in server -print_window(str, [level]) - Print `str' to current window, default level is "Irssi notice". +print(str[, level]) +Server::print(channel, str[, level]) +Window::print(str[, level]) +Windowitem::print(str[, level]) + Print `str'. Default level is MSGLEVEL_CLIENTNOTICE. -command(cmd, [Server server, [Channel channel]]) +command(cmd) +Server::command(cmd) +Window::command(cmd) +Windowitem::command(cmd) Send a command `cmd' (in current channel). This will work just as if you had typed `cmd' in command line, so you'll need to use /COMMANDS or the text will be sent to the channel. -Server::command(cmd, [Channel channel]) Just like above, except different calling method. -Channel::command(cmd) - Just like above, except different calling method. -Server::printtext(channel, level, str) - Print `str'. + *** Themes -setup_get(option) - Get value of `option' from setup and return it. +You can have user configurable texts in scripts that work just like +irssi's internal texts that can be changed in themes. + +First you'll have to register the formats: + +Irssi::theme_register([ + 'format_name', '{hilight my perl format!}', + 'format2', 'testing.. nick = $0, channel = $1' +]); + +Printing happens with one of the functions: + +printformat(level, format, ...) +Window::printformat(level, format, ...) +Server::printformat(target, level, format, ...) +Windowitem::printformat(level, format, ...) + +For example: + + $channel->printformat(MSGLEVEL_CRAP, 'format2', + 'nick', $channel->{name}); + + + *** Settings + +settings_get_str(key) +settings_get_int(key) +settings_get_bool(key) + Return value for setting. + +settings_add_str(section, key, def) +settings_add_int(section, key, def) +settings_add_bool(section, key, def) + Create new setting. + +settings_remove(key) + Remove a setting. + + + *** Signals + +signal_emit(signal, ...) + Send signal `signal'. You can give 6 parameters at maximum. + +signal_add(signal, func) + Bind `signal' to function `func'. + +signal_add_first(signal, func) + Bind `signal' to function `func'. Call `func' as soon as possible. + +signal_add_last(signal, func) + Bind `signal' to function `func'. Call `func' as late as possible. + +signal_remove(signal, func) + Unbind `signal' from function `func'. + +signal_stop() + Stop the signal that's currently being emitted. + +signal_stop_by_name(signal) + Stop the signal with name `signal' that's currently being emitted. + + + *** timeouts / IO listener + +timeout_add(msecs, func, data) + Call `func' every `msecs' milliseconds (1000 = 1 second) with + parameter `data'. Returns tag which can be used to stop the timeout. + +timeout_remove(tag) + Remove timeout with tag. + +input_add(source, condition, func, data) + Call `func' with parameter `data' when specified IO happens. + `source' is the file handle that is being listened. `condition' can + be INPUT_READ, INPUT_WRITE or both. Returns tag which can be used to + remove the listener. + +input_remove(tag) + Remove listener with tag. *** Message levels @@ -143,150 +250,217 @@ combine_level(level, str) Return new level number. - *** Signals / timeouts - -signal_emit(signal, ...) - Send signal `signal' - -signal_add(signal, func) - Bind `signal' to function `func' - -signal_add_last(signal, func) - Bind `signal' to function `func'. Call `func' as late as possible. - -signal_remove(signal, func) - Unbind `signal' from function `func' - -tag timeout_add(msecs, func, data) - Call `func' every `msecs' milliseconds (1000 = 1 second) with - parameter `data'. Returns tag which can be used to stop the timeout. - -timeout_remove(tag) - Remove timeout with tag. - - *** Commands -Command::values() - Get some information about command. This function returns a reference to - hash table. Hash table has keys: - "cmd" - Command - "category" - Category +Command->{}: + cmd - Command name + category - Category -command_bind(cmd, category, func) +command_bind(cmd, func[, category]) Bind command `cmd' to call function `func'. `category' is the category where the command is displayed in /HELP. command_unbind(cmd, func) Unbind command `cmd' from function 'func. -Server::irc_send_cmd_split(cmd, arg, max_nicks) - Split the `cmd' into several commands so `arg' argument has only - `max_nicks' number of nicks. - Example: $server->irc_send_cmd_split("KICK #channel nick1,nick2,nick3 :byebye", 2, 2); - Irssi will send commands "KICK #channel nick1,nick2 :byebye" and - "KICK #channel nick3 :byebye" to server. + *** Windows + +Window::items() + Return a list of items in window. + +Window +window_create(automatic) +Windowitem::window_create(automatic) + Create a new window. + +Window::destroy() + Destroy the window. + +Irssi::Window +Windowitem::window() + Returns parent window for window item. + +Window +window_find_name(name) + Find window with name. + +Window +window_find_refnum(refnum) + Find window with reference number. + +Window +window_find_level(level) +Server::window_find_level(level) + Find window with level. + +Window +window_find_closest(name, level) +Server::window_find_closest(name, level) + Find window that matches best to given arguments. `name' can be either + window name or name of one of the window items. + +Window +window_find_item(name) +Server::window_find_item(name) + Find window which contains window item with specified name/server. + +Windowitem +window_item_find(name) +Server::window_item_find(name) +Window::item_find(server, name) + Find window item that matches best to given arguments. + +window_refnum_prev(refnum, wrap) +window_refnum_next(refnum, wrap) + Return refnum for window that's previous/next in windows list. + +windows_refnum_last() + Return refnum for last window. + +Window::item_add(item, automatic) +Window::item_remove(item) +Window::item_destroy(item) + Add/remove/destroy window item + +Window::set_active() + Set window active. + +Window::change_server(server) +Window::set_refnum(refnum) +Window::set_name(name) +Window::set_level(level) + Change server/refnum/name/level in window. + +Windowitem::set_active() + Change window item active in parent window. + +Window::item_prev() +Window::item_next() + Change to previous/next window item. + +Windowitem::change_server(server) + Change server in window item. + +Windowitem::is_active() + Returns 1 if window item is the active item in parent window. + +Window::get_active_name() + Return active item's name, or if none is active, window's name *** Server Connects -This is a record where we keep connection information. All Servers and -Reconnects records have pointer to one of these. +Connect->{} + type - "SERVER CONNECT" text + chat_type - String ID of chat protocol, for example "IRC" -Connect::values() - Get some information about connect. This function returns a reference to - hash table. Hash table has keys: - "address" - Address where we connected (irc.blah.org) - "port" - Port where we connected - "password" - Password we used in connection. + address - Address where we connected (irc.blah.org) + port - Port where we connected + chatnet - Chat network - "ircnet" - IRC network - "wanted_nick" - Nick which we would prefer to use - "alternate_nick" - Alternate nick which we would prefer to use - "username" - User name - "realname" - Real name + password - Password we used in connection. + wanted_nick - Nick which we would prefer to use + username - User name + realname - Real name -Connect server_create_conn(address, [port=6667, [password='', [nick='', [channels='']]]]) +Connect +server_create_conn(address[, port=6667[, password=''[, nick=''[, channels='']]]]) Create new server connection. + *** Server functions -Server::values() - Get some information about server. This function returns a reference to - hash table. Hash table has keys: - "address" - Address where we connected (irc.blah.org) - "port" - Port where we connected - "password" - Password we used in connection. +Server->{} + type - "SERVER" text + chat_type - String ID of chat protocol, for example "IRC" - "ircnet" - IRC network - "wanted_nick" - Nick which we would prefer to use - "alternate_nick" - Alternate nick which we would prefer to use - "username" - User name - "realname" - Real name + (..contains all the same data as Connect above..) - "tag" - Unique server tag. - "real_address" - Who the server thinks it is (irc1.blah.org) - "nick" - Current nick - "usermode" - Current user mode - "usermode_away" - Are we marked as away? 1|0 - "away_reason" - Away reason - "connected" - Is connection finished? 1|0 - "connection_lost" - Did we lose the connection (1) or was - the connection meant to be disconnected (0) - Example: - $server_info = Irssi::active_server->values(); - Irssi::print("Current server = ".$server_info->{'address'}); + connect_time - Time when connect() to server finished + real_connect_time - Time when server sent "connected" message -Server Connect::connect() + tag - Unique server tag + nick - Current nick + + connected - Is connection finished? 1|0 + connection_lost - Did we lose the connection (1) or was + the connection just /DISCONNECTed (0) + + rawlog - Rawlog object for the server + + version - Server version + last_invite - Last channel we were invited to + server_operator - Are we server operator (IRC op) 1|0 + usermode_away - Are we marked as away? 1|0 + away_reason - Away reason message + banned - Were we banned from this server? 1|0 + +Server +Connect::connect() Connect to server. Server::disconnect() Disconnect from server. -Server server_find_tag(tag) +Server +server_find_tag(tag) Find server with tag -Server server_find_ircnet(ircnet) - Find first server that is in `ircnet' +Server +server_find_chatnet(chatnet) + Find first server that is in `chatnet' -Channel channel_find(channel) - Find `channel' from any server +Server::isnickflag(flag) + Returns 1 if flag is a nick mode flag (@, + or % in IRC) -Channel Server::channel_find_level(level) - Find channel with level `level' preferably from specified server, but - fallbacks to any channel the matching level. +Server::ischannel(data) + Returns 1 if start of `data' seems to mean channel. -Server::send_raw(cmd) - Send raw message to server, it will be flood protected so you - don't need to worry about it. +Server::get_nick_flags() + Returns nick flag characters in order: op, voice, halfop ("@+%" in IRC). -Server::ctcp_send_reply(data) - Send CTCP reply. This will be "CTCP flood protected" so if there's too - many CTCP requests in buffer, this reply might not get sent. +Server::send_message(target, msg) + Sends a message to nick/channel. + + + *** Server reconnections + +Reconnect->{} + type - "RECONNECT" text + chat_type - String ID of chat protocol, for example "IRC" + + (..contains all the same data as Connect above..) + + tag - Unique numeric tag + next_connect - Unix time stamp when the next connection occurs *** Server redirections -WARNING: It's easy to mess up the Irssi's internal server expectations with -these commands! +WARNING: It's easy to mess up the Irssi's internal server expectations +with these commands! -This is a powerful feature of Irssi that I can't seen in other IRC clients. -You can EASILY grab the server's reply for a command you send to server -without any horrible kludges. +This is a powerful feature of Irssi that I haven't seen in other IRC +clients. You can EASILY grab the server's reply for a command you send +to server without any horrible kludges. Server::redirect_init(command, last, ...) - Initialize redirection for specified command. This needs to be done only - once. Irssi already initializes commands "WHOIS", "WHO", "LIST" and "ISON". + Initialize redirection for specified command. This needs to be done + only once. Irssi already initializes commands WHOIS, WHO, LIST, + USERHOST and ISON. + `command' is the whole name of the signal, like "command whois". `last' specifies how many of the items in `...' is considered as the "last event" from the command. - Example: $server->redirection_init('command who', - 2, # 2 first events will finish the command - 'event 401', # unknown nick (finished) - 'event 315', # end of who (finished) - 'event 352'); # who line (wait..) + Example: + + $server->redirection_init('command who', + 2, # 2 first events will finish the command + 'event 401', # unknown nick (finished) + 'event 315', # end of who (finished) + 'event 352'); # who line (wait..) Server::redirect_event(arg, last, ...) Add redirection. `arg' is a space separated list of arguments that should @@ -301,41 +475,292 @@ Server::redirect_event(arg, last, ...) `event' is the event we're waiting from server. `signal' is the signal we will send after receiving the event. It should always start with 'redir ' so that Irssi's perl handler knows to - send correct arguments to signal handler. + send correct arguments to signal handler. `argpos' is the argument position in event's data or -1 if it should be ignored. Example: - $server->send_raw('WHOIS :cras'); - $server->redirect_event('cras', 2, - "event 318", "redir end_of_whois", -1, - "event 402", "redir no_such_server", -1, - "event 401", "redir no_such_nick", 1, - "event 311", "redir whois", 1, - "event 301", "redir whois_away", 1, - "event 312", "redir whois_server", 1, - "event 313", "redir whois_oper", 1, - "event 317", "redir whois_idle", 1, - "event 319", "redir whois_channels", 1); - In the 402-case we tried "/WHOIS nick nick" but nick didn't exist.. + $server->send_raw('WHOIS :cras'); + $server->redirect_event('cras', 2, + "event 318", "redir end_of_whois", 1, + "event 402", "redir no_such_server", 1, + "event 401", "redir no_such_nick", 1, + "event 311", "redir whois", 1, + "event 301", "redir whois_away", 1, + "event 312", "redir whois_server", 1, + "event 313", "redir whois_oper", 1, + "event 317", "redir whois_idle", 1, + "event 319", "redir whois_channels", 1); -group Server::redirect_single_event(arg, last, group, event, signal, argpos) + In the 402-case we tried "/WHOIS nick nick" but nick didn't exist. If + you need to handle "/WHOIS server nick" situation, you should put both + to arg with "server nick". + +Server::redirect_single_event(arg, last, group, event, signal, argpos) Same as redirect_event() except you can set it up in pieces. If `group' is 0, it will create new group and return it's id. - *** IRC masks + *** Window items -irc_mask_match(mask, nick, user, host) +Windowitem->{} + type - Type of the window item, for example "CHANNEL" or "QUERY" + chat_type - String ID of chat protocol, for example "IRC" + + server - Active server for item + name - Name of the item + + createtime - Time the window item was created + new_data - 0=no new data, 1=text, 2=msg, 3=highlighted text + last_color - Color of the last highlighted text + + + *** Channels + +Channel->{} + type - "CHANNEL" text + chat_type - String ID of chat protocol, for example "IRC" + + (..contains all the same data as Windowitem above..) + + topic - Chanenl topic + + no_modes - Channel is modeless + mode - Channel mode + limit - Max. users in channel (+l mode) + key - Channel key (password) + + chanop - You are channel operator + names_got - /NAMES list has been received + wholist - /WHO list has been received + synced - Channel is fully synchronized + + joined - JOIN event for this channel has been received + left - You just left the channel (for "channel destroyed" event) + kicked - You was just kicked out of the channel (for + "channel destroyed" event) + +Server::channels_join(channels, automatic) + Join to channels in server. `channels' may also contain keys for + channels just like with /JOIN command. `automatic' specifies if this + channel was joined "automatically" or if it was joined because join + was requested by user. If channel join is "automatic", irssi doesn't + jump to the window where the channel was joined. + +Channel +Server::channel_create(name, automatic) + Create new channel. + +Channel +channel_create(chat_type, name, automatic) + Create new channel with specified chat type. + FIXME: should this be removed? is this useful for anything? + +Channel::destroy() + Destroy channel. + +Channel +channel_find(channel) + Find channel from any server. + +Channel +Server::channel_find(channel) + Find channel from specified server. + + + *** Nick list + +Nick->{} + type - "NICK" text + chat_type - String ID of chat protocol, for example "IRC" + + nick - Plain nick + host - Host address + realname - Real name + hops - Hop count to the server the nick is using + + gone, serverop - User status, 1 or 0 + op, voice, halfop - Channel status, 1 or 0 + + last_check - timestamp when last checked gone/ircop status. + send_massjoin - Waiting to be sent in a "massjoin" signal, 1 or 0 + +Nick +Channel::nick_insert(nick, op, voice, send_massjoin) + Add nick to nicklist. + +Channel::nick_remove(nick) + Remove nick from nicklist. + +Nick +Channel::nick_find(mask) + Find nick from nicklist. + +Channel::nicks(channel) + Return a list of all nicks in channel. + +Server::nicks_get_same(nick) + Return all nick objects in all channels in server. List is in format: + Channel, Nick, Channel, ... + + + *** Queries + +Query->{} + type - "QUERY" text + chat_type - String ID of chat protocol, for example "IRC" + + (..contains all the same data as Windowitem above..) + + address - Host address of the queries nick + server_tag - Server tag used for this nick (doesn't get erased if + server gets disconnected) + unwanted - 1 if the other side closed or some error occured (DCC chats) + +Query +query_create(chat_type, server_tag, nick, automatic) + Create a new query. + +Query::destroy() + Destroy the query. + +Query::query_change_server(server) + Change the active server of the query. + +Query +query_find(nick) + Find query from any server. + +Query +Server::query_find(nick) + Find query from specified server. + + + *** Masks + +You should use the Server version of the function if possible, since +with different chat protocols the mask matching could be different. + +mask_match(mask, nick, user, host) +Server::mask_match(mask, nick, user, host) Return 1 if `mask' matches nick!user@host. -irc_mask_match_address(mask, nick, address) +mask_match_address(mask, nick, address) +Server::mask_match_address(mask, nick, address) Return 1 if `mask' matches nick!address. -irc_masks_match(masks, nick, address) +masks_match(masks, nick, address) +Server::masks_match(masks, nick, address) Return 1 if any mask in the `masks' (string separated with spaces) matches nick!address. + + *** Rawlog + +Rawlog +rawlog_create() + Create a new rawlog. + +Rawlog::destroy() + Destroy the rawlog. + +rawlog_set_size(lines) + Set the default rawlog size for new rawlogs. + +Rawlog::open(filename) + Start logging new messages in rawlog to specified file. + +Rawlog::close() + Stop logging to file. + +Rawlog::save(filename) + Save the current rawlog history to specified file. + +Rawlog::input(str) + Send `str' to raw log as input text. + +Rawlog::output(str) + Send `str' to raw log as output text. + +Rawlog::redirect(str) + Send `str' to raw log as redirection text. + + + *** Logging + +Log->{} + fname - Log file name + opened - Log file is open + level - Log only these levels + last - Timestamp when last message was written + autoopen - Automatically open log at startup + failed - Opening log failed last time + temp - Log isn't saved to config file + items - List of log items + +Logitem->{} + type - 0=target, 1=window refnum + name - Name + servertag - Server tag + +Log +log_create_rec(fname, level) + Create log file. + +Log::update() + Add log to list of logs / save changes to config file. + +Log +log_find(fname) + Find log with file name. + +Log::close() + Destroy log file. + +Log::start_logging() + Open log file and start logging. + +Log::stop_logging() + Close log file. + +Log::item_add(type, name, server) + Add log item to log. + +Log::item_destroy(item) + Remove log item from log. + +Logitem +Log::item_find(type, item, server) + Find item from log. + + + *** Ignores + +Ignore->{} + mask - Ignore mask + servertag - Ignore only in server + channels - Ignore only in channels (list of names) + pattern - Ignore text pattern + + level - Ignore level + except_level - Ignore exception levels + + regexp - Regexp pattern matching + fullword - Pattern matches only full words + +ignore_add_rec(ignore) + Add ignore record. + +ignore_update_rec(ignore) + Update ignore record in configuration + +ignore_check(nick, host, channel, text, level) +Server::ignore_check(nick, host, channel, text, level) + Return 1 if ignoring matched. + + + *** Channel modes + irc_get_mask(nick, host, flags) Create IRC mask from nick!host. flags = you need to combine these: @@ -345,54 +770,6 @@ irc_get_mask(nick, host, flags) IRC_MASK_HOST 0x04 IRC_MASK_DOMAIN 0x08 - - *** Channels - -Channel::values() - Get some information about channel. This function returns a reference to - hash table. Hash table has keys: - "server" - Server of the channel - "name" - Channel name - "type" - Channel type ("channel", "query", "dcc chat", "empty") - "topic" - Channel topic - "key" - Channel key (password) - "limit" - Max. users in channel (+l mode) - "level" - Channel's level number. - "new_data" - 0=no new data, 1=text, 2=msg, 3=msg for you - "synced" - Channel is synchronized - "wholist" - Channel has received /WHO list - "names_got" - Channel has received /NAMES list - "chanop" - You are channel operator - "left" - You just left the channel (for "channel destroyed" event) - "kicked" - You was just kicked out of the channel (for - "channel destroyed" event) - -Channel Server::channel_create(type, automatic) - Create new channel with name `channel'. `automatic' means that channel is - created "automatically", Irssi won't change the active window to it. - -Channel::destroy() - Destroy channel. - -Channel::change_name(name) - Change channel's name - -Channel::get_mode() - Return channel's mode - -Channel Server::channel_find(channel) - Find `channel' in server. - -Channel Server::channel_find_closest(channel, level) - Find `channel' or if not found, some other channel that has - level `level' (number). - -Channel channel_find_level(level) - Find channel with level `level'. - - - *** Channel modes - Ban::values() Get some information about ban. This function returns a reference to hash table. Hash table has keys: @@ -429,32 +806,6 @@ Channel::modes_set(data, mode) separated with spaces. - *** Nick list - -Nick::values() - Get some information about nick. This function returns a reference to - hash table. Hash table has keys: - "nick" - Plain nick - "host" - Host (blah@there.org) - "name" - Real name - "hops" - Hop count to the server nick is using - "op", "voice", "gone", "ircop" - 1 or 0 - "last_check" - timestamp when last checked gone/ircop status. - "send_massjoin" - Waiting to be sent in a "massjoin" signal - 1 or 0 - -Nick Channel::nicklist_insert(nick, op, voice, send_massjoin) - Add nick to nicklist. (!!) - -Channel::nicklist_remove(nick) - Remove nick from nicklist. (!!) - -Nick Channel::nicklist_find(mask) - Find nick from nicklist. - -Channel::nicklist_getnicks(channel) - Return a list of all nicks (Nick packages) in channel. - - *** DCC Dcc::values() @@ -500,25 +851,6 @@ Dcc item_get_dcc(item) If window item `item' is a query of a =nick, return DCC chat record of nick. - *** Reconnects - -Reconnect::values() - Get some information about reconnect. This function returns a reference to - hash table. Hash table has keys: - "tag" - Unique numeric tag - "next_connect" - Unix time stamp when the next connection occurs - - "address" - Address where we connected (irc.blah.org) - "port" - Port where we connected - "password" - Password we used in connection. - - "ircnet" - IRC network - "wanted_nick" - Nick which we would prefer to use - "alternate_nick" - Alternate nick which we would prefer to use - "username" - User name - "realname" - Real name - - *** Netsplits Netsplit::values() @@ -552,85 +884,6 @@ Server::notifylist_ison_server(nick) Check if `nick' is on IRC server. - *** Rawlog - -Server::rawlog_input(str) - Send `str' to raw log as input text. (!!) - -Server::rawlog_output(str) - Send `str' to raw log as output text. (!!) - -Server::rawlog_redirect(str) - Send `str' to raw log as redirection text. (!!) - - - *** Ignores - -Autoignore::values() - Get some information about autoignore. This function returns a reference to - hash table. Hash table has keys: - "nick" - Ignored nick - "timeleft" - Seconds left to ignore - "level" - Ignoring level number - -ignore_add(mask, level) - Ignore `mask' with level string - -ignore_remove(mask, level) - Unignore level string from `mask' - -Server::ignore_check(nick, host, type) - Return 1 if nick!host is ignored with level number `type'. - -Server::autoignore_add(type, nick) - Autoignore `nick' in server with level number `type'. - -Server::autoignore_remove(mask, level) - Remove autoignoring `nick' from server. `level' is a string. - - - *** Logging - -Log::values() - Get some information about log. This function returns a reference to - hash table. Hash table has keys: - "fname" - Log file name - "autoopen_log" - Automatically open log at startup - "last" - Timestamp when last write occured. - "level" - Global logging level. - /*FIXME: add list of Logitems;*/ - -Logitem::values() - Get some information about logitem. This function returns a reference to - hash table. Hash table has keys: - "name" - Log item name. - "level" - Logging level number. - -Log log_create(fname, data) - Create log file. `data' = logging level ("-all #channel +public") - -Log log_create_with_level(fname, level) - Create log file with level number. - -Log log_file_find(fname) - Find log file. - -Log::destroy() - Destroy log file - -Log::open() - Start logging - -Log::close() - Stop logging - -Log::append_item(name, level) - Append log item with level number `level' to log file. (!!) - -Log::remove_item(log, name) - Remove log item. (!!) - - *** Plugins Plugin::values() @@ -647,3 +900,37 @@ plugin_get_description(name) Plugin plugin_find(name) Find plugin. + + + *** IRC + +dccs() - return list of all dcc connections + +Server::send_raw(cmd) + Send raw message to server, it will be flood protected so you + don't need to worry about it. + +Server::irc_send_cmd_split(cmd, arg, max_nicks) + Split the `cmd' into several commands so `arg' argument has only + `max_nicks' number of nicks. + + Example: $server->irc_send_cmd_split("KICK #channel nick1,nick2,nick3 :byebye", 2, 2); + Irssi will send commands "KICK #channel nick1,nick2 :byebye" and + "KICK #channel nick3 :byebye" to server. + +Server::ctcp_send_reply(data) + Send CTCP reply. This will be "CTCP flood protected" so if there's too + many CTCP requests in buffer, this reply might not get sent. + +Autoignore::values() + Get some information about autoignore. This function returns a reference to + hash table. Hash table has keys: + "nick" - Ignored nick + "timeleft" - Seconds left to ignore + "level" - Ignoring level number + +Server::autoignore_add(type, nick) + Autoignore `nick' in server with level number `type'. + +Server::autoignore_remove(mask, level) + Remove autoignoring `nick' from server. `level' is a string. diff --git a/src/perl/common/Channel.xs b/src/perl/common/Channel.xs index 47e0a37a..b8fdecd0 100644 --- a/src/perl/common/Channel.xs +++ b/src/perl/common/Channel.xs @@ -17,6 +17,14 @@ CODE: OUTPUT: RETVAL +Irssi::Channel +channel_create(chat_type, name, automatic) + int chat_type + char *name + int automatic +CODE: + channel_create(chat_type, NULL, name, automatic); + #******************************* MODULE = Irssi PACKAGE = Irssi::Server #******************************* @@ -31,12 +39,21 @@ PPCODE: XPUSHs(sv_2mortal(irssi_bless((CHANNEL_REC *) tmp->data))); } +void +channels_join(server, channels, automatic) + Irssi::Server server + char *channels + int automatic +CODE: + server->channels_join(server, channels, automatic); + Irssi::Channel -channel_create(chat_type, server, name, automatic) - int chat_type +channel_create(server, name, automatic) Irssi::Server server char *name int automatic +CODE: + channel_create(server->chat_type, server, name, automatic); Irssi::Channel channel_find(server, name) @@ -44,7 +61,7 @@ channel_find(server, name) char *name void -nicklist_get_same(server, nick) +nicks_get_same(server, nick) Irssi::Server server char *nick PREINIT: diff --git a/src/perl/common/Core.xs b/src/perl/common/Core.xs index 52b3a0b7..dab69e94 100644 --- a/src/perl/common/Core.xs +++ b/src/perl/common/Core.xs @@ -318,12 +318,11 @@ PPCODE: } void -command_bind(cmd, category, func) +command_bind(cmd, func, category = "Perl scripts' commands") char *cmd char *category char *func CODE: - if (*category == '\0') category = "Perl scripts' commands"; perl_command_bind(cmd, category, func); void diff --git a/src/perl/common/Irssi.pm b/src/perl/common/Irssi.pm index b141821e..edb6aaff 100644 --- a/src/perl/common/Irssi.pm +++ b/src/perl/common/Irssi.pm @@ -13,7 +13,15 @@ require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); -@EXPORT = qw(INPUT_READ INPUT_WRITE); +@EXPORT = qw(INPUT_READ INPUT_WRITE + MSGLEVEL_CRAP MSGLEVEL_MSGS MSGLEVEL_PUBLIC MSGLEVEL_NOTICES + MSGLEVEL_SNOTES MSGLEVEL_CTCPS MSGLEVEL_ACTIONS MSGLEVEL_JOINS + MSGLEVEL_PARTS MSGLEVEL_QUITS MSGLEVEL_KICKS MSGLEVEL_MODES + MSGLEVEL_TOPICS MSGLEVEL_WALLOPS MSGLEVEL_INVITES MSGLEVEL_NICKS + MSGLEVEL_DCC MSGLEVEL_DCCMSGS MSGLEVEL_CLIENTNOTICE MSGLEVEL_CLIENTCRAP + MSGLEVEL_CLIENTERROR MSGLEVEL_HILIGHT MSGLEVEL_ALL MSGLEVEL_NOHILIGHT + MSGLEVEL_NO_ACT MSGLEVEL_NEVER MSGLEVEL_LASTLOG +); @EXPORT_OK = qw(); bootstrap Irssi $VERSION; diff --git a/src/perl/common/Log.xs b/src/perl/common/Log.xs index 5821ebaa..5a693c49 100644 --- a/src/perl/common/Log.xs +++ b/src/perl/common/Log.xs @@ -34,9 +34,9 @@ log_item_add(log, type, name, server) void log_item_destroy(log, item) Irssi::Log log - Irssi::LogItem item + Irssi::Logitem item -Irssi::LogItem +Irssi::Logitem log_item_find(log, type, item, server) Irssi::Log log int type diff --git a/src/perl/common/Query.xs b/src/perl/common/Query.xs index 3af0b8d0..139bd88b 100644 --- a/src/perl/common/Query.xs +++ b/src/perl/common/Query.xs @@ -11,6 +11,21 @@ PPCODE: XPUSHs(sv_2mortal(irssi_bless(rec))); } +Irssi::Query +query_create(chat_type, server_tag, nick, automatic) + int chat_type + char *server_tag + char *nick + int automatic + +Irssi::Query +query_find(nick) + char *nick +CODE: + RETVAL = query_find(NULL, nick); +OUTPUT: + RETVAL + #******************************* MODULE = Irssi PACKAGE = Irssi::Server #******************************* @@ -27,13 +42,6 @@ PPCODE: XPUSHs(sv_2mortal(irssi_bless(rec))); } -Irssi::Query -query_create(chat_type, server_tag, nick, automatic) - int chat_type - char *server_tag - char *nick - int automatic - Irssi::Query query_find(server, nick) Irssi::Server server diff --git a/src/perl/common/Rawlog.xs b/src/perl/common/Rawlog.xs index 34ace267..08827f62 100644 --- a/src/perl/common/Rawlog.xs +++ b/src/perl/common/Rawlog.xs @@ -7,26 +7,6 @@ rawlog_set_size(lines) Irssi::Rawlog rawlog_create() -#******************************* -MODULE = Irssi PACKAGE = Irssi::Server -#******************************* - -void -rawlog_input(rawlog, str) - Irssi::Rawlog rawlog - char *str - -void -rawlog_output(rawlog, str) - Irssi::Rawlog rawlog - char *str - -void -rawlog_redirect(rawlog, str) - Irssi::Rawlog rawlog - char *str - - #******************************* MODULE = Irssi PACKAGE = Irssi::Rawlog PREFIX = rawlog_ #******************************* diff --git a/src/perl/common/Server.xs b/src/perl/common/Server.xs index 6bbd7752..7454aa8f 100644 --- a/src/perl/common/Server.xs +++ b/src/perl/common/Server.xs @@ -88,14 +88,6 @@ CODE: (char *) SvPV(ST(n), n_a), (char *) SvPV(ST(n+1), n_a), (int) SvIV(ST(n+2))); } -void -channels_join(server, data, automatic) - Irssi::Server server - char *data - int automatic -CODE: - server->channels_join(server, data, automatic); - int isnickflag(server, flag) Irssi::Server server diff --git a/src/perl/common/Themes.xs b/src/perl/common/Themes.xs index 46958b63..47654fce 100644 --- a/src/perl/common/Themes.xs +++ b/src/perl/common/Themes.xs @@ -50,24 +50,6 @@ CODE: printformat_perl(&dest, format, arglist); -void -printformat_window(window, level, format, ...) - Irssi::Window window - int level - char *format -PREINIT: - TEXT_DEST_REC dest; - char *arglist[MAX_FORMAT_PARAMS]; - int n; -CODE: - format_create_dest(&dest, NULL, NULL, level, window); - memset(arglist, 0, sizeof(arglist)); - for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) { - arglist[n-3] = n < items ? SvPV(ST(n), PL_na) : ""; - } - - printformat_perl(&dest, format, arglist); - #******************************* MODULE = Irssi PACKAGE = Irssi::Server #******************************* @@ -91,6 +73,28 @@ CODE: printformat_perl(&dest, format, arglist); +#******************************* +MODULE = Irssi PACKAGE = Irssi::Window +#******************************* + +void +printformat(window, level, format, ...) + Irssi::Window window + int level + char *format +PREINIT: + TEXT_DEST_REC dest; + char *arglist[MAX_FORMAT_PARAMS]; + int n; +CODE: + format_create_dest(&dest, NULL, NULL, level, window); + memset(arglist, 0, sizeof(arglist)); + for (n = 3; n < 3+MAX_FORMAT_PARAMS; n++) { + arglist[n-3] = n < items ? SvPV(ST(n), PL_na) : ""; + } + + printformat_perl(&dest, format, arglist); + #******************************* MODULE = Irssi PACKAGE = Irssi::Windowitem #******************************* diff --git a/src/perl/common/Window.xs b/src/perl/common/Window.xs index db4bc6db..5f082d74 100644 --- a/src/perl/common/Window.xs +++ b/src/perl/common/Window.xs @@ -34,19 +34,10 @@ CODE: printtext_string(NULL, NULL, level, str); void -print_window(str, level=MSGLEVEL_CLIENTNOTICE) - char *str - int level; -CODE: - printtext_window(active_win, level, str); - -void -command(cmd, server=active_win->active_server, item=active_win->active) +command(cmd) char *cmd - Irssi::Server server - Irssi::Windowitem item CODE: - perl_command(cmd, server, item); + perl_command(cmd, active_win->active_server, active_win->active); Irssi::Window window_find_name(name) @@ -77,6 +68,14 @@ CODE: OUTPUT: RETVAL +Irssi::Window +window_find_item(name) + char *name +CODE: + RETVAL = window_find_item(NULL, name); +OUTPUT: + RETVAL + Irssi::Window window_find_closest(name, level) char *name @@ -86,20 +85,25 @@ CODE: OUTPUT: RETVAL +Irssi::Windowitem +window_item_find(name) + char *name +CODE: + RETVAL = window_item_find(NULL, name); +OUTPUT: + RETVAL + #******************************* MODULE = Irssi PACKAGE = Irssi::Server #******************************* void -command(server, cmd, item=active_win->active) +command(server, cmd) Irssi::Server server char *cmd - Irssi::Windowitem item CODE: - if (item != NULL && item->server != SERVER(server)) - item = NULL; - perl_command(cmd, server, item); + perl_command(cmd, server, active_win->active); void print(server, channel, str, level) @@ -107,18 +111,19 @@ print(server, channel, str, level) char *channel char *str int level -PREINIT: - char *fixed; CODE: - fixed = perl_fix_formats(str); - printtext(server, channel, level, fixed); - g_free(fixed); + printtext_string(server, channel, level, str); Irssi::Windowitem window_item_find(server, name) Irssi::Server server char *name +Irssi::Window +window_find_item(server, name) + Irssi::Server server + char *name + Irssi::Window window_find_level(server, level) Irssi::Server server @@ -148,13 +153,19 @@ PPCODE: } void -command(window, cmd, server=window->active_server, item=window->active) +print(window, str, level=MSGLEVEL_CLIENTNOTICE) + Irssi::Window window + char *str + int level; +CODE: + printtext_window(window, level, str); + +void +command(window, cmd) Irssi::Window window char *cmd - Irssi::Server server - Irssi::Windowitem item CODE: - perl_command(cmd, server, item); + perl_command(cmd, window->active_server, window->active); void window_item_add(window, item, automatic) @@ -163,18 +174,11 @@ window_item_add(window, item, automatic) int automatic void -window_item_remove(window, item) - Irssi::Window window +window_item_remove(item) Irssi::Windowitem item void -window_item_destroy(window, item) - Irssi::Window window - Irssi::Windowitem item - -void -window_item_set_active(window, item) - Irssi::Window window +window_item_destroy(item) Irssi::Windowitem item void @@ -217,11 +221,6 @@ char * window_get_active_name(window) Irssi::Window window -Irssi::Window -window_find_item(server, name) - Irssi::Server server - char *name - Irssi::Windowitem window_item_find(window, server, name) Irssi::Window window @@ -233,9 +232,17 @@ OUTPUT: RETVAL #******************************* -MODULE = Irssi PACKAGE = Irssi::Windowitem +MODULE = Irssi PACKAGE = Irssi::Windowitem PREFIX = window_item_ #******************************* +void +print(item, str, level=MSGLEVEL_CLIENTNOTICE) + Irssi::Windowitem item + int level + char *str +CODE: + printtext_string(item->server, item->name, level, str); + void command(item, cmd) Irssi::Windowitem item @@ -248,11 +255,6 @@ window_create(item, automatic) Irssi::Windowitem item int automatic -void -window_item_create(item, automatic) - Irssi::Windowitem item - int automatic - Irssi::Window window(item) Irssi::Windowitem item @@ -270,19 +272,8 @@ int window_item_is_active(item) Irssi::Windowitem item - -#******************************* -MODULE = Irssi PACKAGE = Irssi::Windowitem -#******************************* - void -print(item, str, level=MSGLEVEL_CLIENTNOTICE) +window_item_set_active(item) Irssi::Windowitem item - int level - char *str -PREINIT: - char *fixed; CODE: - fixed = perl_fix_formats(str); - printtext(item->server, item->name, level, fixed); - g_free(fixed); + window_item_set_active(window_item_window(item), item); diff --git a/src/perl/common/module.h b/src/perl/common/module.h index 5942bc2c..e355ac8a 100644 --- a/src/perl/common/module.h +++ b/src/perl/common/module.h @@ -36,7 +36,7 @@ typedef COMMAND_REC *Irssi__Command; typedef LOG_REC *Irssi__Log; -typedef LOG_ITEM_REC *Irssi__LogItem; +typedef LOG_ITEM_REC *Irssi__Logitem; typedef RAWLOG_REC *Irssi__Rawlog; typedef IGNORE_REC *Irssi__Ignore; typedef MODULE_REC *Irssi__Module; diff --git a/src/perl/common/typemap b/src/perl/common/typemap index 76bcd17d..5be3bcd0 100644 --- a/src/perl/common/typemap +++ b/src/perl/common/typemap @@ -9,7 +9,7 @@ Irssi::Command T_PlainObj Irssi::Nick T_IrssiObj Irssi::Ignore T_PlainObj Irssi::Log T_PlainObj -Irssi::LogItem T_PlainObj +Irssi::Logitem T_PlainObj Irssi::Rawlog T_PlainObj Irssi::Module T_PlainObj Irssi::Theme T_PlainObj diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index 25444a02..500d6145 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -188,7 +188,7 @@ void perl_connect_fill_hash(HV *hv, SERVER_CONNECT_REC *conn) void perl_server_fill_hash(HV *hv, SERVER_REC *server) { - char *type, *chat_type; + char *type; HV *stash; g_return_if_fail(hv != NULL); @@ -197,10 +197,7 @@ void perl_server_fill_hash(HV *hv, SERVER_REC *server) perl_connect_fill_hash(hv, server->connrec); type = "SERVER"; - chat_type = (char *) chat_protocol_find_id(server->chat_type)->name; - hv_store(hv, "type", 4, new_pv(type), 0); - hv_store(hv, "chat_type", 9, new_pv(chat_type), 0); hv_store(hv, "connect_time", 12, newSViv(server->connect_time), 0); hv_store(hv, "real_connect_time", 17, newSViv(server->real_connect_time), 0); @@ -350,7 +347,7 @@ void perl_log_fill_hash(HV *hv, LOG_REC *log) hv_store(hv, "failed", 6, newSViv(log->failed), 0); hv_store(hv, "temp", 4, newSViv(log->temp), 0); - stash = gv_stashpv("Irssi::LogItem", 0); + stash = gv_stashpv("Irssi::Logitem", 0); av = newAV(); for (tmp = log->items; tmp != NULL; tmp = tmp->next) { av_push(av, sv_2mortal(new_bless(tmp->data, stash))); @@ -382,7 +379,13 @@ void perl_rawlog_fill_hash(HV *hv, RAWLOG_REC *rawlog) void perl_reconnect_fill_hash(HV *hv, RECONNECT_REC *reconnect) { + char *type; + perl_connect_fill_hash(hv, reconnect->conn); + + type = "RECONNECT"; + hv_store(hv, "type", 4, new_pv(type), 0); + hv_store(hv, "tag", 3, newSViv(reconnect->tag), 0); hv_store(hv, "next_connect", 12, newSViv(reconnect->next_connect), 0); } @@ -561,7 +564,7 @@ void perl_common_init(void) { "Irssi::Command", (PERL_OBJECT_FUNC) perl_command_fill_hash }, { "Irssi::Ignore", (PERL_OBJECT_FUNC) perl_ignore_fill_hash }, { "Irssi::Log", (PERL_OBJECT_FUNC) perl_log_fill_hash }, - { "Irssi::LogItem", (PERL_OBJECT_FUNC) perl_log_item_fill_hash }, + { "Irssi::Logitem", (PERL_OBJECT_FUNC) perl_log_item_fill_hash }, { "Irssi::Rawlog", (PERL_OBJECT_FUNC) perl_rawlog_fill_hash }, { "Irssi::Reconnect", (PERL_OBJECT_FUNC) perl_rawlog_fill_hash }, { "Irssi::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash },