aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weechat/TODO.txt1
-rw-r--r--weechat/tomsg.c21
2 files changed, 18 insertions, 4 deletions
diff --git a/weechat/TODO.txt b/weechat/TODO.txt
deleted file mode 100644
index 7f8db51..0000000
--- a/weechat/TODO.txt
+++ /dev/null
@@ -1 +0,0 @@
-- buffer_set(buffer, "notify", "2") on chats with 2 people
diff --git a/weechat/tomsg.c b/weechat/tomsg.c
index c860aea..9c92543 100644
--- a/weechat/tomsg.c
+++ b/weechat/tomsg.c
@@ -24,6 +24,7 @@ struct roomdata{
char *name;
struct t_gui_buffer *buffer;
struct t_gui_nick_group *buffer_nickgroup;
+ int nmembers;
struct conndata *conn; // do not free
};
@@ -50,6 +51,18 @@ static struct t_weechat_plugin *weechat_plugin;
static struct t_hashtable *conntable;
+static void room_update_attributes(struct roomdata *room){
+ bool private=room->nmembers<=2;
+ weechat_buffer_set(room->buffer,"localvar_set_type",private?"private":"channel");
+ weechat_buffer_set(room->buffer,"notify",private?"2":"1");
+ fprintf(debugf,"room_update_attributes: set private for room %s to %d\n",room->name,private);
+ if(room->conn->username){
+ weechat_buffer_set(room->buffer,"localvar_set_nick",room->conn->username);
+ } else {
+ weechat_buffer_set(room->buffer,"localvar_del_nick","");
+ }
+}
+
static void close_room(struct roomdata *room){
fprintf(debugf,"close_room(room=%p)\n",room);
free(room->name);
@@ -108,11 +121,9 @@ static void create_room_buffer(struct roomdata *room){
weechat_buffer_set(room->buffer,"nicklist","1");
weechat_buffer_set(room->buffer,"nicklist_case_sensitive","1");
weechat_buffer_set(room->buffer,"nicklist_display_groups","0");
- if(room->conn->username){
- weechat_buffer_set(room->buffer,"localvar_set_nick",room->conn->username);
- }
room->buffer_nickgroup=NULL;
+ room_update_attributes(room);
}
static void history_net_callback(int fd,struct net_response res,void *payload){
@@ -141,6 +152,8 @@ static void members_net_callback(int fd,struct net_response res,void *payload){
"","chat_nick",
1);
}
+ room->nmembers=res.nitems;
+ room_update_attributes(room);
}
static void push_net_callback(int fd,struct net_response res,void *payload){
@@ -177,6 +190,8 @@ static void push_net_callback(int fd,struct net_response res,void *payload){
"","chat_nick",
1);
}
+ room->nmembers++;
+ room_update_attributes(room);
} else if(res.type==NET_INVITE){
weechat_printf(room->buffer,"%sYou were invited into this room",netpfx);
net_sendf(fd,history_net_callback,room,"history %s 10",room->name);