1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 23:36:37 +02:00

Away now announced in channels, and config option "look_display_away" added to enable/disable this feature

This commit is contained in:
Sebastien Helleu
2004-09-12 17:22:45 +00:00
parent 6100af949b
commit 0e47caf091
10 changed files with 190 additions and 16 deletions
+3 -1
View File
@@ -1,10 +1,12 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2004-09-08
ChangeLog - 2004-09-12
Version 0.0.8 (under dev!):
* Away now announced in channels, and config option "look_display_away" added
to enable/disable this feature
* Fixed crash when resizing terminal to very small size
* "-MORE-" message is now erased when switching to another buffer
* DCC window with Alt-D
+5
View File
@@ -73,6 +73,7 @@ int cfg_look_nickmode;
int cfg_look_nickmode_empty;
char *cfg_look_no_nickname;
char *cfg_look_completor;
int cfg_look_display_away;
int cfg_look_infobar;
char *cfg_look_infobar_timestamp;
int cfg_look_infobar_delay_highlight;
@@ -140,6 +141,10 @@ t_config_option weechat_options_look[] =
N_("the string inserted after nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
":", NULL, NULL, &cfg_look_completor, config_change_noop },
{ "look_display_away", N_("display message to all channels when away"),
N_("display message to all channels when (un)marking as away"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
NULL, NULL, &cfg_look_display_away, NULL, config_change_noop },
{ "look_infobar", N_("enable info bar"),
N_("enable info bar"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
+1
View File
@@ -88,6 +88,7 @@ extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern int cfg_look_display_away;
extern int cfg_look_infobar;
extern char *cfg_look_infobar_timestamp;
extern int cfg_look_infobar_delay_highlight;
+82 -7
View File
@@ -89,6 +89,8 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
{
char *pos;
t_irc_server *ptr_server;
time_t elapsed;
char buffer[4096];
if (arguments && (strncmp (arguments, "-all", 4) == 0))
{
@@ -104,18 +106,62 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
if (ptr_server->is_connected)
{
if (pos)
{
ptr_server->is_away = 1;
ptr_server->away_time = time (NULL);
server_sendf (ptr_server, "AWAY :%s\r\n", pos);
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer), "is away: %s", pos);
irc_send_me_all_channels (ptr_server, buffer);
}
}
else
{
server_sendf (ptr_server, "AWAY\r\n");
ptr_server->is_away = 0;
elapsed = time (NULL) - ptr_server->away_time;
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer),
"is back (gone %.2ld:%.2ld:%.2ld)",
elapsed / 3600,
(elapsed / 60) % 60,
elapsed % 60);
irc_send_me_all_channels (ptr_server, buffer);
}
}
}
}
}
else
{
if (arguments)
{
server->is_away = 1;
server->away_time = time (NULL);
server_sendf (server, "AWAY :%s\r\n", arguments);
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer), "is away: %s", arguments);
irc_send_me_all_channels (server, buffer);
}
}
else
{
server_sendf (server, "AWAY\r\n");
server->is_away = 0;
elapsed = time (NULL) - server->away_time;
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer),
"is back (gone %.2ld:%.2ld:%.2ld)",
elapsed / 3600,
(elapsed / 60) % 60,
elapsed % 60);
irc_send_me_all_channels (server, buffer);
}
}
}
return 0;
}
@@ -381,6 +427,41 @@ irc_cmd_send_lusers (t_irc_server *server, char *arguments)
return 0;
}
/*
* irc_send_me: send a ctcp action to a channel
*/
int
irc_send_me (t_irc_server *server, t_irc_channel *channel, char *arguments)
{
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
channel->name, arguments);
irc_display_prefix (channel->buffer, PREFIX_ACTION_ME);
gui_printf_color (channel->buffer,
COLOR_WIN_CHAT_NICK, "%s", server->nick);
gui_printf_color (channel->buffer,
COLOR_WIN_CHAT, " %s\n", arguments);
return 0;
}
/*
* irc_send_me_all_channels: send a ctcp action to all channels of a server
*/
int
irc_send_me_all_channels (t_irc_server *server, char *arguments)
{
t_irc_channel *ptr_channel;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel->type == CHAT_CHANNEL)
irc_send_me (server, ptr_channel, arguments);
}
return 0;
}
/*
* irc_cmd_send_me: send a ctcp action to the current channel
*/
@@ -395,13 +476,7 @@ irc_cmd_send_me (t_irc_server *server, char *arguments)
WEECHAT_ERROR, "me");
return -1;
}
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
CHANNEL(gui_current_window->buffer)->name, arguments);
irc_display_prefix (gui_current_window->buffer, PREFIX_ACTION_ME);
gui_printf_color (gui_current_window->buffer,
COLOR_WIN_CHAT_NICK, "%s", server->nick);
gui_printf_color (gui_current_window->buffer,
COLOR_WIN_CHAT, " %s\n", arguments);
irc_send_me (server, CHANNEL(gui_current_window->buffer), arguments);
return 0;
}
+4
View File
@@ -21,6 +21,7 @@
#ifndef __WEECHAT_IRC_H
#define __WEECHAT_IRC_H 1
#include <time.h>
#include "../gui/gui.h"
/* prefixes for chat window */
@@ -132,6 +133,7 @@ struct t_irc_server
int is_connected; /* 1 if WeeChat is connected to server */
int sock4; /* socket for server */
int is_away; /* 1 is user is marker as away */
time_t away_time; /* time() when user marking as away */
int server_read; /* pipe for reading server data */
int server_write; /* pipe for sending data to server */
t_gui_buffer *buffer; /* GUI buffer allocated for server */
@@ -279,6 +281,8 @@ 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 *);
extern int irc_cmd_send_lusers (t_irc_server *, char *);
extern int irc_send_me (t_irc_server *, t_irc_channel *, char *);
extern int irc_send_me_all_channels (t_irc_server *, char *);
extern int irc_cmd_send_me (t_irc_server *, char *);
extern int irc_cmd_send_mode (t_irc_server *, char *);
extern int irc_cmd_send_motd (t_irc_server *, char *);
+3 -1
View File
@@ -1,10 +1,12 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2004-09-08
ChangeLog - 2004-09-12
Version 0.0.8 (under dev!):
* Away now announced in channels, and config option "look_display_away" added
to enable/disable this feature
* Fixed crash when resizing terminal to very small size
* "-MORE-" message is now erased when switching to another buffer
* DCC window with Alt-D
+5
View File
@@ -73,6 +73,7 @@ int cfg_look_nickmode;
int cfg_look_nickmode_empty;
char *cfg_look_no_nickname;
char *cfg_look_completor;
int cfg_look_display_away;
int cfg_look_infobar;
char *cfg_look_infobar_timestamp;
int cfg_look_infobar_delay_highlight;
@@ -140,6 +141,10 @@ t_config_option weechat_options_look[] =
N_("the string inserted after nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
":", NULL, NULL, &cfg_look_completor, config_change_noop },
{ "look_display_away", N_("display message to all channels when away"),
N_("display message to all channels when (un)marking as away"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
NULL, NULL, &cfg_look_display_away, NULL, config_change_noop },
{ "look_infobar", N_("enable info bar"),
N_("enable info bar"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
+1
View File
@@ -88,6 +88,7 @@ extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern int cfg_look_display_away;
extern int cfg_look_infobar;
extern char *cfg_look_infobar_timestamp;
extern int cfg_look_infobar_delay_highlight;
+82 -7
View File
@@ -89,6 +89,8 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
{
char *pos;
t_irc_server *ptr_server;
time_t elapsed;
char buffer[4096];
if (arguments && (strncmp (arguments, "-all", 4) == 0))
{
@@ -104,18 +106,62 @@ irc_cmd_send_away (t_irc_server *server, char *arguments)
if (ptr_server->is_connected)
{
if (pos)
{
ptr_server->is_away = 1;
ptr_server->away_time = time (NULL);
server_sendf (ptr_server, "AWAY :%s\r\n", pos);
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer), "is away: %s", pos);
irc_send_me_all_channels (ptr_server, buffer);
}
}
else
{
server_sendf (ptr_server, "AWAY\r\n");
ptr_server->is_away = 0;
elapsed = time (NULL) - ptr_server->away_time;
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer),
"is back (gone %.2ld:%.2ld:%.2ld)",
elapsed / 3600,
(elapsed / 60) % 60,
elapsed % 60);
irc_send_me_all_channels (ptr_server, buffer);
}
}
}
}
}
else
{
if (arguments)
{
server->is_away = 1;
server->away_time = time (NULL);
server_sendf (server, "AWAY :%s\r\n", arguments);
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer), "is away: %s", arguments);
irc_send_me_all_channels (server, buffer);
}
}
else
{
server_sendf (server, "AWAY\r\n");
server->is_away = 0;
elapsed = time (NULL) - server->away_time;
if (cfg_look_display_away)
{
snprintf (buffer, sizeof (buffer),
"is back (gone %.2ld:%.2ld:%.2ld)",
elapsed / 3600,
(elapsed / 60) % 60,
elapsed % 60);
irc_send_me_all_channels (server, buffer);
}
}
}
return 0;
}
@@ -381,6 +427,41 @@ irc_cmd_send_lusers (t_irc_server *server, char *arguments)
return 0;
}
/*
* irc_send_me: send a ctcp action to a channel
*/
int
irc_send_me (t_irc_server *server, t_irc_channel *channel, char *arguments)
{
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
channel->name, arguments);
irc_display_prefix (channel->buffer, PREFIX_ACTION_ME);
gui_printf_color (channel->buffer,
COLOR_WIN_CHAT_NICK, "%s", server->nick);
gui_printf_color (channel->buffer,
COLOR_WIN_CHAT, " %s\n", arguments);
return 0;
}
/*
* irc_send_me_all_channels: send a ctcp action to all channels of a server
*/
int
irc_send_me_all_channels (t_irc_server *server, char *arguments)
{
t_irc_channel *ptr_channel;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel->type == CHAT_CHANNEL)
irc_send_me (server, ptr_channel, arguments);
}
return 0;
}
/*
* irc_cmd_send_me: send a ctcp action to the current channel
*/
@@ -395,13 +476,7 @@ irc_cmd_send_me (t_irc_server *server, char *arguments)
WEECHAT_ERROR, "me");
return -1;
}
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
CHANNEL(gui_current_window->buffer)->name, arguments);
irc_display_prefix (gui_current_window->buffer, PREFIX_ACTION_ME);
gui_printf_color (gui_current_window->buffer,
COLOR_WIN_CHAT_NICK, "%s", server->nick);
gui_printf_color (gui_current_window->buffer,
COLOR_WIN_CHAT, " %s\n", arguments);
irc_send_me (server, CHANNEL(gui_current_window->buffer), arguments);
return 0;
}
+4
View File
@@ -21,6 +21,7 @@
#ifndef __WEECHAT_IRC_H
#define __WEECHAT_IRC_H 1
#include <time.h>
#include "../gui/gui.h"
/* prefixes for chat window */
@@ -132,6 +133,7 @@ struct t_irc_server
int is_connected; /* 1 if WeeChat is connected to server */
int sock4; /* socket for server */
int is_away; /* 1 is user is marker as away */
time_t away_time; /* time() when user marking as away */
int server_read; /* pipe for reading server data */
int server_write; /* pipe for sending data to server */
t_gui_buffer *buffer; /* GUI buffer allocated for server */
@@ -279,6 +281,8 @@ 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 *);
extern int irc_cmd_send_lusers (t_irc_server *, char *);
extern int irc_send_me (t_irc_server *, t_irc_channel *, char *);
extern int irc_send_me_all_channels (t_irc_server *, char *);
extern int irc_cmd_send_me (t_irc_server *, char *);
extern int irc_cmd_send_mode (t_irc_server *, char *);
extern int irc_cmd_send_motd (t_irc_server *, char *);