diff options
author | Timo Sirainen <cras@irssi.org> | 2001-01-07 09:54:21 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-01-07 09:54:21 +0000 |
commit | abcb44f835c5c5523709cc1ee76809bb6c749ffc (patch) | |
tree | f17944033351213d1fbff702607e02e761dde7c2 | |
parent | 3f1b28ead9a703d09d651e776fdb13e9c5d1ae57 (diff) | |
download | irssi-abcb44f835c5c5523709cc1ee76809bb6c749ffc.zip |
perl updates
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1089 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | docs/perl.txt | 301 | ||||
-rw-r--r-- | src/perl/Makefile.am | 1 | ||||
-rw-r--r-- | src/perl/irc/Bans.xs | 24 | ||||
-rw-r--r-- | src/perl/irc/Dcc.xs | 30 | ||||
-rw-r--r-- | src/perl/irc/Irc.xs | 18 | ||||
-rw-r--r-- | src/perl/irc/IrcServer.xs | 4 | ||||
-rw-r--r-- | src/perl/irc/Modes.xs | 24 | ||||
-rw-r--r-- | src/perl/irc/typemap | 1 |
8 files changed, 218 insertions, 185 deletions
diff --git a/docs/perl.txt b/docs/perl.txt index 1976fee7..cb51aafc 100644 --- a/docs/perl.txt +++ b/docs/perl.txt @@ -46,17 +46,15 @@ Irssi::signal_stop(); For example: --------------------------------------------------------- -sub event_privmsg { - # $data = "nick/#channel :text" - my ($server, $data, $nick, $address) = @_; - my ($target, $text) = split(/ :/, $data, 2); + sub event_privmsg { + # $data = "nick/#channel :text" + my ($server, $data, $nick, $address) = @_; + my ($target, $text) = split(/ :/, $data, 2); - Irssi::signal_stop() if ($text =~ /free.*porn/ || $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". Yes, you @@ -114,9 +112,10 @@ 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. +any chat protocol, and IRC specific commands. If you want to use IRC +specific commands, or use IRC specific ->{data} in your scripts, you'll +need to add "use Irssi::Irc" to your scripts. IRC specific commands are +listed after the generic ones. *** General @@ -759,178 +758,218 @@ Server::ignore_check(nick, host, channel, text, level) Return 1 if ignoring matched. - *** Channel modes + *** + *** IRC specific functions. All objects below this are prefixed with Irc:: + *** -irc_get_mask(nick, host, flags) - Create IRC mask from nick!host. - flags = you need to combine these: - (FIXME: export the IRC_xxx defines to perl (or something)) - IRC_MASK_NICK 0x01 - IRC_MASK_USER 0x02 - IRC_MASK_HOST 0x04 - IRC_MASK_DOMAIN 0x08 + *** IRC servers -Ban::values() - Get some information about ban. This function returns a reference to - hash table. Hash table has keys: - "ban" - The ban - "setby" - Nick of who set the ban - "time" - Timestamp when ban was set +Irc::Server->{} + (..contains all the same data as core Server object..) + real_address - Address the IRC server gives + usermode - User mode in server + userhost - Your user host in server -Ban Channel::ban_add(ban, nick, time) - Add new ban. (!!) +Irc::Connect->{} + (..contains all the same data as core Connect object..) + alternate_nick - Alternate nick to use if default nick is taken. -Channel::ban_remove(ban) - Remove ban. (!!) +Connect::connect() + Connect to IRC server. + +Server::get_channels(server) + Return a string of all channels (and keys, if any have them) in server, + like "#a,#b,#c,#d x,b_chan_key,x,x" or just "#e,#f,#g" -Ban Channel::ban_exception_add(ban, nick, time) - Add ban exception (!!) +Server::send_raw(cmd) + Send raw message to server, it will be flood protected so you + don't need to worry about it. -Channel::ban_exception_remove(ban) - Remove ban exception (!!) +Server::send_raw_now(cmd) + Send raw message to server immediately without flood protection. -Channel::invitelist_add(mask) - Add invite (!!) +Server::send_raw_split(cmd, nickarg, max_nicks) + Split the `cmd' into several commands so `nickarg' argument has only + `max_nicks' number of nicks. -Channel::invitelist_remove(mask) - Remove invite (!!) + Example: + $server->send_raw_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. -Channel::modes_parse_channel(setby, modestr) - Parse mode string (!!) + + *** IRC channels + +Ban->{} + ban - The ban + setby - Nick of who set the ban + time - Timestamp when ban was set + +Channel +Server::channel_create(name, automatic) + Create new channel. + +Channel::bans() + Return a list of bans in channel. + +Channel::ebans() + Return a list of ban exceptions in channel. + +Channel::invites() + Return invite list (+I) of channel. Channel::ban_get_mask(nick) Get ban mask for `nick'. -Channel::modes_set(data, mode) - Set mode `mode' ("+o", "-o", etc.) to all nicks in `data' - separated with spaces. +Channel::banlist_add(ban, nick, time) + Add a new ban to channel. + +Channel::banlist_remove(ban) + Remove a ban from channel. + +Channel::banlist_exception_add(ban, nick, time) + Add a new ban exception to channel. + +Channel::banlist_exception_remove(ban) + Remove a ban exception from channel. + +Channel::invitelist_add(mask) + Add a new invite mask to channel. + +Channel::invitelist_remove(mask) + Remove invite mask from channel. + +modes_join(old, mode, channel) + Add `mode' to `old' - return newly allocated mode. If `channel' is 1, + we're parsing channel mode and we should try to join mode arguments too. *** DCC -Dcc::values() - Get some information about nick. This function returns a reference to - hash table. Hash table has keys: - "type" - Type of the DCC: chat, send, get - "created" - Unix time stamp when the DCC record was created +Dcc->{} + type - Type of the DCC: chat, send, get + created - Time stamp when the DCC record was created + + server - Server where the DCC was initiated. + nick - Other side's nick name. + + chat - Dcc chat record if the request came through DCC chat + + ircnet - IRC network where the DCC was initiated. + mynick - Our nick to use in DCC chat. - "server" - Server where the DCC was initiated. - "chat" - DCC chat record if the request came through DCC chat - "ircnet" - IRC network where the DCC was initiated. - "mynick" - Our nick to use in DCC chat. + arg - Given argument .. file name usually + file - The real file name which we use. - "nick" - Other side's nick name. - "addr" - Other side's IP address. - "port" - Port we're connecting in. + addr - Other side's IP address. + port - Port we're connecting in. - "arg" - Given argument .. file name usually - "file" - The real file name which we use. + size - File size + transfd - Bytes transferred + skipped - Bytes skipped from start (resuming file) + starttime - Unix time stamp when the DCC transfer was started - "size" - File size - "transfd" - Bytes transferred - "skipped" - Bytes skipped from start (resuming file) - "starttime" - Unix time stamp when the DCC transfer was started +dccs() - return list of all dcc connections Dcc::destroy() - Destroy DCC connection. (!!) + Destroy DCC connection. -Dcc dcc_find_item(type, nick, arg) +Dcc +dcc_find_item(type, nick, arg) Find DCC connection. -Dcc dcc_find_by_port(nick, port) +Dcc +dcc_find_by_port(nick, port) Find DCC connection by port. -dcc_ctcp_message(target, server, chat, notice, msg) - Send a CTCP message/notify to target. Send the CTCP via DCC chat if - `chat' is specified. +Dcc +Windowitem::get_dcc(item) + If `item' is a query of a =nick, return DCC chat record of nick. -Dcc::dcc_chat_send(data) +Dcc::chat_send(data) Send `data' to dcc chat. -Dcc item_get_dcc(item) - If window item `item' is a query of a =nick, return DCC chat record - of nick. +Server::dcc_ctcp_message(target, notice, msg) +Dcc::ctcp_message(target, notice, msg) + Send a CTCP message/notify to target. + *** Netsplits -Netsplit::values() - Get some information about netsplit. This function returns a reference to - hash table. Hash table has keys: - "nick" - Nick - "address" - Nick's host - "server" - The server nick was in - "destserver" - The other server where split occured. - "destroy" - Timestamp when this record should be destroyed - /*FIXME: add list of channels the nick was in;*/ - -Netsplit Server::netsplit_find(nick, address) +Netsplit->{} + nick - Nick + address - Nick's host + destroy - Timestamp when this record should be destroyed + server - Netsplitserver object + channels - list of channels (Netsplitchannel objects) the nick was in + +Netsplitserver->{} + server - The server nick was in + destserver - The other server where split occured. + count - Number of splits in server + +Netsplitchannel->{} + name - Channel name + nick - Nick object + +Netsplit +Server::netsplit_find(nick, address) Check if nick!address is on the other side of netsplit. Netsplit records are automatically removed after 30 minutes (current default).. -Nick Server::netsplit_find_channel(nick, address, channel) +Nick +Server::netsplit_find_channel(nick, address, channel) Find nick record for nick!address in channel `channel'. *** Notify list -notifylist_add(nick, ircnet) - Add `nick' to notify list in irc network `ircnet' - -Server notifylist_ison(nick, ircnets) - Check if `nick' is in IRC. `ircnets' is a space separated - list of irc networks. If it's empty string, all servers will be checked. - -Server::notifylist_ison_server(nick) - Check if `nick' is on IRC server. - - - *** Plugins +Notifylist->{} + mask - Notify nick mask + away_check - Notify away status changes + idle_check_time - Notify when idle time is reset and idle was bigger + than this (seconds) + ircnets - List of ircnets (strings) the notify is checked -Plugin::values() - Get some information about plugin. This function returns a reference to - hash table. Hash table has keys: - "name" - Plugin name - "description" - Plugin description +notifies() - Return list of all notifies -plugin_load(name, args) - Load plugin. +Notifylist +notifylist_add(mask, ircnets, away_check, idle_check_time) + Add new item to notify list. -plugin_get_description(name) - Get plugin description string. +notifylist_remove(mask) + Remove item from notify list. -Plugin plugin_find(name) - Find plugin. +Notifylist +notifylist_find(mask, ircnet) + Find notify. +Server +notifylist_ison(nick, serverlist) + Check if `nick' is in IRC. `serverlist' is a space separated + list of server tags. If it's empty string, all servers will be checked. - *** 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::notifylist_ison_server(nick) + Check if `nick' is on IRC server. -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. +Notifylist::ircnets_match(ircnet) + Returns 1 if notify is checked in `ircnet'. - 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. + *** Autoignoring -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 +Autoignore->{} + 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_add(nick, level) + Add new autoignore. Server::autoignore_remove(mask, level) - Remove autoignoring `nick' from server. `level' is a string. + Remove autoignore. diff --git a/src/perl/Makefile.am b/src/perl/Makefile.am index c97a4cc9..5879386c 100644 --- a/src/perl/Makefile.am +++ b/src/perl/Makefile.am @@ -61,7 +61,6 @@ CORE_SOURCES = \ common/module.h IRC_SOURCES = \ - irc/Bans.xs \ irc/Dcc.xs \ irc/Flood.xs \ irc/IrcChannel.xs \ diff --git a/src/perl/irc/Bans.xs b/src/perl/irc/Bans.xs deleted file mode 100644 index 5412018d..00000000 --- a/src/perl/irc/Bans.xs +++ /dev/null @@ -1,24 +0,0 @@ -MODULE = Irssi::Irc PACKAGE = Irssi::Irc - -void -ban_set_type(type) - char *type - -#******************************* -MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Channel -#******************************* - -char * -ban_get_mask(channel, nick) - Irssi::Irc::Channel channel - char *nick - -void -ban_set(channel, bans) - Irssi::Irc::Channel channel - char *bans - -void -ban_remove(channel, ban) - Irssi::Irc::Channel channel - char *ban diff --git a/src/perl/irc/Dcc.xs b/src/perl/irc/Dcc.xs index 4a68f4e1..222c80e4 100644 --- a/src/perl/irc/Dcc.xs +++ b/src/perl/irc/Dcc.xs @@ -22,23 +22,41 @@ dcc_find_by_port(nick, port) char *nick int port +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Windowitem PREFIX = item_ +#******************************* + +Irssi::Irc::Dcc +item_get_dcc(item) + Irssi::Windowitem item + +#******************************* +MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server +#******************************* + void -dcc_ctcp_message(server, target, chat, notice, msg) +dcc_ctcp_message(server, target, notice, msg) Irssi::Irc::Server server char *target - Irssi::Irc::Dcc chat int notice char *msg - -Irssi::Irc::Dcc -item_get_dcc(item) - void *item +CODE: + dcc_ctcp_message(server, target, NULL, notice, msg); #******************************* MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Dcc PREFIX = dcc_ #******************************* void +dcc_ctcp_message(chat, target, notice, msg) + Irssi::Irc::Dcc chat + char *target + int notice + char *msg +CODE: + dcc_ctcp_message(chat->server, target, chat, notice, msg); + +void dcc_destroy(dcc) Irssi::Irc::Dcc dcc diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs index 58c417aa..d8122a90 100644 --- a/src/perl/irc/Irc.xs +++ b/src/perl/irc/Irc.xs @@ -52,7 +52,9 @@ static void perl_dcc_fill_hash(HV *hv, DCC_REC *dcc) static void perl_netsplit_fill_hash(HV *hv, NETSPLIT_REC *netsplit) { + AV *av; HV *stash; + GSList *tmp; hv_store(hv, "nick", 4, new_pv(netsplit->nick), 0); hv_store(hv, "address", 7, new_pv(netsplit->address), 0); @@ -60,7 +62,13 @@ static void perl_netsplit_fill_hash(HV *hv, NETSPLIT_REC *netsplit) stash = gv_stashpv("Irssi::Irc::Netsplitserver", 0); hv_store(hv, "server", 6, new_bless(netsplit->server, stash), 0); - /*FIXME: add GSList *channels;*/ + + stash = gv_stashpv("Irssi::Irc::Netsplitchannel", 0); + av = newAV(); + for (tmp = netsplit->channels; tmp != NULL; tmp = tmp->next) { + av_push(av, sv_2mortal(new_bless(tmp->data, stash))); + } + hv_store(hv, "channels", 7, newRV_noinc((SV*)av), 0); } static void perl_netsplit_server_fill_hash(HV *hv, NETSPLIT_SERVER_REC *rec) @@ -70,6 +78,12 @@ static void perl_netsplit_server_fill_hash(HV *hv, NETSPLIT_SERVER_REC *rec) hv_store(hv, "count", 5, newSViv(rec->count), 0); } +static void perl_netsplit_channel_fill_hash(HV *hv, NETSPLIT_CHANNEL_REC *rec) +{ + hv_store(hv, "name", 4, new_pv(rec->name), 0); + hv_store(hv, "nick", 4, irssi_bless(rec->nick), 0); +} + static void perl_autoignore_fill_hash(HV *hv, AUTOIGNORE_REC *ai) { hv_store(hv, "nick", 4, new_pv(ai->nick), 0); @@ -98,6 +112,7 @@ static PLAIN_OBJECT_INIT_REC irc_plains[] = { { "Irssi::Irc::Dcc", (PERL_OBJECT_FUNC) perl_dcc_fill_hash }, { "Irssi::Irc::Netsplit", (PERL_OBJECT_FUNC) perl_netsplit_fill_hash }, { "Irssi::Irc::Netsplitserver", (PERL_OBJECT_FUNC) perl_netsplit_server_fill_hash }, + { "Irssi::Irc::Netsplitchannel", (PERL_OBJECT_FUNC) perl_netsplit_channel_fill_hash }, { "Irssi::Irc::Autoignore", (PERL_OBJECT_FUNC) perl_autoignore_fill_hash }, { "Irssi::Irc::Notifylist", (PERL_OBJECT_FUNC) perl_notifylist_fill_hash }, @@ -127,7 +142,6 @@ CODE: (PERL_OBJECT_FUNC) perl_irc_server_fill_hash); irssi_add_plains(irc_plains); -INCLUDE: Bans.xs INCLUDE: IrcServer.xs INCLUDE: IrcChannel.xs INCLUDE: IrcQuery.xs diff --git a/src/perl/irc/IrcServer.xs b/src/perl/irc/IrcServer.xs index 9ee76c2f..1ceff0c2 100644 --- a/src/perl/irc/IrcServer.xs +++ b/src/perl/irc/IrcServer.xs @@ -27,6 +27,10 @@ send_raw_split(server, cmd, nickarg, max_nicks) CODE: irc_send_cmd_split(server, cmd, nickarg, max_nicks); +void +ctcp_send_reply(server, data) + Irssi::Irc::Server server + char *data MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Connect PREFIX = irc_server_ diff --git a/src/perl/irc/Modes.xs b/src/perl/irc/Modes.xs index 86cb0144..671d6f09 100644 --- a/src/perl/irc/Modes.xs +++ b/src/perl/irc/Modes.xs @@ -7,31 +7,13 @@ modes_join(old, mode, channel) int channel #******************************* -MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server -#******************************* - -void -channel_set_singlemode(server, channel, nicks, mode) - Irssi::Irc::Server server - char *channel - char *nicks - char *mode - -void -channel_set_mode(server, channel, mode) - Irssi::Irc::Server server - char *channel - char *mode - -#******************************* MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Channel PREFIX = channel_ #******************************* -void -parse_channel_modes(channel, setby, modestr) +char * +ban_get_mask(channel, nick) Irssi::Irc::Channel channel - char *setby - char *modestr + char *nick Irssi::Irc::Ban banlist_add(channel, ban, nick, time) diff --git a/src/perl/irc/typemap b/src/perl/irc/typemap index 928eceb6..ec670a57 100644 --- a/src/perl/irc/typemap +++ b/src/perl/irc/typemap @@ -9,6 +9,7 @@ Irssi::Irc::Ban T_PlainObj Irssi::Irc::Dcc T_PlainObj Irssi::Irc::Netsplit T_PlainObj Irssi::Irc::Netsplitserver T_PlainObj +Irssi::Irc::Netsplitchannel T_PlainObj Irssi::Irc::Autoignore T_PlainObj Irssi::Irc::Notifylist T_PlainObj |