mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 20:33:46 +02:00
added "message own_public" and "message own_private" events that are
sent when /msg command is used. this way we don't need to parse the /msg's options everywhere. also efnet @#channels support works now better. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1041 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
219c83ae6a
commit
2ae679be08
15 changed files with 210 additions and 141 deletions
|
|
@ -62,7 +62,7 @@ static void cmd_join(const char *data, SERVER_REC *server)
|
|||
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
char *target, *msg;
|
||||
char *target, *origtarget, *msg;
|
||||
void *free_arg;
|
||||
int free_ret;
|
||||
|
||||
|
|
@ -78,16 +78,23 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|||
if (server == NULL || !server->connected)
|
||||
cmd_param_error(CMDERR_NOT_CONNECTED);
|
||||
|
||||
origtarget = target;
|
||||
free_ret = FALSE;
|
||||
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0) {
|
||||
target = parse_special(&target, server, item,
|
||||
NULL, &free_ret, NULL, 0);
|
||||
if (target != NULL && *target == '\0')
|
||||
target = NULL;
|
||||
} else if (strcmp(target, "*") == 0 && item != NULL)
|
||||
target = item->name;
|
||||
|
||||
if (target != NULL)
|
||||
server->send_message(server, target, msg);
|
||||
|
||||
signal_emit(target != NULL && server->ischannel(target) ?
|
||||
"message own_public" : "message own_private", 4,
|
||||
server, msg, target, origtarget);
|
||||
|
||||
if (free_ret && target != NULL) g_free(target);
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,13 +391,6 @@ static char *expando_chatnet(SERVER_REC *server, void *item, int *free_ret)
|
|||
return server == NULL ? "" : server->connrec->chatnet;
|
||||
}
|
||||
|
||||
static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
g_free_not_null(last_privmsg_from);
|
||||
last_privmsg_from = g_strdup(nick);
|
||||
}
|
||||
|
||||
static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address,
|
||||
const char *target)
|
||||
|
|
@ -406,28 +399,27 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
|
|||
last_public_from = g_strdup(nick);
|
||||
}
|
||||
|
||||
static void cmd_msg(const char *data, SERVER_REC *server)
|
||||
static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||
const char *nick, const char *address)
|
||||
{
|
||||
GHashTable *optlist;
|
||||
char *target, *msg;
|
||||
void *free_arg;
|
||||
g_free_not_null(last_privmsg_from);
|
||||
last_privmsg_from = g_strdup(nick);
|
||||
}
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
static void sig_message_own_private(SERVER_REC *server, const char *msg,
|
||||
const char *target, const char *origtarget)
|
||||
{
|
||||
g_return_if_fail(server != NULL);
|
||||
g_return_if_fail(msg != NULL);
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
|
||||
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
||||
"msg", &optlist, &target, &msg))
|
||||
return;
|
||||
|
||||
if (*target != '\0' && *msg != '\0' &&
|
||||
!server->ischannel(*target) && isalpha(*target)) {
|
||||
g_free_not_null(last_sent_msg);
|
||||
if (target != NULL) {
|
||||
if (target != last_sent_msg) {
|
||||
g_free_not_null(last_sent_msg);
|
||||
last_sent_msg = g_strdup(target);
|
||||
}
|
||||
g_free_not_null(last_sent_msg_body);
|
||||
last_sent_msg = g_strdup(target);
|
||||
last_sent_msg_body = g_strdup(msg);
|
||||
}
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
static int sig_timer(void)
|
||||
|
|
@ -532,9 +524,9 @@ void expandos_init(void)
|
|||
"window server changed", EXPANDO_ARG_WINDOW, NULL);
|
||||
|
||||
timer_tag = g_timeout_add(1000, (GSourceFunc) sig_timer, NULL);
|
||||
signal_add("command msg", (SIGNAL_FUNC) cmd_msg);
|
||||
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||
}
|
||||
|
||||
void expandos_deinit(void)
|
||||
|
|
@ -559,5 +551,5 @@ void expandos_deinit(void)
|
|||
g_source_remove(timer_tag);
|
||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_remove("command msg", (SIGNAL_FUNC) cmd_msg);
|
||||
signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host,
|
|||
g_return_val_if_fail(server != NULL, 0);
|
||||
|
||||
chanrec = (channel != NULL && server != NULL &&
|
||||
server->ischannel(*channel)) ?
|
||||
server->ischannel(channel)) ?
|
||||
channel_find(server, channel) : NULL;
|
||||
|
||||
best_mask = 0; best_patt = 0; best_ignore = FALSE;
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ GSList *queries;
|
|||
void (*channels_join)(SERVER_REC *server, const char *data, int automatic);
|
||||
/* returns true if `flag' indicates a nick flag (op/voice/halfop) */
|
||||
int (*isnickflag)(char flag);
|
||||
/* returns true if `flag' indicates a channel */
|
||||
int (*ischannel)(char flag);
|
||||
/* returns true if `data' indicates a channel */
|
||||
int (*ischannel)(const char *data);
|
||||
/* returns all nick flag characters in order op, voice, halfop. If some
|
||||
of them aren't supported '\0' can be used. */
|
||||
const char *(*get_nick_flags)(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue