From 96d4db275fb6d6ed96096e489d46d6a31a31ea5e Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 8 Aug 2020 22:12:48 +0200 Subject: weechat: Better message line tagging for notify/log --- weechat/tomsg.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/weechat/tomsg.c b/weechat/tomsg.c index 03f0f5e..b56b08c 100644 --- a/weechat/tomsg.c +++ b/weechat/tomsg.c @@ -75,12 +75,17 @@ static void display_message( const char *message, int64_t msgid, bool is_reply, - bool is_history + bool is_history, + bool is_self_msg ) { char tags[128]; - snprintf(tags, sizeof tags, "tomsgid_%" PRIi64 "%s%s", + snprintf(tags, sizeof tags, "tomsgid_%" PRIi64 ",nick_%s,log1%s%s", msgid, - room->nmembers == 2 && !is_history ? ",notify_private" : ",notify_message", + username, + is_history ? ",notify_none,no_log" + : is_self_msg ? ",notify_none" + : room->nmembers == 2 ? ",notify_private" + : ",notify_message", is_reply ? ",tomsg_reply" : ""); weechat_printf_date_tags( @@ -352,7 +357,7 @@ static int room_input_cb(const void *room_vp,void *_d,struct t_gui_buffer *buffe payload->ids[0]=room->next_pending_id++; payload->replyid=-1; net_sendf(conn->fd,message_net_callback,payload,"send %s -1 %s",room->name,tosend); - display_message(room,gettimestamp(),conn->username,tosend,-payload->ids[0],false,false); + display_message(room,gettimestamp(),conn->username,tosend,-payload->ids[0],false,false,true); if(free_tosend){ free((void*)tosend); @@ -470,8 +475,8 @@ static void push_net_callback(int fd,struct net_response res,void *payload){ debugf("Found reply msgid=%" PRIi64 " replyid=%" PRIi64 "\n",res.msgid,res.replyid); char str[128]; snprintf(str,sizeof str,"%s> ...",weechat_color("green")); - display_message(room,res.timestamp,res.username,str,res.msgid,true,res.type==NET_HISTORY); - display_message(room,res.timestamp,"",res.message,res.msgid,false,res.type==NET_HISTORY); + display_message(room,res.timestamp,res.username,str,res.msgid,true,res.type==NET_HISTORY,false); + display_message(room,res.timestamp,"",res.message,res.msgid,false,res.type==NET_HISTORY,false); struct room_and_msgid *payload=malloc(sizeof(struct room_and_msgid)); assert(payload); @@ -479,7 +484,7 @@ static void push_net_callback(int fd,struct net_response res,void *payload){ payload->msgid=res.msgid; net_sendf(fd,reply_get_message_net_callback,payload,"get_message %" PRIi64,res.replyid); } else { - display_message(room,res.timestamp,res.username,res.message,res.msgid,false,res.type==NET_HISTORY); + display_message(room,res.timestamp,res.username,res.message,res.msgid,false,res.type==NET_HISTORY,false); } } else if(res.type==NET_JOIN){ weechat_printf(room->buffer,"%sUser %s joined this room",netpfx,res.username); @@ -867,8 +872,8 @@ static int cmd_tomsg_cb( char str[128]; snprintf(str,sizeof str,"%s> ...",weechat_color("green")); i64 timestamp=gettimestamp(); - display_message(room,timestamp,room->conn->username,str,-msg_payload->ids[0],true,false); - display_message(room,timestamp,"",message_body,-msg_payload->ids[1],false,false); + display_message(room,timestamp,room->conn->username,str,-msg_payload->ids[0],true,false,true); + display_message(room,timestamp,"",message_body,-msg_payload->ids[1],false,false,true); // TODO: do get_payload in message_net_callback // struct room_and_msgid *get_payload=malloc(sizeof(struct room_and_msgid)); -- cgit v1.2.3-70-g09d2