From ff2a8d69791df413ad973da4ebf174e495103277 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Mon, 21 Jul 2025 18:10:38 -0400 Subject: [PATCH] soju compatibility in DMs --- src/common/dcc.c | 2 +- src/common/inbound.c | 38 +++++++++++++++++++++++++++++--------- src/common/inbound.h | 2 +- src/common/proto-irc.c | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/common/dcc.c b/src/common/dcc.c index df129e68de7058586a8326339809b90bcfb2a991..43ee3a27b2b5a867a2aaf2727aa47f18c65e9df7 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -564,7 +564,7 @@ dcc_chat_line (struct DCC *dcc, char *line) FALSE, &no_tags); } else { - inbound_privmsg (dcc->serv, dcc->nick, "", line, FALSE, &no_tags); + inbound_privmsg (dcc->serv, dcc->nick, NULL, "", line, FALSE, &no_tags); } g_free (line); return 0; diff --git a/src/common/inbound.c b/src/common/inbound.c index fdee2eccf626517ecca3e0cfc631b1b6be65933e..2be8154a3d76e0bfe8a33af02c4f3ba5df409c73 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -164,15 +164,21 @@ inbound_make_idtext (server *serv, char *idtext, int max, int id) } void -inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, +inbound_privmsg (server *serv, char *from, char *to, char *ip, char *text, int id, const message_tags_data *tags_data) { session *sess; struct User *user; char idtext[64]; gboolean nodiag = FALSE; + char *chan; - sess = find_dialog (serv, from); + if (g_ascii_strcasecmp(from, serv->nick) == 0) + chan = to; + else + chan = from; + + sess = find_dialog (serv, chan); if (sess || prefs.hex_gui_autoopen_dialog) { @@ -181,7 +187,7 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, { if (flood_check (from, ip, serv, current_sess, 1)) /* Create a dialog session */ - sess = inbound_open_dialog (serv, from, tags_data); + sess = inbound_open_dialog (serv, chan, tags_data); else sess = serv->server_session; if (!sess) @@ -190,11 +196,15 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, if (ip && ip[0]) set_topic (sess, ip, ip); - inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, tags_data->identified, tags_data); + + if(chan == to) + inbound_chanmsg (serv, NULL, to, from, text, TRUE, tags_data->identified, tags_data); + else + inbound_chanmsg (serv, NULL, NULL, from, text, FALSE, tags_data->identified, tags_data); return; } - sess = find_session_from_nick (from, serv); + sess = find_session_from_nick (chan, serv); if (!sess) { sess = serv->front_session; @@ -338,7 +348,10 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text, char idtext[64]; int privaction = FALSE; - if (!fromme) + if (g_ascii_strcasecmp(from, serv->nick) == 0) + fromme = TRUE; + + if (TRUE) { if (is_channel (serv, chan)) { @@ -348,14 +361,21 @@ inbound_action (session *sess, char *chan, char *from, char *ip, char *text, /* it's a private action! */ privaction = TRUE; /* find a dialog tab for it */ - sess = find_dialog (serv, from); + if (fromme) + sess = find_dialog (serv, chan); + else + sess = find_dialog (serv, from); /* if non found, open a new one */ if (!sess && prefs.hex_gui_autoopen_dialog) { /* but only if it wouldn't flood */ if (flood_check (from, ip, serv, current_sess, 1)) - sess = inbound_open_dialog (serv, from, tags_data); - else + { + if (fromme) + sess = inbound_open_dialog (serv, chan, tags_data); + else + sess = inbound_open_dialog (serv, from, tags_data); + } else sess = serv->server_session; } if (!sess) diff --git a/src/common/inbound.h b/src/common/inbound.h index 6e7c171f30bd9d4b2bbb4923edf5540efa9dc7dd..a05a87015b10c4b514a4dfd9ac9a12484dacc183 100644 --- a/src/common/inbound.h +++ b/src/common/inbound.h @@ -80,7 +80,7 @@ void inbound_chanmsg (server *serv, session *sess, char *chan, char *from, const message_tags_data *tags_data); void clear_channel (session *sess); void set_topic (session *sess, char *topic, char *stripped_topic); -void inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, +void inbound_privmsg (server *serv, char *from, char *to, char *ip, char *text, int id, const message_tags_data *tags_data); void inbound_action (session *sess, char *chan, char *from, char *ip, char *text, int fromme, int id, diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 5b8e02c48f088ab6dbba6f1a81ceb18d09762b73..ac5c9a244dbab35d9303e1a7a8394d664212689e 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -1322,7 +1322,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], { if (ignore_check (word[1], IG_PRIV)) return; - inbound_privmsg (serv, nick, ip, text, tags_data->identified, tags_data); + inbound_privmsg (serv, nick, to, ip, text, tags_data->identified, tags_data); } } }