1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 13:26:38 +02:00

Added /cycle command, /part command does close buffer any more

This commit is contained in:
Sebastien Helleu
2006-03-19 12:15:27 +00:00
parent 12b0742668
commit e499c1cb32
30 changed files with 5852 additions and 5366 deletions
+5 -1
View File
@@ -1,9 +1,13 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2006-03-18
ChangeLog - 2006-03-19
Version 0.1.9 (under dev!):
* added /cycle command, /part command does close buffer any more (use
/buffer close (or alias /close) to part and close buffer
Version 0.1.8 (2006-03-18):
* improved Ruby plugin
* fixed /set command when internal server name contains one or many dots
+541 -525
View File
File diff suppressed because it is too large Load Diff
+541 -525
View File
File diff suppressed because it is too large Load Diff
+541 -529
View File
File diff suppressed because it is too large Load Diff
+541 -525
View File
File diff suppressed because it is too large Load Diff
+543 -533
View File
File diff suppressed because it is too large Load Diff
+24 -8
View File
@@ -50,16 +50,16 @@ t_weechat_command weechat_commands[] =
"arguments: arguments for command"),
"%- %A", 0, MAX_ARGS, NULL, weechat_cmd_alias },
{ "buffer", N_("manage buffers"),
N_("[action | number | [[server] [channel]]]"),
N_("[action [args] | number | [[server] [channel]]]"),
N_(" action: action to do:\n"
" move: move buffer in the list (may be relative, for example -1)\n"
" close: close buffer (for channel: same as /part without part message)\n"
" close: close buffer (optional arg is part message, for a channel)\n"
" list: list opened buffers (no parameter implies this list)\n"
" notify: set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)\n"
"server\n"
"channel: jump to buffer by server and/or channel name\n"
" number: jump to buffer by number"),
"move|close|list|notify", 0, MAX_ARGS, weechat_cmd_buffer, NULL },
"move|close|list|notify", 0, MAX_ARGS, NULL, weechat_cmd_buffer },
{ "charset", N_("change charset for server or channel"),
N_("[(decode_iso | decode_utf | encode) charset]"),
N_("decode_iso: charset used for decoding ISO\n"
@@ -795,7 +795,7 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
}
else
{
if ((irc_commands[i].need_connection) &&
if ((irc_commands[i].needs_connection) &&
((!server) || (!server->is_connected)))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
@@ -1215,18 +1215,20 @@ weechat_cmd_buffer_display_info (t_gui_buffer *buffer)
int
weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
int argc, char **argv)
char *arguments)
{
t_gui_window *window;
t_gui_buffer *buffer, *ptr_buffer;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
long number;
char *error;
int target_buffer;
char *error, *pos, **argv;
int argc, target_buffer;
irc_find_context (server, channel, &window, &buffer);
argv = explode_string (arguments, " ", 0, &argc);
if ((argc == 0) || ((argc == 1) && (ascii_strcasecmp (argv[0], "list") == 0)))
{
/* list opened buffers */
@@ -1255,6 +1257,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s missing arguments for \"%s\" command\n"),
WEECHAT_ERROR, "buffer");
free_exploded_string (argv);
return -1;
}
@@ -1278,6 +1281,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect buffer number\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
}
@@ -1294,6 +1298,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
gui_printf (NULL,
_("%s can not close the single buffer\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
if (BUFFER_IS_SERVER(buffer))
@@ -1305,6 +1310,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
_("%s can not close server buffer while channels "
"are opened\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
server_disconnect (SERVER(buffer), 0);
@@ -1329,9 +1335,15 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
if (SERVER(buffer)->is_connected
&& CHANNEL(buffer)
&& CHANNEL(buffer)->nicks)
{
pos = strstr (arguments, "close");
if (pos)
pos += 6;
CHANNEL(buffer)->close = 1;
irc_cmd_send_part (SERVER(buffer),
CHANNEL(buffer),
NULL);
pos);
}
else
{
ptr_channel = channel_search (SERVER(buffer),
@@ -1385,6 +1397,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect notify level (must be between %d and %d)\n"),
WEECHAT_ERROR, NOTIFY_LEVEL_MIN, NOTIFY_LEVEL_MAX);
free_exploded_string (argv);
return -1;
}
if ((!BUFFER_IS_CHANNEL(buffer))
@@ -1394,6 +1407,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect buffer for notify (must be channel or private)\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
buffer->notify_level = number;
@@ -1433,6 +1447,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect notify level (must be between %d and %d)\n"),
WEECHAT_ERROR, NOTIFY_LEVEL_MIN, NOTIFY_LEVEL_MAX);
free_exploded_string (argv);
return -1;
}
}
@@ -1499,6 +1514,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
}
}
free_exploded_string (argv);
return 0;
}
+1 -1
View File
@@ -74,7 +74,7 @@ extern void free_multi_command (char **);
extern int exec_weechat_command (t_irc_server *, t_irc_channel *, char *);
extern void user_command (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_alias (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_buffer (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_buffer (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_charset (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_clear (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_connect (t_irc_server *, t_irc_channel *, int, char **);
+8
View File
@@ -172,6 +172,8 @@ session_save_channel (FILE *file, t_irc_channel *channel)
rc = rc && (session_write_int (file, SESSION_CHAN_NICKS_COUNT, channel->nicks_count));
rc = rc && (session_write_int (file, SESSION_CHAN_CHECKING_AWAY, channel->checking_away));
rc = rc && (session_write_str (file, SESSION_CHAN_AWAY_MESSAGE, channel->away_message));
rc = rc && (session_write_int (file, SESSION_CHAN_CYCLE, channel->cycle));
rc = rc && (session_write_int (file, SESSION_CHAN_CLOSE, channel->close));
rc = rc && (session_write_id (file, SESSION_CHAN_END));
if (!rc)
@@ -1045,6 +1047,12 @@ session_load_channel (FILE *file)
case SESSION_CHAN_AWAY_MESSAGE:
rc = rc && (session_read_str (file, &(session_current_channel->away_message)));
break;
case SESSION_CHAN_CYCLE:
rc = rc && (session_read_int (file, &(session_current_channel->cycle)));
break;
case SESSION_CHAN_CLOSE:
rc = rc && (session_read_int (file, &(session_current_channel->close)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"channel (object id: %d)\n"));
+3 -1
View File
@@ -102,7 +102,9 @@ enum t_session_channel
SESSION_CHAN_KEY,
SESSION_CHAN_NICKS_COUNT,
SESSION_CHAN_CHECKING_AWAY,
SESSION_CHAN_AWAY_MESSAGE
SESSION_CHAN_AWAY_MESSAGE,
SESSION_CHAN_CYCLE,
SESSION_CHAN_CLOSE
};
enum t_session_nick
+4
View File
@@ -67,6 +67,8 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name)
new_channel->nicks_count = 0;
new_channel->checking_away = 0;
new_channel->away_message = NULL;
new_channel->cycle = 0;
new_channel->close = 0;
new_channel->nicks = NULL;
new_channel->last_nick = NULL;
@@ -493,6 +495,8 @@ channel_print_log (t_irc_channel *channel)
weechat_log_printf (" key. . . . . : '%s'\n", channel->key);
weechat_log_printf (" checking_away: %d\n", channel->checking_away);
weechat_log_printf (" away_message : '%s'\n", channel->away_message);
weechat_log_printf (" cycle. . . . : %d\n", channel->cycle);
weechat_log_printf (" close. . . . : %d\n", channel->close);
weechat_log_printf (" nicks. . . . : 0x%X\n", channel->nicks);
weechat_log_printf (" last_nick. . : 0x%X\n", channel->last_nick);
weechat_log_printf (" buffer . . . : 0x%X\n", channel->buffer);
+5
View File
@@ -59,6 +59,11 @@ t_irc_command irc_commands[] =
" type: CTCP type (examples: \"version\", \"ping\", ..)\n"
"arguments: arguments for CTCP"),
"%n action|ping|version", 2, MAX_ARGS, 1, NULL, irc_cmd_send_ctcp, NULL },
{ "cycle", N_("leave and rejoin a channel"),
N_("[channel[,channel]] [part_message]"),
N_(" channel: channel name for cycle\n"
"part_message: part message (displayed to other users)"),
"%p", 0, MAX_ARGS, 1, NULL, irc_cmd_send_cycle, NULL },
{ "dcc", N_("starts DCC (file or chat) or close chat"),
N_("action [nickname [file]]"),
N_(" action: 'send' (file) or 'chat' or 'close' (chat)\n"
+64 -34
View File
@@ -1414,7 +1414,8 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
int
irc_cmd_recv_part (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos, *pos_args;
char *pos, *pos_args, *join_string;
int join_length;
t_irc_channel *ptr_channel;
t_irc_nick *ptr_nick;
@@ -1446,46 +1447,75 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *nick, char *arguments
ptr_nick = nick_search (ptr_channel, nick);
if (ptr_nick)
{
if (strcmp (ptr_nick->nick, server->nick) == 0)
/* display part message */
if (!command_ignored)
{
/* part request was issued by local client */
gui_buffer_free (ptr_channel->buffer, 1);
channel_free (server, ptr_channel);
gui_draw_buffer_status (gui_current_window->buffer, 1);
gui_draw_buffer_input (gui_current_window->buffer, 1);
}
else
{
/* remove nick from nick list and display message */
nick_free (ptr_channel, ptr_nick);
if (!command_ignored)
{
pos = strchr (host, '!');
irc_display_prefix (server, ptr_channel->buffer, PREFIX_PART);
gui_printf (ptr_channel->buffer, _("%s%s %s(%s%s%s)%s has left %s%s"),
GUI_COLOR(COLOR_WIN_CHAT_NICK),
nick,
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT_HOST),
(pos) ? pos + 1 : "",
pos = strchr (host, '!');
irc_display_prefix (server, ptr_channel->buffer, PREFIX_PART);
gui_printf (ptr_channel->buffer, _("%s%s %s(%s%s%s)%s has left %s%s"),
GUI_COLOR(COLOR_WIN_CHAT_NICK),
nick,
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT_HOST),
(pos) ? pos + 1 : "",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT),
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_channel->name);
if (pos_args && pos_args[0])
gui_printf (ptr_channel->buffer, " %s(%s%s%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT),
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_channel->name);
if (pos_args && pos_args[0])
gui_printf (ptr_channel->buffer, " %s(%s%s%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT),
pos_args,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
else
gui_printf (ptr_channel->buffer, "\n");
}
pos_args,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
else
gui_printf (ptr_channel->buffer, "\n");
}
/* part request was issued by local client ? */
if (strcmp (ptr_nick->nick, server->nick) == 0)
{
nick_free_all (ptr_channel);
/* cycling ? => rejoin channel immediately */
if (ptr_channel->cycle)
{
ptr_channel->cycle = 0;
if (ptr_channel->key)
{
join_length = strlen (ptr_channel->name) + 1 +
strlen (ptr_channel->key) + 1;
join_string = (char *)malloc (join_length);
if (join_string)
{
snprintf (join_string, join_length, "%s %s",
ptr_channel->name,
ptr_channel->key);
irc_cmd_send_join(server, ptr_channel, join_string);
free (join_string);
}
else
irc_cmd_send_join(server, ptr_channel, ptr_channel->name);
}
else
irc_cmd_send_join(server, ptr_channel, ptr_channel->name);
}
if (ptr_channel->close)
{
gui_buffer_free (ptr_channel->buffer, 1);
channel_free (server, ptr_channel);
ptr_channel = NULL;
}
}
else
nick_free (ptr_channel, ptr_nick);
if (ptr_channel)
{
gui_draw_buffer_nick (ptr_channel->buffer, 1);
gui_draw_buffer_status (ptr_channel->buffer, 1);
}
gui_draw_buffer_input (gui_current_window->buffer, 1);
}
}
else
+101
View File
@@ -502,6 +502,107 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
return 0;
}
/*
* irc_cmd_send_cycle: leave and rejoin a channel
*/
int
irc_cmd_send_cycle (t_irc_server *server, t_irc_channel *channel,
char *arguments)
{
t_gui_buffer *buffer;
char *channel_name, *pos_args, *ptr_arg, *buf;
t_irc_channel *ptr_channel;
char **channels;
int i, argc;
irc_find_context (server, channel, NULL, &buffer);
if (arguments)
{
if (string_is_channel (arguments))
{
channel_name = arguments;
pos_args = strchr (arguments, ' ');
if (pos_args)
{
pos_args[0] = '\0';
pos_args++;
while (pos_args[0] == ' ')
pos_args++;
}
channels = explode_string (channel_name, ",", 0, &argc);
if (channels)
{
for (i = 0; i < argc; i++)
{
ptr_channel = channel_search (server, channels[i]);
/* mark channal as cycling */
if (ptr_channel &&
(ptr_channel->type == CHANNEL_TYPE_CHANNEL))
ptr_channel->cycle = 1;
}
free_exploded_string (channels);
}
}
else
{
if (BUFFER_IS_SERVER(buffer))
{
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s \"%s\" command can not be executed on a server buffer\n"),
WEECHAT_ERROR, "cycle");
return -1;
}
/* does nothing on private buffer (cycle has no sense!) */
if (BUFFER_IS_PRIVATE(buffer))
return 0;
channel_name = CHANNEL(buffer)->name;
pos_args = arguments;
CHANNEL(buffer)->cycle = 1;
}
}
else
{
if (BUFFER_IS_SERVER(buffer))
{
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s \"%s\" command can not be executed on a server buffer\n"),
WEECHAT_ERROR, "part");
return -1;
}
/* does nothing on private buffer (cycle has no sense!) */
if (BUFFER_IS_PRIVATE(buffer))
return 0;
channel_name = CHANNEL(buffer)->name;
pos_args = NULL;
CHANNEL(buffer)->cycle = 1;
}
ptr_arg = (pos_args) ? pos_args :
(cfg_irc_default_msg_part && cfg_irc_default_msg_part[0]) ?
cfg_irc_default_msg_part : NULL;
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
return 0;
}
/*
* irc_cmd_send_dcc: start DCC (file or chat)
*/
+4 -1
View File
@@ -111,6 +111,8 @@ struct t_irc_channel
int nicks_count; /* # nicks on channel (0 if dcc/pv) */
int checking_away; /* = 1 if checking away with WHO cmd */
char *away_message; /* to display away only once in private */
int cycle; /* currently cycling (/part then /join) */
int close; /* close request (/buffer close) */
t_irc_nick *nicks; /* nicks on the channel */
t_irc_nick *last_nick; /* last nick on the channel */
t_gui_buffer *buffer; /* GUI buffer allocated for channel */
@@ -189,7 +191,7 @@ struct t_irc_command
char *completion_template; /* template for completion */
/* NULL=no completion, ""=default (nick) */
int min_arg, max_arg; /* min & max number of arguments */
int need_connection; /* = 1 if cmd needs server connection */
int needs_connection; /* = 1 if cmd needs server connection */
int (*cmd_function_args)(t_irc_server *, t_irc_channel *, int, char **);
/* function called when user enters cmd */
int (*cmd_function_1arg)(t_irc_server *, t_irc_channel *, char *);
@@ -414,6 +416,7 @@ extern int irc_cmd_send_amsg (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_away (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_ban (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_ctcp (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_cycle (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_dcc (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_dehalfop (t_irc_server *, t_irc_channel *, int, char **);
extern int irc_cmd_send_deop (t_irc_server *, t_irc_channel *, int, char **);
+5 -1
View File
@@ -1,9 +1,13 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2006-03-18
ChangeLog - 2006-03-19
Version 0.1.9 (under dev!):
* added /cycle command, /part command does close buffer any more (use
/buffer close (or alias /close) to part and close buffer
Version 0.1.8 (2006-03-18):
* improved Ruby plugin
* fixed /set command when internal server name contains one or many dots
+541 -525
View File
File diff suppressed because it is too large Load Diff
+541 -525
View File
File diff suppressed because it is too large Load Diff
+541 -529
View File
File diff suppressed because it is too large Load Diff
+541 -525
View File
File diff suppressed because it is too large Load Diff
+543 -533
View File
File diff suppressed because it is too large Load Diff
+24 -8
View File
@@ -50,16 +50,16 @@ t_weechat_command weechat_commands[] =
"arguments: arguments for command"),
"%- %A", 0, MAX_ARGS, NULL, weechat_cmd_alias },
{ "buffer", N_("manage buffers"),
N_("[action | number | [[server] [channel]]]"),
N_("[action [args] | number | [[server] [channel]]]"),
N_(" action: action to do:\n"
" move: move buffer in the list (may be relative, for example -1)\n"
" close: close buffer (for channel: same as /part without part message)\n"
" close: close buffer (optional arg is part message, for a channel)\n"
" list: list opened buffers (no parameter implies this list)\n"
" notify: set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)\n"
"server\n"
"channel: jump to buffer by server and/or channel name\n"
" number: jump to buffer by number"),
"move|close|list|notify", 0, MAX_ARGS, weechat_cmd_buffer, NULL },
"move|close|list|notify", 0, MAX_ARGS, NULL, weechat_cmd_buffer },
{ "charset", N_("change charset for server or channel"),
N_("[(decode_iso | decode_utf | encode) charset]"),
N_("decode_iso: charset used for decoding ISO\n"
@@ -795,7 +795,7 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
}
else
{
if ((irc_commands[i].need_connection) &&
if ((irc_commands[i].needs_connection) &&
((!server) || (!server->is_connected)))
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
@@ -1215,18 +1215,20 @@ weechat_cmd_buffer_display_info (t_gui_buffer *buffer)
int
weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
int argc, char **argv)
char *arguments)
{
t_gui_window *window;
t_gui_buffer *buffer, *ptr_buffer;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
long number;
char *error;
int target_buffer;
char *error, *pos, **argv;
int argc, target_buffer;
irc_find_context (server, channel, &window, &buffer);
argv = explode_string (arguments, " ", 0, &argc);
if ((argc == 0) || ((argc == 1) && (ascii_strcasecmp (argv[0], "list") == 0)))
{
/* list opened buffers */
@@ -1255,6 +1257,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s missing arguments for \"%s\" command\n"),
WEECHAT_ERROR, "buffer");
free_exploded_string (argv);
return -1;
}
@@ -1278,6 +1281,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect buffer number\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
}
@@ -1294,6 +1298,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
gui_printf (NULL,
_("%s can not close the single buffer\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
if (BUFFER_IS_SERVER(buffer))
@@ -1305,6 +1310,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
_("%s can not close server buffer while channels "
"are opened\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
server_disconnect (SERVER(buffer), 0);
@@ -1329,9 +1335,15 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
if (SERVER(buffer)->is_connected
&& CHANNEL(buffer)
&& CHANNEL(buffer)->nicks)
{
pos = strstr (arguments, "close");
if (pos)
pos += 6;
CHANNEL(buffer)->close = 1;
irc_cmd_send_part (SERVER(buffer),
CHANNEL(buffer),
NULL);
pos);
}
else
{
ptr_channel = channel_search (SERVER(buffer),
@@ -1385,6 +1397,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect notify level (must be between %d and %d)\n"),
WEECHAT_ERROR, NOTIFY_LEVEL_MIN, NOTIFY_LEVEL_MAX);
free_exploded_string (argv);
return -1;
}
if ((!BUFFER_IS_CHANNEL(buffer))
@@ -1394,6 +1407,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect buffer for notify (must be channel or private)\n"),
WEECHAT_ERROR);
free_exploded_string (argv);
return -1;
}
buffer->notify_level = number;
@@ -1433,6 +1447,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect notify level (must be between %d and %d)\n"),
WEECHAT_ERROR, NOTIFY_LEVEL_MIN, NOTIFY_LEVEL_MAX);
free_exploded_string (argv);
return -1;
}
}
@@ -1499,6 +1514,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
}
}
free_exploded_string (argv);
return 0;
}
+1 -1
View File
@@ -74,7 +74,7 @@ extern void free_multi_command (char **);
extern int exec_weechat_command (t_irc_server *, t_irc_channel *, char *);
extern void user_command (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_alias (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_buffer (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_buffer (t_irc_server *, t_irc_channel *, char *);
extern int weechat_cmd_charset (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_clear (t_irc_server *, t_irc_channel *, int, char **);
extern int weechat_cmd_connect (t_irc_server *, t_irc_channel *, int, char **);
+8
View File
@@ -172,6 +172,8 @@ session_save_channel (FILE *file, t_irc_channel *channel)
rc = rc && (session_write_int (file, SESSION_CHAN_NICKS_COUNT, channel->nicks_count));
rc = rc && (session_write_int (file, SESSION_CHAN_CHECKING_AWAY, channel->checking_away));
rc = rc && (session_write_str (file, SESSION_CHAN_AWAY_MESSAGE, channel->away_message));
rc = rc && (session_write_int (file, SESSION_CHAN_CYCLE, channel->cycle));
rc = rc && (session_write_int (file, SESSION_CHAN_CLOSE, channel->close));
rc = rc && (session_write_id (file, SESSION_CHAN_END));
if (!rc)
@@ -1045,6 +1047,12 @@ session_load_channel (FILE *file)
case SESSION_CHAN_AWAY_MESSAGE:
rc = rc && (session_read_str (file, &(session_current_channel->away_message)));
break;
case SESSION_CHAN_CYCLE:
rc = rc && (session_read_int (file, &(session_current_channel->cycle)));
break;
case SESSION_CHAN_CLOSE:
rc = rc && (session_read_int (file, &(session_current_channel->close)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"channel (object id: %d)\n"));
+3 -1
View File
@@ -102,7 +102,9 @@ enum t_session_channel
SESSION_CHAN_KEY,
SESSION_CHAN_NICKS_COUNT,
SESSION_CHAN_CHECKING_AWAY,
SESSION_CHAN_AWAY_MESSAGE
SESSION_CHAN_AWAY_MESSAGE,
SESSION_CHAN_CYCLE,
SESSION_CHAN_CLOSE
};
enum t_session_nick
+4
View File
@@ -67,6 +67,8 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name)
new_channel->nicks_count = 0;
new_channel->checking_away = 0;
new_channel->away_message = NULL;
new_channel->cycle = 0;
new_channel->close = 0;
new_channel->nicks = NULL;
new_channel->last_nick = NULL;
@@ -493,6 +495,8 @@ channel_print_log (t_irc_channel *channel)
weechat_log_printf (" key. . . . . : '%s'\n", channel->key);
weechat_log_printf (" checking_away: %d\n", channel->checking_away);
weechat_log_printf (" away_message : '%s'\n", channel->away_message);
weechat_log_printf (" cycle. . . . : %d\n", channel->cycle);
weechat_log_printf (" close. . . . : %d\n", channel->close);
weechat_log_printf (" nicks. . . . : 0x%X\n", channel->nicks);
weechat_log_printf (" last_nick. . : 0x%X\n", channel->last_nick);
weechat_log_printf (" buffer . . . : 0x%X\n", channel->buffer);
+5
View File
@@ -59,6 +59,11 @@ t_irc_command irc_commands[] =
" type: CTCP type (examples: \"version\", \"ping\", ..)\n"
"arguments: arguments for CTCP"),
"%n action|ping|version", 2, MAX_ARGS, 1, NULL, irc_cmd_send_ctcp, NULL },
{ "cycle", N_("leave and rejoin a channel"),
N_("[channel[,channel]] [part_message]"),
N_(" channel: channel name for cycle\n"
"part_message: part message (displayed to other users)"),
"%p", 0, MAX_ARGS, 1, NULL, irc_cmd_send_cycle, NULL },
{ "dcc", N_("starts DCC (file or chat) or close chat"),
N_("action [nickname [file]]"),
N_(" action: 'send' (file) or 'chat' or 'close' (chat)\n"
+64 -34
View File
@@ -1414,7 +1414,8 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
int
irc_cmd_recv_part (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos, *pos_args;
char *pos, *pos_args, *join_string;
int join_length;
t_irc_channel *ptr_channel;
t_irc_nick *ptr_nick;
@@ -1446,46 +1447,75 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *nick, char *arguments
ptr_nick = nick_search (ptr_channel, nick);
if (ptr_nick)
{
if (strcmp (ptr_nick->nick, server->nick) == 0)
/* display part message */
if (!command_ignored)
{
/* part request was issued by local client */
gui_buffer_free (ptr_channel->buffer, 1);
channel_free (server, ptr_channel);
gui_draw_buffer_status (gui_current_window->buffer, 1);
gui_draw_buffer_input (gui_current_window->buffer, 1);
}
else
{
/* remove nick from nick list and display message */
nick_free (ptr_channel, ptr_nick);
if (!command_ignored)
{
pos = strchr (host, '!');
irc_display_prefix (server, ptr_channel->buffer, PREFIX_PART);
gui_printf (ptr_channel->buffer, _("%s%s %s(%s%s%s)%s has left %s%s"),
GUI_COLOR(COLOR_WIN_CHAT_NICK),
nick,
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT_HOST),
(pos) ? pos + 1 : "",
pos = strchr (host, '!');
irc_display_prefix (server, ptr_channel->buffer, PREFIX_PART);
gui_printf (ptr_channel->buffer, _("%s%s %s(%s%s%s)%s has left %s%s"),
GUI_COLOR(COLOR_WIN_CHAT_NICK),
nick,
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT_HOST),
(pos) ? pos + 1 : "",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT),
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_channel->name);
if (pos_args && pos_args[0])
gui_printf (ptr_channel->buffer, " %s(%s%s%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT),
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
ptr_channel->name);
if (pos_args && pos_args[0])
gui_printf (ptr_channel->buffer, " %s(%s%s%s)\n",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
GUI_COLOR(COLOR_WIN_CHAT),
pos_args,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
else
gui_printf (ptr_channel->buffer, "\n");
}
pos_args,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
else
gui_printf (ptr_channel->buffer, "\n");
}
/* part request was issued by local client ? */
if (strcmp (ptr_nick->nick, server->nick) == 0)
{
nick_free_all (ptr_channel);
/* cycling ? => rejoin channel immediately */
if (ptr_channel->cycle)
{
ptr_channel->cycle = 0;
if (ptr_channel->key)
{
join_length = strlen (ptr_channel->name) + 1 +
strlen (ptr_channel->key) + 1;
join_string = (char *)malloc (join_length);
if (join_string)
{
snprintf (join_string, join_length, "%s %s",
ptr_channel->name,
ptr_channel->key);
irc_cmd_send_join(server, ptr_channel, join_string);
free (join_string);
}
else
irc_cmd_send_join(server, ptr_channel, ptr_channel->name);
}
else
irc_cmd_send_join(server, ptr_channel, ptr_channel->name);
}
if (ptr_channel->close)
{
gui_buffer_free (ptr_channel->buffer, 1);
channel_free (server, ptr_channel);
ptr_channel = NULL;
}
}
else
nick_free (ptr_channel, ptr_nick);
if (ptr_channel)
{
gui_draw_buffer_nick (ptr_channel->buffer, 1);
gui_draw_buffer_status (ptr_channel->buffer, 1);
}
gui_draw_buffer_input (gui_current_window->buffer, 1);
}
}
else
+101
View File
@@ -502,6 +502,107 @@ irc_cmd_send_ctcp (t_irc_server *server, t_irc_channel *channel,
return 0;
}
/*
* irc_cmd_send_cycle: leave and rejoin a channel
*/
int
irc_cmd_send_cycle (t_irc_server *server, t_irc_channel *channel,
char *arguments)
{
t_gui_buffer *buffer;
char *channel_name, *pos_args, *ptr_arg, *buf;
t_irc_channel *ptr_channel;
char **channels;
int i, argc;
irc_find_context (server, channel, NULL, &buffer);
if (arguments)
{
if (string_is_channel (arguments))
{
channel_name = arguments;
pos_args = strchr (arguments, ' ');
if (pos_args)
{
pos_args[0] = '\0';
pos_args++;
while (pos_args[0] == ' ')
pos_args++;
}
channels = explode_string (channel_name, ",", 0, &argc);
if (channels)
{
for (i = 0; i < argc; i++)
{
ptr_channel = channel_search (server, channels[i]);
/* mark channal as cycling */
if (ptr_channel &&
(ptr_channel->type == CHANNEL_TYPE_CHANNEL))
ptr_channel->cycle = 1;
}
free_exploded_string (channels);
}
}
else
{
if (BUFFER_IS_SERVER(buffer))
{
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s \"%s\" command can not be executed on a server buffer\n"),
WEECHAT_ERROR, "cycle");
return -1;
}
/* does nothing on private buffer (cycle has no sense!) */
if (BUFFER_IS_PRIVATE(buffer))
return 0;
channel_name = CHANNEL(buffer)->name;
pos_args = arguments;
CHANNEL(buffer)->cycle = 1;
}
}
else
{
if (BUFFER_IS_SERVER(buffer))
{
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s \"%s\" command can not be executed on a server buffer\n"),
WEECHAT_ERROR, "part");
return -1;
}
/* does nothing on private buffer (cycle has no sense!) */
if (BUFFER_IS_PRIVATE(buffer))
return 0;
channel_name = CHANNEL(buffer)->name;
pos_args = NULL;
CHANNEL(buffer)->cycle = 1;
}
ptr_arg = (pos_args) ? pos_args :
(cfg_irc_default_msg_part && cfg_irc_default_msg_part[0]) ?
cfg_irc_default_msg_part : NULL;
if (ptr_arg)
{
buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
server_sendf (server, "PART %s :%s\r\n", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
}
else
server_sendf (server, "PART %s\r\n", channel_name);
return 0;
}
/*
* irc_cmd_send_dcc: start DCC (file or chat)
*/
+4 -1
View File
@@ -111,6 +111,8 @@ struct t_irc_channel
int nicks_count; /* # nicks on channel (0 if dcc/pv) */
int checking_away; /* = 1 if checking away with WHO cmd */
char *away_message; /* to display away only once in private */
int cycle; /* currently cycling (/part then /join) */
int close; /* close request (/buffer close) */
t_irc_nick *nicks; /* nicks on the channel */
t_irc_nick *last_nick; /* last nick on the channel */
t_gui_buffer *buffer; /* GUI buffer allocated for channel */
@@ -189,7 +191,7 @@ struct t_irc_command
char *completion_template; /* template for completion */
/* NULL=no completion, ""=default (nick) */
int min_arg, max_arg; /* min & max number of arguments */
int need_connection; /* = 1 if cmd needs server connection */
int needs_connection; /* = 1 if cmd needs server connection */
int (*cmd_function_args)(t_irc_server *, t_irc_channel *, int, char **);
/* function called when user enters cmd */
int (*cmd_function_1arg)(t_irc_server *, t_irc_channel *, char *);
@@ -414,6 +416,7 @@ extern int irc_cmd_send_amsg (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_away (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_ban (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_ctcp (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_cycle (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_dcc (t_irc_server *, t_irc_channel *, char *);
extern int irc_cmd_send_dehalfop (t_irc_server *, t_irc_channel *, int, char **);
extern int irc_cmd_send_deop (t_irc_server *, t_irc_channel *, int, char **);