1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

irc: add option irc.look.ban_mask_default (bug #26571)

This commit is contained in:
Sebastien Helleu
2013-12-07 22:02:05 +01:00
parent f6a80141b7
commit 1aeeecb82d
23 changed files with 228 additions and 23 deletions
+1
View File
@@ -49,6 +49,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* aspell: fix detection of nicks with non-alphanumeric chars
* guile: disable guile gmp allocator (fix crash on unload of relay plugin)
(bug #40628)
* irc: add option irc.look.ban_mask_default (bug #26571)
* irc: add option irc.network.lag_max
* irc: fix ignore on a host without nick
* irc: use color code 0x1F (`ctrl-_`) for underlined text in input line (same
+5
View File
@@ -63,6 +63,11 @@
** Typ: Farbe
** Werte: ein Farbname für WeeChat (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), eine Terminal-Farbnummer oder ein Alias; Attribute können vor eine Farbe gesetzt werden (gilt ausschließlich für die Textfarbe und nicht für den Hintergrund): "*" für fett, "!" für invertiert, "/" für kursiv, "_" für unterstrichen (Standardwert: `darkgray`)
* [[option_irc.look.ban_mask_default]] *irc.look.ban_mask_default*
** Beschreibung: `default ban mask for commands /ban, /unban and /kickban; variables $nick, $user and $host are replaced by their values (extracted from "nick!user@host"); this default mask is used only if WeeChat knows the host for the nick`
** Typ: Zeichenkette
** Werte: beliebige Zeichenkette (Standardwert: `"*!$user@$host"`)
* [[option_irc.look.buffer_switch_autojoin]] *irc.look.buffer_switch_autojoin*
** Beschreibung: `wechselt automatisch zum Channel-Buffer falls dieser automatisch betreten wurde (mittels der Serveroption "autojoin")`
** Typ: boolesch
+5
View File
@@ -63,6 +63,11 @@
** type: color
** values: a WeeChat color name (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a terminal color number or an alias; attributes are allowed before color (for text color only, not background): "*" for bold, "!" for reverse, "/" for italic, "_" for underline (default value: `darkgray`)
* [[option_irc.look.ban_mask_default]] *irc.look.ban_mask_default*
** description: `default ban mask for commands /ban, /unban and /kickban; variables $nick, $user and $host are replaced by their values (extracted from "nick!user@host"); this default mask is used only if WeeChat knows the host for the nick`
** type: string
** values: any string (default value: `"*!$user@$host"`)
* [[option_irc.look.buffer_switch_autojoin]] *irc.look.buffer_switch_autojoin*
** description: `auto switch to channel buffer when it is auto joined (with server option "autojoin")`
** type: boolean
+5
View File
@@ -63,6 +63,11 @@
** type: couleur
** valeurs: un nom de couleur WeeChat (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), un numéro de couleur du terminal ou un alias; des attributs sont autorisés avant la couleur (seulement pour la couleur du texte, pas le fond) : "*" pour le gras, "!" pour la vidéo inverse, "/" pour l'italique, "_" pour le souligné (valeur par défaut: `darkgray`)
* [[option_irc.look.ban_mask_default]] *irc.look.ban_mask_default*
** description: `masque de bannissement par défaut pour les commandes /ban, /unban et /kickban; les variables $nick, $user et $host sont remplacées par leurs valeurs (extraites de "nick!user@host"); ce masque par défaut est utilisé seulement si WeeChat connaît l'hôte pour le pseudo`
** type: chaîne
** valeurs: toute chaîne (valeur par défaut: `"*!$user@$host"`)
* [[option_irc.look.buffer_switch_autojoin]] *irc.look.buffer_switch_autojoin*
** description: `basculer automatiquement vers le tampon du canal lorsqu'il est automatiquement rejoint (avec l'option du serveur "autojoin")`
** type: booléen
+5
View File
@@ -63,6 +63,11 @@
** tipo: colore
** valori: a WeeChat color name (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a terminal color number or an alias; attributes are allowed before color (for text color only, not background): "*" for bold, "!" for reverse, "/" for italic, "_" for underline (valore predefinito: `darkgray`)
* [[option_irc.look.ban_mask_default]] *irc.look.ban_mask_default*
** descrizione: `default ban mask for commands /ban, /unban and /kickban; variables $nick, $user and $host are replaced by their values (extracted from "nick!user@host"); this default mask is used only if WeeChat knows the host for the nick`
** tipo: stringa
** valori: qualsiasi stringa (valore predefinito: `"*!$user@$host"`)
* [[option_irc.look.buffer_switch_autojoin]] *irc.look.buffer_switch_autojoin*
** descrizione: `passa automaticamente al buffer del canale con l'ingresso automatico abilitato (con l'opzione del server "autojoin")`
** tipo: bool
+5
View File
@@ -63,6 +63,11 @@
** タイプ: 色
** 値: a WeeChat color name (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a terminal color number or an alias; attributes are allowed before color (for text color only, not background): "*" for bold, "!" for reverse, "/" for italic, "_" for underline (デフォルト値: `darkgray`)
* [[option_irc.look.ban_mask_default]] *irc.look.ban_mask_default*
** 説明: `default ban mask for commands /ban, /unban and /kickban; variables $nick, $user and $host are replaced by their values (extracted from "nick!user@host"); this default mask is used only if WeeChat knows the host for the nick`
** タイプ: 文字列
** 値: 未制約文字列 (デフォルト値: `"*!$user@$host"`)
* [[option_irc.look.buffer_switch_autojoin]] *irc.look.buffer_switch_autojoin*
** 説明: `自動で参加した場合に、自動的にチャンネルバッファを移動 (サーバオプション "autojoin" と共に使用)`
** タイプ: ブール
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:18+0100\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6217,6 +6217,12 @@ msgstr "%s%s: chyba při vytváření serveru \"%s\""
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: chyba při vytváření volby serveru \"%s\""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-20 15:12+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <weechatter@arcor.de>\n"
@@ -6953,6 +6953,12 @@ msgstr "%s%s: Fehler bei der Erstellung des Servers \"%s\""
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: Fehler bei der Erstellung der Serveroption \"%s\""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:18+0100\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6452,6 +6452,12 @@ msgstr "%s%s: error al crear el servidor \"%s\""
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: error al crear la opción \"%s\" del servidor"
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+12 -2
View File
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"PO-Revision-Date: 2013-12-07 17:08+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-12-07 18:17+0100\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@@ -6779,6 +6779,16 @@ msgstr "%s%s: erreur de création du serveur \"%s\""
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: erreur de création de l'option serveur \"%s\""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
"masque de bannissement par défaut pour les commandes /ban, /unban et /"
"kickban; les variables $nick, $user et $host sont remplacées par leurs "
"valeurs (extraites de \"nick!user@host\"); ce masque par défaut est utilisé "
"seulement si WeeChat connaît l'hôte pour le pseudo"
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:18+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5754,6 +5754,12 @@ msgstr "%s nincs elég memória az információs pult üzenethez\n"
msgid "%s%s: error creating server option \"%s\""
msgstr "%s nincs elég memória az információs pult üzenethez\n"
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:18+0100\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6578,6 +6578,12 @@ msgstr "%s%s: errore durante la creazione del server \"%s\""
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: errore durante la creazione dell'opzione del server \"%s\""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:18+0100\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/WeeChat>\n"
@@ -6508,6 +6508,12 @@ msgstr "%s%s: サーバ \"%s\" 作成中のエラー"
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: サーバオプション \"%s\" 作成中にエラー"
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-11 09:07+0100\n"
"Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6663,6 +6663,12 @@ msgstr "%s%s: błąd podczas tworzenia serwera \"%s\""
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: błąd podczas tworzenia opcji dla serwera \"%s\""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:18+0100\n"
"Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5966,6 +5966,12 @@ msgstr "%s%s: erro ao criar servidor \"%s\""
msgid "%s%s: error creating server option \"%s\""
msgstr "%s%s: erro ao criar opção do servidor \"%s\""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:18+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5778,6 +5778,12 @@ msgstr "%s недостаточно памяти для сообщения в с
msgid "%s%s: error creating server option \"%s\""
msgstr "%s недостаточно памяти для сообщения в строке информации\n"
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-11-09 10:13+0100\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5079,6 +5079,12 @@ msgstr ""
msgid "%s%s: error creating server option \"%s\""
msgstr ""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+7 -1
View File
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.1-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-12-07 15:14+0100\n"
"POT-Creation-Date: 2013-12-07 18:16+0100\n"
"PO-Revision-Date: 2013-02-14 18:20+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5037,6 +5037,12 @@ msgstr ""
msgid "%s%s: error creating server option \"%s\""
msgstr ""
msgid ""
"default ban mask for commands /ban, /unban and /kickban; variables $nick, "
"$user and $host are replaced by their values (extracted from \"nick!user@host"
"\"); this default mask is used only if WeeChat knows the host for the nick"
msgstr ""
msgid ""
"auto switch to channel buffer when it is auto joined (with server option "
"\"autojoin\")"
+45 -10
View File
@@ -839,6 +839,45 @@ irc_command_run_away (void *data, struct t_gui_buffer *buffer,
return WEECHAT_RC_OK;
}
/*
* Sends a ban/unban command to the server, as "MODE [+/-]b nick".
*
* Argument "mode" can be "+b" for ban or "-b" for unban.
*/
void
irc_command_send_ban (struct t_irc_server *server,
const char *channel_name,
const char *mode,
const char *nick)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
char *mask;
mask = NULL;
if (!strchr (nick, '!') && !strchr (nick, '@'))
{
ptr_channel = irc_channel_search (server, channel_name);
if (ptr_channel)
{
ptr_nick = irc_nick_search (server, ptr_channel, nick);
if (ptr_nick)
mask = irc_nick_default_ban_mask (ptr_nick);
}
}
irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"MODE %s %s %s",
channel_name,
mode,
(mask) ? mask : nick);
if (mask)
free (mask);
}
/*
* Callback for command "/ban": bans nicks or hosts.
*/
@@ -891,9 +930,8 @@ irc_command_ban (void *data, struct t_gui_buffer *buffer, int argc,
/* loop on users */
while (argv[pos_args])
{
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"MODE %s +b %s",
pos_channel, argv[pos_args]);
irc_command_send_ban (ptr_server, pos_channel, "+b",
argv[pos_args]);
pos_args++;
}
}
@@ -2522,10 +2560,8 @@ irc_command_kickban (void *data, struct t_gui_buffer *buffer, int argc,
}
else
{
irc_server_sendf (ptr_server,
IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"MODE %s +b %s",
pos_channel, pos_nick);
irc_command_send_ban (ptr_server, pos_channel, "+b",
pos_nick);
}
/* kick nick */
@@ -5332,9 +5368,8 @@ irc_command_unban (void *data, struct t_gui_buffer *buffer, int argc,
/* loop on users */
while (argv[pos_args])
{
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"MODE %s -b %s",
pos_channel, argv[pos_args]);
irc_command_send_ban (ptr_server, pos_channel, "-b",
argv[pos_args]);
pos_args++;
}
}
+10
View File
@@ -48,6 +48,7 @@ struct t_config_section *irc_config_section_server = NULL;
/* IRC config, look section */
struct t_config_option *irc_config_look_ban_mask_default;
struct t_config_option *irc_config_look_buffer_switch_autojoin;
struct t_config_option *irc_config_look_buffer_switch_join;
struct t_config_option *irc_config_look_color_nicks_in_names;
@@ -2193,6 +2194,15 @@ irc_config_init ()
return 0;
}
irc_config_look_ban_mask_default = weechat_config_new_option (
irc_config_file, ptr_section,
"ban_mask_default", "string",
N_("default ban mask for commands /ban, /unban and /kickban; variables "
"$nick, $user and $host are replaced by their values (extracted "
"from \"nick!user@host\"); this default mask is used only if "
"WeeChat knows the host for the nick"),
NULL, 0, 0, "*!$user@$host", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
irc_config_look_buffer_switch_autojoin = weechat_config_new_option (
irc_config_file, ptr_section,
"buffer_switch_autojoin", "boolean",
+1
View File
@@ -96,6 +96,7 @@ extern struct t_config_section *irc_config_section_ctcp;
extern struct t_config_section *irc_config_section_server_default;
extern struct t_config_section *irc_config_section_server;
extern struct t_config_option *irc_config_look_ban_mask_default;
extern struct t_config_option *irc_config_look_buffer_switch_autojoin;
extern struct t_config_option *irc_config_look_buffer_switch_join;
extern struct t_config_option *irc_config_look_color_nicks_in_names;
+56
View File
@@ -1045,6 +1045,62 @@ irc_nick_color_for_pv (struct t_irc_channel *channel, const char *nickname)
return IRC_COLOR_CHAT_NICK_OTHER;
}
/*
* Returns default ban mask for the nick.
*
* Note: result must be freed after use (if not NULL).
*/
char *
irc_nick_default_ban_mask (struct t_irc_nick *nick)
{
static char ban_mask[128];
const char *ptr_ban_mask;
char *pos_hostname, user[64], *res, *temp;
if (!nick)
return NULL;
ptr_ban_mask = weechat_config_string (irc_config_look_ban_mask_default);
pos_hostname = (nick->host) ? strchr (nick->host, '@') : NULL;
if (!nick->host || !pos_hostname || !ptr_ban_mask || !ptr_ban_mask[0])
{
snprintf (ban_mask, sizeof (ban_mask), "%s!*@*", nick->name);
return strdup (ban_mask);
}
if (pos_hostname - nick->host > (int)sizeof (user) - 1)
return NULL;
strncpy (user, nick->host, pos_hostname - nick->host);
user[pos_hostname - nick->host] = '\0';
pos_hostname++;
/* replace nick */
temp = weechat_string_replace (ptr_ban_mask, "$nick", nick->name);
if (!temp)
return NULL;
res = temp;
/* replace user */
temp = weechat_string_replace (res, "$user", user);
free (res);
if (!temp)
return NULL;
res = temp;
/* replace hostname */
temp = weechat_string_replace (res, "$host", pos_hostname);
free (res);
if (!temp)
return NULL;
res = temp;
return res;
}
/*
* Returns hdata for nick.
*/
+1
View File
@@ -101,6 +101,7 @@ extern const char *irc_nick_color_for_server_message (struct t_irc_server *serve
const char *nickname);
extern const char * irc_nick_color_for_pv (struct t_irc_channel *channel,
const char *nickname);
extern char *irc_nick_default_ban_mask (struct t_irc_nick *nick);
extern struct t_hdata *irc_nick_hdata_nick_cb (void *data,
const char *hdata_name);
extern int irc_nick_add_to_infolist (struct t_infolist *infolist,