summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/command.c8
-rw-r--r--src/irc/irc-commands.c16
-rw-r--r--src/irc/irc-recv.c202
-rw-r--r--src/irc/irc-send.c262
-rw-r--r--src/irc/irc.h6
5 files changed, 476 insertions, 18 deletions
diff --git a/src/common/command.c b/src/common/command.c
index 3f7644ccb..a5f6fe58e 100644
--- a/src/common/command.c
+++ b/src/common/command.c
@@ -1234,6 +1234,10 @@ weechat_cmd_help (int argc, char **argv)
_(weechat_commands[i].arguments));
else
gui_printf (NULL, "\n");
+ if (weechat_commands[i].command_description &&
+ weechat_commands[i].command_description[0])
+ gui_printf (NULL, "\n%s\n",
+ _(weechat_commands[i].command_description));
if (weechat_commands[i].arguments_description &&
weechat_commands[i].arguments_description[0])
gui_printf (NULL, "\n%s\n",
@@ -1256,6 +1260,10 @@ weechat_cmd_help (int argc, char **argv)
_(irc_commands[i].arguments));
else
gui_printf (NULL, "\n");
+ if (irc_commands[i].command_description &&
+ irc_commands[i].command_description[0])
+ gui_printf (NULL, "\n%s\n",
+ _(irc_commands[i].command_description));
if (irc_commands[i].arguments_description &&
irc_commands[i].arguments_description[0])
gui_printf (NULL, "\n%s\n",
diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c
index 1588f3ccb..b490e0f02 100644
--- a/src/irc/irc-commands.c
+++ b/src/irc/irc-commands.c
@@ -40,6 +40,10 @@ t_irc_command irc_commands[] =
N_("-all: toggle away status on all connected servers\n"
"message: message for away (if no message is given, away status is removed)"),
0, MAX_ARGS, 1, NULL, irc_cmd_send_away, NULL },
+ { "ban", N_("bans nicks or hosts"),
+ N_("[channel] [nickname [nickname ...]]"),
+ N_("channel: channel for ban\nnickname: user or host to ban"),
+ 0, MAX_ARGS, 1, NULL, irc_cmd_send_ban, NULL },
{ "ctcp", N_("send a ctcp message"),
N_("nickname type"),
N_("nickname: user to send ctcp to\ntype: \"action\" or \"version\""),
@@ -80,6 +84,10 @@ t_irc_command irc_commands[] =
N_("[channel] nickname [comment]"),
N_("channel: channel where user is\nnickname: nickname to kick\ncomment: comment for kick"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_kick, irc_cmd_recv_kick },
+ { "kickban", N_("kicks and bans a nick from a channel"),
+ N_("[channel] nickname [comment]"),
+ N_("channel: channel where user is\nnickname: nickname to kick and ban\ncomment: comment for kick"),
+ 1, MAX_ARGS, 1, NULL, irc_cmd_send_kickban, NULL },
{ "kill", N_("close client-server connection"),
N_("nickname comment"),
N_("nickname: nickname\ncomment: comment for kill"),
@@ -218,6 +226,10 @@ t_irc_command irc_commands[] =
{ "trace", N_("find the route to specific server"),
N_("[target]"), N_("target: server"),
0, 1, 1, NULL, irc_cmd_send_trace, NULL },
+ { "unban", N_("unbans nicks or hosts"),
+ N_("[channel] nickname [nickname ...]"),
+ N_("channel: channel for unban\nnickname: user or host to unban"),
+ 1, MAX_ARGS, 1, NULL, irc_cmd_send_unban, NULL },
{ "userhost", N_("return a list of information about nicknames"),
N_("nickname [nickname ...]"), N_("nickname: nickname"),
1, MAX_ARGS, 1, NULL, irc_cmd_send_userhost, NULL },
@@ -311,6 +323,8 @@ t_irc_command irc_commands[] =
{ "364", N_("links"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg },
{ "365", N_("end of /links list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg },
{ "366", N_("end of /names list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_366 },
+ { "367", N_("banlist"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_367 },
+ { "368", N_("end of banlist"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_368 },
{ "369", N_("end of /whowas list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg },
{ "371", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg },
{ "372", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg },
@@ -363,6 +377,8 @@ t_irc_command irc_commands[] =
"", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_433 },
{ "436", N_("nickname collision"),
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
+ { "438", N_("not authorized to change nickname"),
+ "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_438 },
{ "441", N_("user not in channel"),
"", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error },
{ "442", N_("not on channel"),
diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c
index b48ab1cff..414a30cfc 100644
--- a/src/irc/irc-recv.c
+++ b/src/irc/irc-recv.c
@@ -3201,6 +3201,172 @@ irc_cmd_recv_366 (t_irc_server *server, char *host, char *arguments)
}
/*
+ * irc_cmd_recv_367: '367' command received (banlist)
+ */
+
+int
+irc_cmd_recv_367 (t_irc_server *server, char *host, char *arguments)
+{
+ char *pos_channel, *pos_ban, *pos_user, *pos_date, *pos;
+ t_irc_channel *ptr_channel;
+ t_gui_buffer *buffer;
+ time_t datetime;
+
+ /* make gcc happy */
+ (void) host;
+
+ /* look for channel */
+ pos_channel = strchr (arguments, ' ');
+ if (!pos_channel)
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s cannot parse \"%s\" command\n"),
+ WEECHAT_ERROR, "367");
+ return -1;
+ }
+ pos_channel[0] = '\0';
+ pos_channel++;
+ while (pos_channel[0] == ' ')
+ pos_channel++;
+
+ /* look for ban mask */
+ pos_ban = strchr (pos_channel, ' ');
+ if (!pos_ban)
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s cannot parse \"%s\" command\n"),
+ WEECHAT_ERROR, "367");
+ return -1;
+ }
+ pos_ban[0] = '\0';
+ pos_ban++;
+ while (pos_ban[0] == ' ')
+ pos_ban++;
+
+ /* look for user who set ban */
+ pos_user = strchr (pos_ban, ' ');
+ if (!pos_user)
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s cannot parse \"%s\" command\n"),
+ WEECHAT_ERROR, "367");
+ return -1;
+ }
+ pos_user[0] = '\0';
+ pos_user++;
+ while (pos_user[0] == ' ')
+ pos_user++;
+
+ /* look for date/time */
+ pos_date = strchr (pos_user, ' ');
+ if (!pos_date)
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s cannot parse \"%s\" command\n"),
+ WEECHAT_ERROR, "367");
+ return -1;
+ }
+ pos_date[0] = '\0';
+ pos_date++;
+ while (pos_date[0] == ' ')
+ pos_date++;
+
+ if (!pos_date || !pos_date[0])
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s cannot parse \"%s\" command\n"),
+ WEECHAT_ERROR, "367");
+ return -1;
+ }
+
+ ptr_channel = channel_search (server, pos_channel);
+ buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
+
+ irc_display_prefix (buffer, PREFIX_INFO);
+ gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "[");
+ gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%s", pos_channel);
+ gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "] ");
+ gui_printf_color (buffer, COLOR_WIN_CHAT_HOST, "%s ", pos_ban);
+ gui_printf (buffer, _("banned by"));
+ pos = strchr (pos_user, '!');
+ if (pos)
+ {
+ pos[0] = '\0';
+ gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, " %s ", pos_user);
+ gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "(");
+ gui_printf_color (buffer, COLOR_WIN_CHAT_HOST, "%s", pos + 1);
+ gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, ")");
+ }
+ else
+ gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, " %s", pos_user);
+ datetime = (time_t)(atol (pos_date));
+ gui_printf_nolog (buffer, ", %s", ctime (&datetime));
+
+ return 0;
+}
+
+/*
+ * irc_cmd_recv_368: '368' command received (end of banlist)
+ */
+
+int
+irc_cmd_recv_368 (t_irc_server *server, char *host, char *arguments)
+{
+ char *pos_channel, *pos_msg;
+ t_irc_channel *ptr_channel;
+ t_gui_buffer *buffer;
+
+ /* make gcc happy */
+ (void) host;
+
+ pos_channel = strchr (arguments, ' ');
+ if (!pos_channel)
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s cannot parse \"%s\" command\n"),
+ WEECHAT_ERROR, "368");
+ return -1;
+ }
+ pos_channel[0] = '\0';
+ pos_channel++;
+ while (pos_channel[0] == ' ')
+ pos_channel++;
+
+ pos_msg = strchr (pos_channel, ' ');
+ if (!pos_msg)
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s cannot parse \"%s\" command\n"),
+ WEECHAT_ERROR, "368");
+ return -1;
+ }
+ pos_msg[0] = '\0';
+ pos_msg++;
+ while (pos_msg[0] == ' ')
+ pos_msg++;
+ if (pos_msg[0] == ':')
+ pos_msg++;
+
+ ptr_channel = channel_search (server, pos_channel);
+ buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer;
+
+ irc_display_prefix (buffer, PREFIX_INFO);
+ gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "[");
+ gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%s", pos_channel);
+ gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "] ");
+ gui_printf_nolog (buffer, "%s\n", pos_msg);
+
+ return 0;
+}
+
+/*
* irc_cmd_recv_433: '433' command received (nickname already in use)
*/
@@ -3270,3 +3436,39 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
return irc_cmd_recv_error (server, host, arguments);
return 0;
}
+
+/*
+ * irc_cmd_recv_438: '438' command received (not authorized to change nickname)
+ */
+
+int
+irc_cmd_recv_438 (t_irc_server *server, char *host, char *arguments)
+{
+ char *pos, *pos2;
+
+ /* make gcc happy */
+ (void) server;
+ (void) host;
+
+ pos = strchr (arguments, ' ');
+ irc_display_prefix (server->buffer, PREFIX_SERVER);
+ if (pos)
+ {
+ pos[0] = '\0';
+ pos++;
+
+ pos2 = strstr (pos, " :");
+ if (pos2)
+ {
+ pos2[0] = '\0';
+ pos2 += 2;
+ gui_printf (server->buffer, "%s (%s => %s)\n", pos2, arguments, pos);
+ }
+ else
+ gui_printf (server->buffer, "%s (%s)\n", pos, arguments);
+ }
+ else
+ gui_printf (server->buffer, "%s\n", arguments);
+
+ return 0;
+}
diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c
index 1d17350d8..9a376dbc0 100644
--- a/src/irc/irc-send.c
+++ b/src/irc/irc-send.c
@@ -188,6 +188,84 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
}
/*
+ * irc_cmd_send_ban: bans nicks or hosts
+ */
+
+int
+irc_cmd_send_ban (t_irc_server *server, char *arguments)
+{
+ char *pos_channel, *pos, *pos2;
+
+ if (arguments)
+ {
+ pos_channel = NULL;
+ pos = strchr (arguments, ' ');
+ if (pos)
+ {
+ pos[0] = '\0';
+
+ if (string_is_channel (arguments))
+ {
+ pos_channel = arguments;
+ pos++;
+ while (pos[0] == ' ')
+ pos++;
+ }
+ else
+ {
+ pos[0] = ' ';
+ pos = arguments;
+ }
+ }
+ else
+ pos = arguments;
+
+ /* channel not given, use default buffer */
+ if (!pos_channel)
+ {
+ if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s \"%s\" command can only be executed in a channel window\n"),
+ WEECHAT_ERROR, "ban");
+ return -1;
+ }
+ pos_channel = CHANNEL(gui_current_window->buffer)->name;
+ }
+
+ /* loop on users */
+ while (pos && pos[0])
+ {
+ pos2 = strchr (pos, ' ');
+ if (pos2)
+ {
+ pos2[0] = '\0';
+ pos2++;
+ while (pos2[0] == ' ')
+ pos2++;
+ }
+ server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos);
+ pos = pos2;
+ }
+ }
+ else
+ {
+ if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s \"%s\" command can only be executed in a channel window\n"),
+ WEECHAT_ERROR, "ban");
+ return -1;
+ }
+ server_sendf (server, "MODE %s +b\r\n", CHANNEL(gui_current_window->buffer)->name);
+ }
+
+ return 0;
+}
+
+/*
* irc_cmd_send_ctcp: send a ctcp message
*/
@@ -458,29 +536,28 @@ irc_cmd_send_join (t_irc_server *server, char *arguments)
int
irc_cmd_send_kick (t_irc_server *server, char *arguments)
{
- char *args, *pos;
+ char *pos_channel, *pos_nick, *pos_comment;
if (string_is_channel (arguments))
- server_sendf (server, "KICK %s\r\n", arguments);
- else
{
- if (BUFFER_IS_CHANNEL (gui_current_window->buffer))
+ pos_channel = arguments;
+ pos_nick = strchr (arguments, ' ');
+ if (!pos_nick)
{
- args = strdup (arguments);
- pos = strchr (args, ' ');
- if (pos)
- pos[0] = '\0';
- if (pos)
- server_sendf (server,
- "KICK %s %s :%s\r\n",
- CHANNEL(gui_current_window->buffer)->name, args, pos + 1);
- else
- server_sendf (server,
- "KICK %s %s\r\n",
- CHANNEL(gui_current_window->buffer)->name, args);
- free (args);
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s wrong arguments for \"%s\" command\n"),
+ WEECHAT_ERROR, "kick");
+ return -1;
}
- else
+ pos_nick[0] = '\0';
+ pos_nick++;
+ while (pos_nick[0] == ' ')
+ pos_nick++;
+ }
+ else
+ {
+ if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
{
irc_display_prefix (server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
@@ -488,7 +565,82 @@ irc_cmd_send_kick (t_irc_server *server, char *arguments)
WEECHAT_ERROR, "kick");
return -1;
}
+ pos_channel = CHANNEL(gui_current_window->buffer)->name;
+ pos_nick = arguments;
+ }
+
+ pos_comment = strchr (pos_nick, ' ');
+ if (pos_comment)
+ {
+ pos_comment[0] = '\0';
+ pos_comment++;
+ while (pos_comment[0] == ' ')
+ pos_comment++;
+ }
+
+ if (pos_comment)
+ server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
+ else
+ server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
+
+ return 0;
+}
+
+/*
+ * irc_cmd_send_kickban: forcibly remove a user from a channel and ban it
+ */
+
+int
+irc_cmd_send_kickban (t_irc_server *server, char *arguments)
+{
+ char *pos_channel, *pos_nick, *pos_comment;
+
+ if (string_is_channel (arguments))
+ {
+ pos_channel = arguments;
+ pos_nick = strchr (arguments, ' ');
+ if (!pos_nick)
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s wrong arguments for \"%s\" command\n"),
+ WEECHAT_ERROR, "kickban");
+ return -1;
+ }
+ pos_nick[0] = '\0';
+ pos_nick++;
+ while (pos_nick[0] == ' ')
+ pos_nick++;
}
+ else
+ {
+ if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s \"%s\" command can only be executed in a channel window\n"),
+ WEECHAT_ERROR, "kickban");
+ return -1;
+ }
+ pos_channel = CHANNEL(gui_current_window->buffer)->name;
+ pos_nick = arguments;
+ }
+
+ pos_comment = strchr (pos_nick, ' ');
+ if (pos_comment)
+ {
+ pos_comment[0] = '\0';
+ pos_comment++;
+ while (pos_comment[0] == ' ')
+ pos_comment++;
+ }
+
+ server_sendf (server, "MODE %s +b %s\r\n", pos_channel, pos_nick);
+ if (pos_comment)
+ server_sendf (server, "KICK %s %s :%s\r\n", pos_channel, pos_nick, pos_comment);
+ else
+ server_sendf (server, "KICK %s %s\r\n", pos_channel, pos_nick);
+
return 0;
}
@@ -1315,6 +1467,80 @@ irc_cmd_send_trace (t_irc_server *server, char *arguments)
}
/*
+ * irc_cmd_send_unban: unbans nicks or hosts
+ */
+
+int
+irc_cmd_send_unban (t_irc_server *server, char *arguments)
+{
+ char *pos_channel, *pos, *pos2;
+
+ if (arguments)
+ {
+ pos_channel = NULL;
+ pos = strchr (arguments, ' ');
+ if (pos)
+ {
+ pos[0] = '\0';
+
+ if (string_is_channel (arguments))
+ {
+ pos_channel = arguments;
+ pos++;
+ while (pos[0] == ' ')
+ pos++;
+ }
+ else
+ {
+ pos[0] = ' ';
+ pos = arguments;
+ }
+ }
+ else
+ pos = arguments;
+
+ /* channel not given, use default buffer */
+ if (!pos_channel)
+ {
+ if (!BUFFER_IS_CHANNEL(gui_current_window->buffer))
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s \"%s\" command can only be executed in a channel window\n"),
+ WEECHAT_ERROR, "unban");
+ return -1;
+ }
+ pos_channel = CHANNEL(gui_current_window->buffer)->name;
+ }
+
+ /* loop on users */
+ while (pos && pos[0])
+ {
+ pos2 = strchr (pos, ' ');
+ if (pos2)
+ {
+ pos2[0] = '\0';
+ pos2++;
+ while (pos2[0] == ' ')
+ pos2++;
+ }
+ server_sendf (server, "MODE %s -b %s\r\n", pos_channel, pos);
+ pos = pos2;
+ }
+ }
+ else
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf_nolog (server->buffer,
+ _("%s wrong argument count for \"%s\" command\n"),
+ WEECHAT_ERROR, "unban");
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
* irc_cmd_send_userhost: return a list of information about nicknames
*/
diff --git a/src/irc/irc.h b/src/irc/irc.h
index b7b9b8453..bfcdb4180 100644
--- a/src/irc/irc.h
+++ b/src/irc/irc.h
@@ -318,6 +318,7 @@ extern void irc_login (t_irc_server *);
/* IRC commands issued by user */
extern int irc_cmd_send_admin (t_irc_server *, char *);
extern int irc_cmd_send_away (t_irc_server *, char *);
+extern int irc_cmd_send_ban (t_irc_server *, char *);
extern int irc_cmd_send_ctcp (t_irc_server *, char *);
extern int irc_cmd_send_dcc (t_irc_server *, char *);
extern int irc_cmd_send_deop (t_irc_server *, int, char **);
@@ -328,6 +329,7 @@ extern int irc_cmd_send_invite (t_irc_server *, int, char **);
extern int irc_cmd_send_ison (t_irc_server *, char *);
extern int irc_cmd_send_join (t_irc_server *, char *);
extern int irc_cmd_send_kick (t_irc_server *, char *);
+extern int irc_cmd_send_kickban (t_irc_server *, char *);
extern int irc_cmd_send_kill (t_irc_server *, char *);
extern int irc_cmd_send_links (t_irc_server *, char *);
extern int irc_cmd_send_list (t_irc_server *, char *);
@@ -360,6 +362,7 @@ extern int irc_cmd_send_summon (t_irc_server *, char *);
extern int irc_cmd_send_time (t_irc_server *, char *);
extern int irc_cmd_send_topic (t_irc_server *, char *);
extern int irc_cmd_send_trace (t_irc_server *, char *);
+extern int irc_cmd_send_unban (t_irc_server *, char *);
extern int irc_cmd_send_userhost (t_irc_server *, char *);
extern int irc_cmd_send_users (t_irc_server *, char *);
extern int irc_cmd_send_version (t_irc_server *, char *);
@@ -413,6 +416,9 @@ extern int irc_cmd_recv_352 (t_irc_server *, char *, char *);
extern int irc_cmd_recv_353 (t_irc_server *, char *, char *);
extern int irc_cmd_recv_365 (t_irc_server *, char *, char *);
extern int irc_cmd_recv_366 (t_irc_server *, char *, char *);
+extern int irc_cmd_recv_367 (t_irc_server *, char *, char *);
+extern int irc_cmd_recv_368 (t_irc_server *, char *, char *);
extern int irc_cmd_recv_433 (t_irc_server *, char *, char *);
+extern int irc_cmd_recv_438 (t_irc_server *, char *, char *);
#endif /* irc.h */