1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

Added IRC command 329 (channel creation date)

This commit is contained in:
Sebastien Helleu
2006-08-17 13:23:31 +00:00
parent 9f88f68e3b
commit 487d776b87
28 changed files with 3798 additions and 3486 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ Version 0.2.0 (under dev!):
* fixed command 348 (channel exception list, received by /mode #chan e)
* added missing modes (channel & user), now all modes are allowed (bug #16606)
* added "%m" for completion with self nick (on current server)
* added missing IRC commands (310, 326, 338)
* added missing IRC commands (310, 326, 329, 338)
* fixed DCC restore after /upgrade (order is now correctly saved)
* fixed away after server disconnection (now away is set again when
reconnecting) (bug #16359)
+257 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+256 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+260 -250
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -176,6 +176,7 @@ session_save_channel (FILE *file, t_irc_channel *channel)
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_int (file, SESSION_CHAN_DISPLAY_CREATION_DATE, channel->display_creation_date));
rc = rc && (session_write_id (file, SESSION_CHAN_END));
if (!rc)
@@ -1072,6 +1073,9 @@ session_load_channel (FILE *file)
case SESSION_CHAN_CLOSE:
rc = rc && (session_read_int (file, &(session_current_channel->close)));
break;
case SESSION_CHAN_DISPLAY_CREATION_DATE:
rc = rc && (session_read_int (file, &(session_current_channel->display_creation_date)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"channel (object id: %d)\n"));
+2 -1
View File
@@ -107,7 +107,8 @@ enum t_session_channel
SESSION_CHAN_CHECKING_AWAY,
SESSION_CHAN_AWAY_MESSAGE,
SESSION_CHAN_CYCLE,
SESSION_CHAN_CLOSE
SESSION_CHAN_CLOSE,
SESSION_CHAN_DISPLAY_CREATION_DATE
};
enum t_session_nick
+17 -15
View File
@@ -69,6 +69,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name)
new_channel->away_message = NULL;
new_channel->cycle = 0;
new_channel->close = 0;
new_channel->display_creation_date = 0;
new_channel->nicks = NULL;
new_channel->last_nick = NULL;
@@ -547,19 +548,20 @@ void
channel_print_log (t_irc_channel *channel)
{
weechat_log_printf ("=> channel %s (addr:0x%X)]\n", channel->name, channel);
weechat_log_printf (" type . . . . : %d\n", channel->type);
weechat_log_printf (" dcc_chat . . : 0x%X\n", channel->dcc_chat);
weechat_log_printf (" topic. . . . : '%s'\n", channel->topic);
weechat_log_printf (" modes. . . . : '%s'\n", channel->modes);
weechat_log_printf (" limit. . . . : %d\n", channel->limit);
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);
weechat_log_printf (" prev_channel : 0x%X\n", channel->prev_channel);
weechat_log_printf (" next_channel : 0x%X\n", channel->next_channel);
weechat_log_printf (" type . . . . . . . . : %d\n", channel->type);
weechat_log_printf (" dcc_chat . . . . . . : 0x%X\n", channel->dcc_chat);
weechat_log_printf (" topic. . . . . . . . : '%s'\n", channel->topic);
weechat_log_printf (" modes. . . . . . . . : '%s'\n", channel->modes);
weechat_log_printf (" limit. . . . . . . . : %d\n", channel->limit);
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 (" display_creation_date: %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);
weechat_log_printf (" prev_channel . . . . : 0x%X\n", channel->prev_channel);
weechat_log_printf (" next_channel . . . . : 0x%X\n", channel->next_channel);
}
+2
View File
@@ -351,6 +351,8 @@ t_irc_command irc_commands[] =
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_324 },
{ "326", N_("whois (has oper privs)"), "", "",
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_whois_nick_msg },
{ "329", N_("channel creation date"), "", "",
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_329 },
{ "331", N_("no topic for channel"), "", "",
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_331 },
{ "332", N_("topic of channel"),
+70
View File
@@ -474,6 +474,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
arguments);
}
ptr_channel->display_creation_date = 1;
ptr_nick = nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0);
if (ptr_nick)
ptr_nick->host = strdup ((pos) ? pos + 1 : host);
@@ -3361,6 +3362,75 @@ irc_cmd_recv_324 (t_irc_server *server, char *host, char *nick, char *arguments)
return 0;
}
/*
* irc_cmd_recv_329: '329' command received (channel creation date)
*/
int
irc_cmd_recv_329 (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos_channel, *pos_date;
t_irc_channel *ptr_channel;
time_t datetime;
/* make gcc happy */
(void) host;
(void) nick;
pos_channel = strchr (arguments, ' ');
if (pos_channel)
{
while (pos_channel[0] == ' ')
pos_channel++;
pos_date = strchr (pos_channel, ' ');
if (pos_date)
{
pos_date[0] = '\0';
pos_date++;
while (pos_date[0] == ' ')
pos_date++;
ptr_channel = channel_search (server, pos_channel);
if (!ptr_channel)
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s channel \"%s\" not found for \"%s\" command\n"),
WEECHAT_ERROR, pos_channel, "329");
return -1;
}
command_ignored |= ignore_check (host, "329",
pos_channel, server->name);
if (!command_ignored && (ptr_channel->display_creation_date))
{
datetime = (time_t)(atol (pos_date));
irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO);
gui_printf (ptr_channel->buffer, _("Channel created on %s"),
ctime (&datetime));
}
ptr_channel->display_creation_date = 0;
}
else
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s cannot identify date/time for \"%s\" command\n"),
WEECHAT_ERROR, "329");
return -1;
}
}
else
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s cannot identify channel for \"%s\" command\n"),
WEECHAT_ERROR, "329");
return -1;
}
return 0;
}
/*
* irc_cmd_recv_331: '331' command received (no topic for channel)
*/
+2
View File
@@ -101,6 +101,7 @@ struct t_irc_channel
char *away_message; /* to display away only once in private */
int cycle; /* currently cycling (/part then /join) */
int close; /* close request (/buffer close) */
int display_creation_date; /* 1 if creation date should be displayed */
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 */
@@ -543,6 +544,7 @@ extern int irc_cmd_recv_321 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_322 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_323 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_324 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_329 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_331 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_332 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_333 (t_irc_server *, char *, char *, char *);
+1 -1
View File
@@ -9,7 +9,7 @@ Version 0.2.0 (under dev!):
* fixed command 348 (channel exception list, received by /mode #chan e)
* added missing modes (channel & user), now all modes are allowed (bug #16606)
* added "%m" for completion with self nick (on current server)
* added missing IRC commands (310, 326, 338)
* added missing IRC commands (310, 326, 329, 338)
* fixed DCC restore after /upgrade (order is now correctly saved)
* fixed away after server disconnection (now away is set again when
reconnecting) (bug #16359)
+257 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+256 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+257 -246
View File
File diff suppressed because it is too large Load Diff
+260 -250
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -176,6 +176,7 @@ session_save_channel (FILE *file, t_irc_channel *channel)
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_int (file, SESSION_CHAN_DISPLAY_CREATION_DATE, channel->display_creation_date));
rc = rc && (session_write_id (file, SESSION_CHAN_END));
if (!rc)
@@ -1072,6 +1073,9 @@ session_load_channel (FILE *file)
case SESSION_CHAN_CLOSE:
rc = rc && (session_read_int (file, &(session_current_channel->close)));
break;
case SESSION_CHAN_DISPLAY_CREATION_DATE:
rc = rc && (session_read_int (file, &(session_current_channel->display_creation_date)));
break;
default:
weechat_log_printf (_("session: warning: ignoring value from "
"channel (object id: %d)\n"));
+2 -1
View File
@@ -107,7 +107,8 @@ enum t_session_channel
SESSION_CHAN_CHECKING_AWAY,
SESSION_CHAN_AWAY_MESSAGE,
SESSION_CHAN_CYCLE,
SESSION_CHAN_CLOSE
SESSION_CHAN_CLOSE,
SESSION_CHAN_DISPLAY_CREATION_DATE
};
enum t_session_nick
+17 -15
View File
@@ -69,6 +69,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name)
new_channel->away_message = NULL;
new_channel->cycle = 0;
new_channel->close = 0;
new_channel->display_creation_date = 0;
new_channel->nicks = NULL;
new_channel->last_nick = NULL;
@@ -547,19 +548,20 @@ void
channel_print_log (t_irc_channel *channel)
{
weechat_log_printf ("=> channel %s (addr:0x%X)]\n", channel->name, channel);
weechat_log_printf (" type . . . . : %d\n", channel->type);
weechat_log_printf (" dcc_chat . . : 0x%X\n", channel->dcc_chat);
weechat_log_printf (" topic. . . . : '%s'\n", channel->topic);
weechat_log_printf (" modes. . . . : '%s'\n", channel->modes);
weechat_log_printf (" limit. . . . : %d\n", channel->limit);
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);
weechat_log_printf (" prev_channel : 0x%X\n", channel->prev_channel);
weechat_log_printf (" next_channel : 0x%X\n", channel->next_channel);
weechat_log_printf (" type . . . . . . . . : %d\n", channel->type);
weechat_log_printf (" dcc_chat . . . . . . : 0x%X\n", channel->dcc_chat);
weechat_log_printf (" topic. . . . . . . . : '%s'\n", channel->topic);
weechat_log_printf (" modes. . . . . . . . : '%s'\n", channel->modes);
weechat_log_printf (" limit. . . . . . . . : %d\n", channel->limit);
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 (" display_creation_date: %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);
weechat_log_printf (" prev_channel . . . . : 0x%X\n", channel->prev_channel);
weechat_log_printf (" next_channel . . . . : 0x%X\n", channel->next_channel);
}
+2
View File
@@ -351,6 +351,8 @@ t_irc_command irc_commands[] =
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_324 },
{ "326", N_("whois (has oper privs)"), "", "",
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_whois_nick_msg },
{ "329", N_("channel creation date"), "", "",
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_329 },
{ "331", N_("no topic for channel"), "", "",
NULL, 0, 0, 0, 1, NULL, NULL, irc_cmd_recv_331 },
{ "332", N_("topic of channel"),
+70
View File
@@ -474,6 +474,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
arguments);
}
ptr_channel->display_creation_date = 1;
ptr_nick = nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0);
if (ptr_nick)
ptr_nick->host = strdup ((pos) ? pos + 1 : host);
@@ -3361,6 +3362,75 @@ irc_cmd_recv_324 (t_irc_server *server, char *host, char *nick, char *arguments)
return 0;
}
/*
* irc_cmd_recv_329: '329' command received (channel creation date)
*/
int
irc_cmd_recv_329 (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos_channel, *pos_date;
t_irc_channel *ptr_channel;
time_t datetime;
/* make gcc happy */
(void) host;
(void) nick;
pos_channel = strchr (arguments, ' ');
if (pos_channel)
{
while (pos_channel[0] == ' ')
pos_channel++;
pos_date = strchr (pos_channel, ' ');
if (pos_date)
{
pos_date[0] = '\0';
pos_date++;
while (pos_date[0] == ' ')
pos_date++;
ptr_channel = channel_search (server, pos_channel);
if (!ptr_channel)
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s channel \"%s\" not found for \"%s\" command\n"),
WEECHAT_ERROR, pos_channel, "329");
return -1;
}
command_ignored |= ignore_check (host, "329",
pos_channel, server->name);
if (!command_ignored && (ptr_channel->display_creation_date))
{
datetime = (time_t)(atol (pos_date));
irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO);
gui_printf (ptr_channel->buffer, _("Channel created on %s"),
ctime (&datetime));
}
ptr_channel->display_creation_date = 0;
}
else
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s cannot identify date/time for \"%s\" command\n"),
WEECHAT_ERROR, "329");
return -1;
}
}
else
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
gui_printf_nolog (server->buffer,
_("%s cannot identify channel for \"%s\" command\n"),
WEECHAT_ERROR, "329");
return -1;
}
return 0;
}
/*
* irc_cmd_recv_331: '331' command received (no topic for channel)
*/
+2
View File
@@ -101,6 +101,7 @@ struct t_irc_channel
char *away_message; /* to display away only once in private */
int cycle; /* currently cycling (/part then /join) */
int close; /* close request (/buffer close) */
int display_creation_date; /* 1 if creation date should be displayed */
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 */
@@ -543,6 +544,7 @@ extern int irc_cmd_recv_321 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_322 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_323 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_324 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_329 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_331 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_332 (t_irc_server *, char *, char *, char *);
extern int irc_cmd_recv_333 (t_irc_server *, char *, char *, char *);