diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-05-29 14:26:30 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-05-29 14:26:30 +0200 |
commit | 4a41625989e02cd194938e580923b484e0bd4a0f (patch) | |
tree | 46c78a9c0346bb2504916810002d09f3a2b0b27a /src | |
parent | a9b976274e9cad44151128d8d228e6989ba2f813 (diff) | |
download | weechat-4a41625989e02cd194938e580923b484e0bd4a0f.zip |
irc: add variable "${target}" (target nick) in commands /kick and /kickban
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-command.c | 20 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 5 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 3 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index f28fa12f8..7728fbb09 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -1755,7 +1755,8 @@ IRC_COMMAND_CALLBACK(cycle) IRC_SERVER_OPTION_MSG_PART); if (ptr_arg && ptr_arg[0]) { - msg = irc_server_get_default_msg (ptr_arg, ptr_server, channel_name); + msg = irc_server_get_default_msg (ptr_arg, ptr_server, channel_name, + NULL); irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PART %s :%s", channel_name, msg); } @@ -2033,7 +2034,7 @@ irc_command_quit_server (struct t_irc_server *server, const char *arguments) IRC_SERVER_OPTION_MSG_QUIT); if (ptr_arg && ptr_arg[0]) { - msg = irc_server_get_default_msg (ptr_arg, server, NULL); + msg = irc_server_get_default_msg (ptr_arg, server, NULL, NULL); irc_server_sendf (server, 0, NULL, "QUIT :%s", msg); } else @@ -2775,7 +2776,8 @@ irc_command_kick_channel (struct t_irc_server *server, IRC_SERVER_OPTION_MSG_KICK); if (ptr_msg && ptr_msg[0]) { - msg = irc_server_get_default_msg (ptr_msg, server, channel_name); + msg = irc_server_get_default_msg (ptr_msg, server, channel_name, + nick_name); irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "KICK %s %s :%s", channel_name, nick_name, msg); @@ -3942,7 +3944,7 @@ irc_command_part_channel (struct t_irc_server *server, const char *channel_name, IRC_SERVER_OPTION_MSG_PART); if (ptr_arg && ptr_arg[0]) { - msg = irc_server_get_default_msg (ptr_arg, server, channel_name); + msg = irc_server_get_default_msg (ptr_arg, server, channel_name, NULL); irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, "PART %s :%s", channel_name, msg); } @@ -6694,8 +6696,9 @@ irc_command_init () N_("[<channel>] <nick> [<reason>]"), N_("channel: channel name\n" " nick: nick\n" - " reason: reason (special variables $nick, $channel and $server are " - "replaced by their value)"), + " reason: reason (evaluated, see /help eval; special variables " + "${nick} (self nick), ${target} (target nick), ${channel} and " + "${server} are replaced by their values)"), "%(nicks) %(irc_msg_kick) %-", &irc_command_kick, NULL, NULL); weechat_hook_command ( "kickban", @@ -6703,8 +6706,9 @@ irc_command_init () N_("[<channel>] <nick> [<reason>]"), N_("channel: channel name\n" " nick: nick\n" - " reason: reason (special variables $nick, $channel and $server are " - "replaced by their value)\n" + " reason: reason (evaluated, see /help eval; special variables " + "${nick} (self nick), ${target} (target nick), ${channel} and " + "${server} are replaced by their values)\n" "\n" "It is possible to kick/ban with a mask, nick will be extracted from " "mask and replaced by \"*\".\n" diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 44293fba9..b754ec3e3 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1361,7 +1361,8 @@ irc_server_get_max_modes (struct t_irc_server *server) char * irc_server_get_default_msg (const char *default_msg, struct t_irc_server *server, - const char *channel_name) + const char *channel_name, + const char *target_nick) { char *version; struct t_hashtable *extra_vars; @@ -1393,6 +1394,8 @@ irc_server_get_default_msg (const char *default_msg, weechat_hashtable_set (extra_vars, "channel", (channel_name) ? channel_name : ""); weechat_hashtable_set (extra_vars, "nick", server->nick); + if (target_nick) + weechat_hashtable_set (extra_vars, "target", target_nick); } msg = weechat_string_eval_expression (default_msg, NULL, extra_vars, NULL); diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 535b61c90..e5bb74578 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -340,7 +340,8 @@ extern int irc_server_prefix_char_statusmsg (struct t_irc_server *server, extern int irc_server_get_max_modes (struct t_irc_server *server); extern char *irc_server_get_default_msg (const char *default_msg, struct t_irc_server *server, - const char *channel_name); + const char *channel_name, + const char *target_nick); extern struct t_irc_server *irc_server_alloc (const char *name); extern struct t_irc_server *irc_server_alloc_with_url (const char *irc_url); extern void irc_server_apply_command_line_options (struct t_irc_server *server, |