diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-03-25 10:39:07 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-03-25 10:39:07 +0100 |
commit | e59bbbb40a61379646edddb631f77bebe5dacf31 (patch) | |
tree | fe58f6b66510160df14f6e2fcc1ee1dff8c7f5d0 | |
parent | 96e6ae3fc31470db029ed99e3b55693f60a11067 (diff) | |
download | weechat-e59bbbb40a61379646edddb631f77bebe5dacf31.zip |
Add "irc_is_nick" for function info_get to check if a string is a valid IRC nick name (patch #7133)
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | doc/en/autogen/plugin_api/infos.txt | 4 | ||||
-rw-r--r-- | doc/fr/autogen/plugin_api/infos.txt | 4 | ||||
-rw-r--r-- | doc/it/autogen/plugin_api/infos.txt | 4 | ||||
-rw-r--r-- | po/cs.po | 15 | ||||
-rw-r--r-- | po/de.po | 15 | ||||
-rw-r--r-- | po/es.po | 17 | ||||
-rw-r--r-- | po/fr.po | 17 | ||||
-rw-r--r-- | po/hu.po | 16 | ||||
-rw-r--r-- | po/it.po | 15 | ||||
-rw-r--r-- | po/pl.po | 17 | ||||
-rw-r--r-- | po/ru.po | 16 | ||||
-rw-r--r-- | po/weechat.pot | 13 | ||||
-rw-r--r-- | src/plugins/irc/irc-info.c | 11 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 29 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.h | 3 |
16 files changed, 144 insertions, 56 deletions
@@ -1,7 +1,7 @@ WeeChat ChangeLog ================= FlashCode <flashcode@flashtux.org> -v0.3.2-dev, 2010-03-24 +v0.3.2-dev, 2010-03-25 Version 0.3.2 (under dev!) @@ -31,6 +31,8 @@ Version 0.3.2 (under dev!) * gui: fix bug with cursor when position is last char of terminal * api: add "version_number" for function info_get to get WeeChat version as number +* api: add "irc_is_nick" for function info_get to check if a string is a valid + IRC nick name (patch #7133) * api: add functions "string_encode_base64" and "string_decode_base64", fix bug with base64 encoding * api: add functions "string_match", "string_has_highlight" and diff --git a/doc/en/autogen/plugin_api/infos.txt b/doc/en/autogen/plugin_api/infos.txt index 32933937c..c674f7485 100644 --- a/doc/en/autogen/plugin_api/infos.txt +++ b/doc/en/autogen/plugin_api/infos.txt @@ -6,7 +6,9 @@ | irc | irc_buffer | get buffer pointer for an IRC server/channel/nick | server,channel,nick (channel and nicks are optional) -| irc | irc_is_channel | 1 if string is an IRC channel | channel name +| irc | irc_is_channel | 1 if string is a valid IRC channel name | channel name + +| irc | irc_is_nick | 1 if string is a valid IRC nick name | nickname | irc | irc_nick | get current nick on a server | server name diff --git a/doc/fr/autogen/plugin_api/infos.txt b/doc/fr/autogen/plugin_api/infos.txt index cead0fda5..3f7c48121 100644 --- a/doc/fr/autogen/plugin_api/infos.txt +++ b/doc/fr/autogen/plugin_api/infos.txt @@ -6,7 +6,9 @@ | irc | irc_buffer | retourne le pointeur vers le tampon pour un serveur/canal/pseudo IRC | serveur,canal,pseudo (canal et pseudo sont optionnels) -| irc | irc_is_channel | 1 si la chaîne est un canal IRC | nom de canal +| irc | irc_is_channel | 1 si la chaîne est un nom de canal IRC valide | nom de canal + +| irc | irc_is_nick | 1 si la chaîne est un pseudo IRC valide | pseudo | irc | irc_nick | retourne le pseudo utilisé actuellement sur un serveur | nom de serveur diff --git a/doc/it/autogen/plugin_api/infos.txt b/doc/it/autogen/plugin_api/infos.txt index e697c3540..caaaa2b54 100644 --- a/doc/it/autogen/plugin_api/infos.txt +++ b/doc/it/autogen/plugin_api/infos.txt @@ -6,7 +6,9 @@ | irc | irc_buffer | ottiene puntatore al buffer per un server/canale/nick IRC | server,canale,nick (canale e nick sono opzionali) -| irc | irc_is_channel | 1 se la stringa è un canale IRC | nome canale +| irc | irc_is_channel | 1 if string is a valid IRC channel name | nome canale + +| irc | irc_is_nick | 1 if string is a valid IRC nick name | nick | irc | irc_nick | ottiene nick corrente su un server | nome server @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: 2010-03-23 10:19+0100\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4533,12 +4533,20 @@ msgstr[0] "kanál" msgstr[1] "kanály" msgstr[2] "kanálů" -msgid "1 if string is an IRC channel" +#, fuzzy +msgid "1 if string is a valid IRC channel name" msgstr "1 pokud je řetězec IRC kanál" msgid "channel name" msgstr "jméno kanálu" +#, fuzzy +msgid "1 if string is a valid IRC nick name" +msgstr "1 pokud je řetězec IRC kanál" + +msgid "nickname" +msgstr "přezdívka" + msgid "get current nick on a server" msgstr "získat aktuální přezdívku na serveru" @@ -4554,9 +4562,6 @@ msgstr "IRC host (jako `:nick!name@server.com`)" msgid "get nick color" msgstr "získat barvu barva přezdívky" -msgid "nickname" -msgstr "přezdívka" - msgid "get buffer pointer for an IRC server/channel/nick" msgstr "získat ukazatel bufferu pro IRC server/kanál/přezdívku" @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: 2010-03-23 15:44+0100\n" "Last-Translator: Nils G <weechatter@arcor.de>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4734,12 +4734,20 @@ msgid_plural "channels" msgstr[0] "Channel" msgstr[1] "Channels" -msgid "1 if string is an IRC channel" +#, fuzzy +msgid "1 if string is a valid IRC channel name" msgstr "1, falls die Zeichenkette ein IRC-Channel ist" msgid "channel name" msgstr "Channelname" +#, fuzzy +msgid "1 if string is a valid IRC nick name" +msgstr "1, falls die Zeichenkette ein IRC-Channel ist" + +msgid "nickname" +msgstr "Nickname" + msgid "get current nick on a server" msgstr "Aktuellen Nicknamen für den Server erhalten" @@ -4755,9 +4763,6 @@ msgstr "IRC host (in der Form `:nick!name@server.com`)" msgid "get nick color" msgstr "Hole Farbe für Nick" -msgid "nickname" -msgstr "Nickname" - msgid "get buffer pointer for an IRC server/channel/nick" msgstr "hole Buffer Pointer für einen IRC Server/Channel/Nick" @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: 2010-03-23 10:20+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4576,13 +4576,22 @@ msgid_plural "channels" msgstr[0] "canal" msgstr[1] "canales" -msgid "1 if string is an IRC channel" +#, fuzzy +msgid "1 if string is a valid IRC channel name" msgstr "1 si la cadena es un canal IRC" #, fuzzy msgid "channel name" msgstr "canal modo" +#, fuzzy +msgid "1 if string is a valid IRC nick name" +msgstr "1 si la cadena es un canal IRC" + +#, fuzzy +msgid "nickname" +msgstr "[-all] apodo" + msgid "get current nick on a server" msgstr "devuelve el apodo actual en el servidor" @@ -4600,10 +4609,6 @@ msgid "get nick color" msgstr "obtiene el color del apodo" #, fuzzy -msgid "nickname" -msgstr "[-all] apodo" - -#, fuzzy msgid "get buffer pointer for an IRC server/channel/nick" msgstr "devuelve el puntero del buffer de un canal/servidor IRC" @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" -"PO-Revision-Date: 2010-03-24 19:39+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" +"PO-Revision-Date: 2010-03-25 10:24+0100\n" "Last-Translator: FlashCode <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "MIME-Version: 1.0\n" @@ -4683,12 +4683,18 @@ msgid_plural "channels" msgstr[0] "canal" msgstr[1] "canaux" -msgid "1 if string is an IRC channel" -msgstr "1 si la chaîne est un canal IRC" +msgid "1 if string is a valid IRC channel name" +msgstr "1 si la chaîne est un nom de canal IRC valide" msgid "channel name" msgstr "nom de canal" +msgid "1 if string is a valid IRC nick name" +msgstr "1 si la chaîne est un pseudo IRC valide" + +msgid "nickname" +msgstr "pseudo" + msgid "get current nick on a server" msgstr "retourne le pseudo utilisé actuellement sur un serveur" @@ -4704,9 +4710,6 @@ msgstr "host IRC (comme `:pseudo!nom@serveur.com`)" msgid "get nick color" msgstr "retourne la couleur du pseudo" -msgid "nickname" -msgstr "pseudo" - msgid "get buffer pointer for an IRC server/channel/nick" msgstr "retourne le pointeur vers le tampon pour un serveur/canal/pseudo IRC" @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: 2010-03-23 10:20+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4409,7 +4409,7 @@ msgstr[0] "%d szoba" msgstr[1] "%d szoba" #, fuzzy -msgid "1 if string is an IRC channel" +msgid "1 if string is a valid IRC channel name" msgstr "felhasználók listája a szobában" #, fuzzy @@ -4417,6 +4417,14 @@ msgid "channel name" msgstr "%d szoba" #, fuzzy +msgid "1 if string is a valid IRC nick name" +msgstr "felhasználók listája a szobában" + +#, fuzzy +msgid "nickname" +msgstr "[-all] név" + +#, fuzzy msgid "get current nick on a server" msgstr "aktuális név megváltoztatása" @@ -4436,10 +4444,6 @@ msgid "get nick color" msgstr "üzenetek színe" #, fuzzy -msgid "nickname" -msgstr "[-all] név" - -#, fuzzy msgid "get buffer pointer for an IRC server/channel/nick" msgstr "szobák listája ahová be akarunk lépni csatlakozás után" @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Weechat 0.3.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: 2010-03-24 14:20+0100\n" "Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4639,12 +4639,20 @@ msgid_plural "channels" msgstr[0] "canale" msgstr[1] "canali" -msgid "1 if string is an IRC channel" +#, fuzzy +msgid "1 if string is a valid IRC channel name" msgstr "1 se la stringa è un canale IRC" msgid "channel name" msgstr "nome canale" +#, fuzzy +msgid "1 if string is a valid IRC nick name" +msgstr "1 se la stringa è un canale IRC" + +msgid "nickname" +msgstr "nick" + msgid "get current nick on a server" msgstr "ottiene nick corrente su un server" @@ -4660,9 +4668,6 @@ msgstr "host IRC (come `:nick!nome@server.com`)" msgid "get nick color" msgstr "riceve colore del nick" -msgid "nickname" -msgstr "nick" - msgid "get buffer pointer for an IRC server/channel/nick" msgstr "ottiene puntatore al buffer per un server/canale/nick IRC" @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.0-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: 2010-03-23 10:20+0100\n" "Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n" "Language-Team: Polish\n" @@ -4571,13 +4571,22 @@ msgstr[0] "kanał" msgstr[1] "kanały" msgstr[2] "kanałów" -msgid "1 if string is an IRC channel" +#, fuzzy +msgid "1 if string is a valid IRC channel name" msgstr "1 jeśli ciąg jest w kanale IRC" #, fuzzy msgid "channel name" msgstr "kanał atrybuty" +#, fuzzy +msgid "1 if string is a valid IRC nick name" +msgstr "1 jeśli ciąg jest w kanale IRC" + +#, fuzzy +msgid "nickname" +msgstr "[-all] nick" + msgid "get current nick on a server" msgstr "pobiera aktualny nick z serwera" @@ -4595,10 +4604,6 @@ msgid "get nick color" msgstr "pobiera kolor nicka" #, fuzzy -msgid "nickname" -msgstr "[-all] nick" - -#, fuzzy msgid "get buffer pointer for an IRC server/channel/nick" msgstr "pobiera wskaźnik bufora kanału/serwera IRC" @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: 2010-03-23 10:20+0100\n" "Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -4411,7 +4411,7 @@ msgstr[1] "%d каналов" msgstr[2] "%d каналов" #, fuzzy -msgid "1 if string is an IRC channel" +msgid "1 if string is a valid IRC channel name" msgstr "список ников на канале" #, fuzzy @@ -4419,6 +4419,14 @@ msgid "channel name" msgstr "%d канал" #, fuzzy +msgid "1 if string is a valid IRC nick name" +msgstr "список ников на канале" + +#, fuzzy +msgid "nickname" +msgstr "[-all] ник" + +#, fuzzy msgid "get current nick on a server" msgstr "сменить текущий ник" @@ -4438,10 +4446,6 @@ msgid "get nick color" msgstr "цвет чата" #, fuzzy -msgid "nickname" -msgstr "[-all] ник" - -#, fuzzy msgid "get buffer pointer for an IRC server/channel/nick" msgstr "Список каналов, на которые заходить при соединении с сервером" diff --git a/po/weechat.pot b/po/weechat.pot index 1a82db401..c4d88f53a 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-03-24 19:36+0100\n" +"POT-Creation-Date: 2010-03-25 10:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -3771,12 +3771,18 @@ msgid_plural "channels" msgstr[0] "" msgstr[1] "" -msgid "1 if string is an IRC channel" +msgid "1 if string is a valid IRC channel name" msgstr "" msgid "channel name" msgstr "" +msgid "1 if string is a valid IRC nick name" +msgstr "" + +msgid "nickname" +msgstr "" + msgid "get current nick on a server" msgstr "" @@ -3792,9 +3798,6 @@ msgstr "" msgid "get nick color" msgstr "" -msgid "nickname" -msgstr "" - msgid "get buffer pointer for an IRC server/channel/nick" msgstr "" diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c index 0ae8ca560..3b45730cb 100644 --- a/src/plugins/irc/irc-info.c +++ b/src/plugins/irc/irc-info.c @@ -79,6 +79,12 @@ irc_info_get_info_cb (void *data, const char *info_name, return str_true; return NULL; } + else if (weechat_strcasecmp (info_name, "irc_is_nick") == 0) + { + if (irc_nick_is_nick (arguments)) + return str_true; + return NULL; + } else if (weechat_strcasecmp (info_name, "irc_nick") == 0) { ptr_server = irc_server_search (arguments); @@ -396,9 +402,12 @@ void irc_info_init () { /* info hooks */ - weechat_hook_info ("irc_is_channel", N_("1 if string is an IRC channel"), + weechat_hook_info ("irc_is_channel", N_("1 if string is a valid IRC channel name"), N_("channel name"), &irc_info_get_info_cb, NULL); + weechat_hook_info ("irc_is_nick", N_("1 if string is a valid IRC nick name"), + N_("nickname"), + &irc_info_get_info_cb, NULL); weechat_hook_info ("irc_nick", N_("get current nick on a server"), N_("server name"), &irc_info_get_info_cb, NULL); diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 576f532d0..29b0b38e2 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -57,6 +57,35 @@ irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick) } /* + * irc_nick_is_nick: check if string is a valid nick string (RFC 1459) + * return 1 if string valid nick + * 0 if not a valid nick + */ + +int +irc_nick_is_nick (const char *string) +{ + const char *ptr; + + if (!string || !string[0]) + return 0; + + /* first char must not be a number or hyphen */ + ptr = string; + if (strchr ("0123456789-", *ptr)) + return 0; + + while (ptr && ptr[0]) + { + if (!strchr (IRC_NICK_VALID_CHARS, *ptr)) + return 0; + ptr++; + } + + return 1; +} + +/* * irc_nick_find_color: find a color for a nick (according to nick letters) */ diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h index adad7d957..f27ab1973 100644 --- a/src/plugins/irc/irc-nick.h +++ b/src/plugins/irc/irc-nick.h @@ -21,6 +21,8 @@ #define __WEECHAT_IRC_NICK_H 1 #define IRC_NICK_DEFAULT_PREFIXES_LIST "@%+~&!-" +#define IRC_NICK_VALID_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHI" \ + "JKLMNOPQRSTUVWXYZ0123456789-[]\\`_^{|}" #define IRC_NICK_CHANOWNER 1 #define IRC_NICK_CHANADMIN 2 @@ -61,6 +63,7 @@ struct t_irc_nick extern int irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick); +extern int irc_nick_is_nick (const char *string); extern const char *irc_nick_find_color (const char *nickname); extern void irc_nick_get_gui_infos (struct t_irc_nick *nick, char *prefix, int *prefix_color, |