mirror of
https://github.com/irssi/irssi.git
synced 2026-08-09 20:00:23 +02:00
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
This commit is contained in:
parent
6ea882f893
commit
7c94cb083f
7 changed files with 74 additions and 41 deletions
|
|
@ -762,48 +762,62 @@ static char *expand_escapes(const char *line, SERVER_REC *server,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static char *auto_complete(CHANNEL_REC *channel, const char *line)
|
||||
{
|
||||
GList *comp;
|
||||
const char *p;
|
||||
char *nick, *ret;
|
||||
|
||||
p = strstr(line, completion_char);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
nick = g_strndup(line, (int) (p-line));
|
||||
|
||||
ret = NULL;
|
||||
if (nicklist_find(channel, nick) == NULL) {
|
||||
/* not an exact match, use the first possible completion */
|
||||
comp = completion_channel_nicks(channel, nick, NULL);
|
||||
if (comp != NULL) {
|
||||
ret = g_strconcat(comp->data, p, NULL);
|
||||
g_list_foreach(comp, (GFunc) g_free, NULL);
|
||||
g_list_free(comp);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(nick);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
CHANNEL_REC *channel;
|
||||
GList *comp;
|
||||
char *line, *str, *ptr, comp_char;
|
||||
char *line, *str;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
if (item == NULL) return;
|
||||
|
||||
line = settings_get_bool("expand_escapes") ?
|
||||
expand_escapes(data, server, item) : g_strdup(data);
|
||||
comp_char = *completion_char;
|
||||
|
||||
/* check for automatic nick completion */
|
||||
ptr = NULL;
|
||||
comp = NULL;
|
||||
channel = CHANNEL(item);
|
||||
|
||||
if (completion_auto && channel != NULL && comp_char != '\0') {
|
||||
ptr = strchr(line, comp_char);
|
||||
if (ptr != NULL) {
|
||||
*ptr++ = '\0';
|
||||
if (nicklist_find(channel, line) == NULL) {
|
||||
comp = completion_channel_nicks(channel,
|
||||
line, NULL);
|
||||
}
|
||||
if (completion_auto && IS_CHANNEL(item)) {
|
||||
str = auto_complete(CHANNEL(item), line);
|
||||
if (str != NULL) {
|
||||
g_free(line);
|
||||
line = str;
|
||||
}
|
||||
}
|
||||
|
||||
str = g_strdup_printf(ptr == NULL ? "%s %s" : "%s %s%c%s", item->name,
|
||||
comp != NULL ? (char *) comp->data : line,
|
||||
comp_char, ptr);
|
||||
str = g_strdup_printf(IS_CHANNEL(item) ? "-channel %s %s" :
|
||||
IS_QUERY(item) ? "-nick %s %s" : "%s %s",
|
||||
item->name, line);
|
||||
|
||||
signal_emit("command msg", 3, str, server, item);
|
||||
|
||||
g_free(str);
|
||||
g_free(line);
|
||||
|
||||
if (comp != NULL) {
|
||||
g_list_foreach(comp, (GFunc) g_free, NULL);
|
||||
g_list_free(comp);
|
||||
}
|
||||
|
||||
signal_stop();
|
||||
}
|
||||
|
||||
|
|
@ -840,6 +854,11 @@ static void read_settings(void)
|
|||
cmdchars = settings_get_str("cmdchars");
|
||||
completion_auto = settings_get_bool("completion_auto");
|
||||
completion_strict = settings_get_bool("completion_strict");
|
||||
|
||||
if (*completion_char == '\0') {
|
||||
/* this would break.. */
|
||||
completion_auto = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void chat_completion_init(void)
|
||||
|
|
|
|||
|
|
@ -226,7 +226,8 @@ static void cmd_query(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|||
|
||||
query = query_find(server, nick);
|
||||
if (query == NULL)
|
||||
CHAT_PROTOCOL(server)->query_create(server->tag, nick, FALSE);
|
||||
query = CHAT_PROTOCOL(server)->
|
||||
query_create(server->tag, nick, FALSE);
|
||||
else {
|
||||
/* query already exists */
|
||||
WINDOW_REC *window = window_item_window(query);
|
||||
|
|
@ -252,13 +253,9 @@ static void cmd_query(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|||
}
|
||||
|
||||
if (*msg != '\0') {
|
||||
/* FIXME: we'll need some function that does both
|
||||
of these. and separate the , and . target handling
|
||||
from own_private messagge.. */
|
||||
server->send_message(server, nick, msg);
|
||||
|
||||
signal_emit("message own_private", 4,
|
||||
server, msg, nick, nick);
|
||||
msg = g_strdup_printf("-nick %s %s", nick, msg);
|
||||
signal_emit("command msg", 3, msg, server, query);
|
||||
g_free(msg);
|
||||
}
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue