Open irssibot opened 12 years ago
irssi-svn-improve-multi-client-proxy-behaviour.diff
Index: src/irc/proxy/listen.c
===================================================================
--- src/irc/proxy/listen.c (revision 5212)
+++ src/irc/proxy/listen.c (working copy)
@@ -257,7 +257,17 @@
params = event_get_params(args, 2 | PARAM_FLAG_GETREST,
&target, &msg);
- proxy_outserver_all_except(client, "PRIVMSG %s", args);
+ if (ischannel(*target))
+ proxy_outserver_all_except(client, NULL, "PRIVMSG %s :%s", target, msg);
+ else {
+ if (strncmp(msg+1, "ACTION ", 7) == 0) {
+ msg[strlen(msg)-1] = '\0';
+ proxy_outserver_all_except(client, target, "PRIVMSG %s :* %s %s",
+ target, client->nick, msg+8);
+ } else
+ proxy_outserver_all_except(client, target, "PRIVMSG %s :<%s> %s",
+ target, client->nick, msg);
+ }
ignore_next = TRUE;
if (*msg != '\001' || msg[strlen(msg)-1] != '\001') {
@@ -544,8 +554,23 @@
if (!IS_IRC_SERVER(server))
return;
- if (!ignore_next)
- proxy_outserver_all(server, "PRIVMSG %s :%s", target, msg);
+ if (!ignore_next) {
+ GSList *i;
+
+ for (i = proxy_clients; i != NULL; i = i->next) {
+ CLIENT_REC *rec = i->data;
+
+ if (rec->connected && rec->server == server) {
+ if(ischannel(*target)) {
+ proxy_outdata(rec, ":%s!%s@proxy PRIVMSG %s :%s\n", rec->nick,
+ settings_get_str("user_name"), target, msg);
+ } else {
+ proxy_outdata(rec, ":%s!%s@proxy PRIVMSG %s :<%s> %s\n", target,
+ settings_get_str("user_name"), target, rec->nick, msg);
+ }
+ }
+ }
+ }
}
static void sig_message_own_action(IRC_SERVER_REC *server, const char *msg,
@@ -554,8 +579,23 @@
if (!IS_IRC_SERVER(server))
return;
- if (!ignore_next)
- proxy_outserver_all(server, "PRIVMSG %s :\001ACTION %s\001", target, msg);
+ if (!ignore_next) {
+ GSList *i;
+
+ for (i = proxy_clients; i != NULL; i = i->next) {
+ CLIENT_REC *rec = i->data;
+
+ if (rec->connected && rec->server == server) {
+ if(ischannel(*target)) {
+ proxy_outdata(rec, ":%s!%s@proxy PRIVMSG %s :\001ACTION %s\001", rec->nick,
+ settings_get_str("user_name"), target, msg);
+ } else {
+ proxy_outdata(rec, ":%s!%s@proxy PRIVMSG %s :* %s %s\n", target,
+ settings_get_str("user_name"), target, rec->nick, msg);
+ }
+ }
+ }
+ }
}
static LISTEN_REC *find_listen(const char *ircnet, int port)
Index: src/irc/proxy/dump.c
===================================================================
--- src/irc/proxy/dump.c (revision 5212)
+++ src/irc/proxy/dump.c (working copy)
@@ -115,7 +115,7 @@
va_end(args);
}
-void proxy_outserver_all_except(CLIENT_REC *client, const char *data, ...)
+void proxy_outserver_all_except(CLIENT_REC *client, const char *source, const char *data, ...)
{
va_list args;
GSList *tmp;
@@ -132,7 +132,10 @@
if (rec->connected && rec != client &&
rec->server == client->server) {
- proxy_outdata(rec, ":%s!%s@proxy %s\n", rec->nick,
+ if (source == NULL) {
+ source = rec->nick;
+ }
+ proxy_outdata(rec, ":%s!%s@proxy %s\n", source,
settings_get_str("user_name"), str);
}
}
Index: src/irc/proxy/module.h
===================================================================
--- src/irc/proxy/module.h (revision 5212)
+++ src/irc/proxy/module.h (working copy)
@@ -23,4 +23,4 @@
void proxy_outdata_all(IRC_SERVER_REC *server, const char *data, ...);
void proxy_outserver(CLIENT_REC *client, const char *data, ...);
void proxy_outserver_all(IRC_SERVER_REC *server, const char *data, ...);
-void proxy_outserver_all_except(CLIENT_REC *client, const char *data, ...);
+void proxy_outserver_all_except(CLIENT_REC *client, const char *source, const char *data, ...);
Irssi proxy is great; I have been using it for many years without problem. There has always been one thing that annoyed me though. Consider the following: I have a copy of Irssi running permanently on a server, another proxy IRC client connected to it that runs on my home machine and a second proxy IRC client running on my machine at work. For the most part, this works just fine. Where things go a bit awry is when I enter into a /query with another user. On the local client (let's say it's my work one) and Irssi itself, the conversation might look as follows: