summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-02-03 21:53:37 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-02-03 21:53:37 +0000
commit7c94cb083f5354cf85453e9465887fc45bf5bcdc (patch)
treeb014e28fe402bf627de7e762160223b3eb663280 /src/core
parent6ea882f8932e115c32f7b3991cb0a7685a359e56 (diff)
downloadirssi-7c94cb083f5354cf85453e9465887fc45bf5bcdc.zip
Added target_type to send_message(), -channel and -nick parameters to /MSG
to specify if it's supposed to be to channel/nick. /MSG -channel is used automatically by irssi when sending messages to channel (the "normal" way without /msg). This should help with protocols that don't have any channel name prefixes. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2383 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r--src/core/chat-commands.c22
-rw-r--r--src/core/ignore.c5
-rw-r--r--src/core/server-rec.h3
-rw-r--r--src/core/servers.h3
4 files changed, 25 insertions, 8 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c
index 7b76511f..07a9ae88 100644
--- a/src/core/chat-commands.c
+++ b/src/core/chat-commands.c
@@ -308,13 +308,13 @@ static void cmd_join(const char *data, SERVER_REC *server)
cmd_params_free(free_arg);
}
-/* SYNTAX: MSG [-<server tag>] <targets> <message> */
+/* SYNTAX: MSG [-<server tag>] [-channel | -nick] <targets> <message> */
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
GHashTable *optlist;
char *target, *origtarget, *msg;
void *free_arg;
- int free_ret;
+ int free_ret, target_type;
g_return_if_fail(data != NULL);
@@ -342,10 +342,23 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
target = item->name;
}
+ if (g_hash_table_lookup(optlist, "channel") != NULL)
+ target_type = SEND_TARGET_CHANNEL;
+ else if (g_hash_table_lookup(optlist, "nick") != NULL)
+ target_type = SEND_TARGET_NICK;
+ else {
+ /* Need to rely on server_ischannel(). If the protocol
+ doesn't really know if it's channel or nick based on the
+ name, it should just assume it's nick, because when typing
+ text to channels it's always sent with /MSG -channel. */
+ target_type = server_ischannel(server, target) ?
+ SEND_TARGET_CHANNEL : SEND_TARGET_NICK;
+ }
+
if (target != NULL)
- server->send_message(server, target, msg);
+ server->send_message(server, target, msg, target_type);
- signal_emit(target != NULL && server_ischannel(server, target) ?
+ signal_emit(target != NULL && target_type == SEND_TARGET_CHANNEL ?
"message own_public" : "message own_private", 4,
server, msg, target, origtarget);
@@ -419,6 +432,7 @@ void chat_commands_init(void)
command_set_options("connect", "4 6 !! +host noproxy -rawlog");
command_set_options("join", "invite");
+ command_set_options("msg", "channel nick");
}
void chat_commands_deinit(void)
diff --git a/src/core/ignore.c b/src/core/ignore.c
index c98646c1..23bdf83c 100644
--- a/src/core/ignore.c
+++ b/src/core/ignore.c
@@ -161,9 +161,8 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
g_return_val_if_fail(server != NULL, 0);
if (nick == NULL) nick = "";
- chanrec = (channel != NULL && server != NULL &&
- server_ischannel(server, channel)) ?
- channel_find(server, channel) : NULL;
+ chanrec = server == NULL || channel == NULL ? NULL :
+ channel_find(server, channel);
if (chanrec != NULL && nick != NULL &&
(nickrec = nicklist_find(chanrec, nick)) != NULL) {
/* nick found - check only ignores in nickmatch cache */
diff --git a/src/core/server-rec.h b/src/core/server-rec.h
index 9f5070f7..0003f698 100644
--- a/src/core/server-rec.h
+++ b/src/core/server-rec.h
@@ -60,7 +60,8 @@ int (*ischannel)(SERVER_REC *server, const char *data);
of them aren't supported '\0' can be used. */
const char *(*get_nick_flags)(void);
/* send public or private message to server */
-void (*send_message)(SERVER_REC *server, const char *target, const char *msg);
+void (*send_message)(SERVER_REC *server, const char *target,
+ const char *msg, int target_type);
/* -- Default implementations are used if NULL -- */
CHANNEL_REC *(*channel_find_func)(SERVER_REC *server, const char *name);
diff --git a/src/core/servers.h b/src/core/servers.h
index 05ebc55e..dddde263 100644
--- a/src/core/servers.h
+++ b/src/core/servers.h
@@ -31,6 +31,9 @@ struct _SERVER_REC {
#include "server-rec.h"
};
+#define SEND_TARGET_CHANNEL 0
+#define SEND_TARGET_NICK 1
+
extern GSList *servers, *lookup_servers;
void servers_init(void);