mirror of
https://github.com/irssi/irssi.git
synced 2026-08-20 17:12:51 +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)
|
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
char *target, *msg;
|
char *target, *origtarget, *msg;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int free_ret;
|
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)
|
if (server == NULL || !server->connected)
|
||||||
cmd_param_error(CMDERR_NOT_CONNECTED);
|
cmd_param_error(CMDERR_NOT_CONNECTED);
|
||||||
|
|
||||||
|
origtarget = target;
|
||||||
free_ret = FALSE;
|
free_ret = FALSE;
|
||||||
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0) {
|
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0) {
|
||||||
target = parse_special(&target, server, item,
|
target = parse_special(&target, server, item,
|
||||||
NULL, &free_ret, NULL, 0);
|
NULL, &free_ret, NULL, 0);
|
||||||
|
if (target != NULL && *target == '\0')
|
||||||
|
target = NULL;
|
||||||
} else if (strcmp(target, "*") == 0 && item != NULL)
|
} else if (strcmp(target, "*") == 0 && item != NULL)
|
||||||
target = item->name;
|
target = item->name;
|
||||||
|
|
||||||
if (target != NULL)
|
if (target != NULL)
|
||||||
server->send_message(server, target, msg);
|
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);
|
if (free_ret && target != NULL) g_free(target);
|
||||||
cmd_params_free(free_arg);
|
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;
|
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,
|
static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||||
const char *nick, const char *address,
|
const char *nick, const char *address,
|
||||||
const char *target)
|
const char *target)
|
||||||
|
|
@ -406,28 +399,27 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||||
last_public_from = g_strdup(nick);
|
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;
|
g_free_not_null(last_privmsg_from);
|
||||||
char *target, *msg;
|
last_privmsg_from = g_strdup(nick);
|
||||||
void *free_arg;
|
}
|
||||||
|
|
||||||
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 |
|
if (target != NULL) {
|
||||||
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
if (target != last_sent_msg) {
|
||||||
"msg", &optlist, &target, &msg))
|
g_free_not_null(last_sent_msg);
|
||||||
return;
|
last_sent_msg = g_strdup(target);
|
||||||
|
}
|
||||||
if (*target != '\0' && *msg != '\0' &&
|
|
||||||
!server->ischannel(*target) && isalpha(*target)) {
|
|
||||||
g_free_not_null(last_sent_msg);
|
|
||||||
g_free_not_null(last_sent_msg_body);
|
g_free_not_null(last_sent_msg_body);
|
||||||
last_sent_msg = g_strdup(target);
|
|
||||||
last_sent_msg_body = g_strdup(msg);
|
last_sent_msg_body = g_strdup(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_params_free(free_arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sig_timer(void)
|
static int sig_timer(void)
|
||||||
|
|
@ -532,9 +524,9 @@ void expandos_init(void)
|
||||||
"window server changed", EXPANDO_ARG_WINDOW, NULL);
|
"window server changed", EXPANDO_ARG_WINDOW, NULL);
|
||||||
|
|
||||||
timer_tag = g_timeout_add(1000, (GSourceFunc) sig_timer, 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 public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||||
|
signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||||
}
|
}
|
||||||
|
|
||||||
void expandos_deinit(void)
|
void expandos_deinit(void)
|
||||||
|
|
@ -559,5 +551,5 @@ void expandos_deinit(void)
|
||||||
g_source_remove(timer_tag);
|
g_source_remove(timer_tag);
|
||||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
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);
|
g_return_val_if_fail(server != NULL, 0);
|
||||||
|
|
||||||
chanrec = (channel != NULL && server != NULL &&
|
chanrec = (channel != NULL && server != NULL &&
|
||||||
server->ischannel(*channel)) ?
|
server->ischannel(channel)) ?
|
||||||
channel_find(server, channel) : NULL;
|
channel_find(server, channel) : NULL;
|
||||||
|
|
||||||
best_mask = 0; best_patt = 0; best_ignore = FALSE;
|
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);
|
void (*channels_join)(SERVER_REC *server, const char *data, int automatic);
|
||||||
/* returns true if `flag' indicates a nick flag (op/voice/halfop) */
|
/* returns true if `flag' indicates a nick flag (op/voice/halfop) */
|
||||||
int (*isnickflag)(char flag);
|
int (*isnickflag)(char flag);
|
||||||
/* returns true if `flag' indicates a channel */
|
/* returns true if `data' indicates a channel */
|
||||||
int (*ischannel)(char flag);
|
int (*ischannel)(const char *data);
|
||||||
/* returns all nick flag characters in order op, voice, halfop. If some
|
/* returns all nick flag characters in order op, voice, halfop. If some
|
||||||
of them aren't supported '\0' can be used. */
|
of them aren't supported '\0' can be used. */
|
||||||
const char *(*get_nick_flags)(void);
|
const char *(*get_nick_flags)(void);
|
||||||
|
|
|
||||||
|
|
@ -127,53 +127,46 @@ static void sig_message_private(SERVER_REC *server, const char *msg,
|
||||||
SERVER_LAST_MSG_ADD(server, nick);
|
SERVER_LAST_MSG_ADD(server, nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_msg(const char *data, SERVER_REC *server)
|
static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
||||||
|
const char *target, const char *origtarget)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
CHANNEL_REC *channel;
|
||||||
NICK_REC *nick;
|
NICK_REC *nick;
|
||||||
char *target, *msg, *p;
|
char *p, *msgnick;
|
||||||
void *free_arg;
|
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(server != NULL);
|
||||||
|
g_return_if_fail(msg != NULL);
|
||||||
|
if (target == NULL) return;
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
|
channel = channel_find(server, target);
|
||||||
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
if (channel == NULL)
|
||||||
"msg", &optlist, &target, &msg))
|
|
||||||
return;
|
return;
|
||||||
server = cmd_options_get_server("msg", optlist, server);
|
|
||||||
|
|
||||||
if (server != NULL && *target != '\0' && *msg != '\0' &&
|
/* channel msg - if first word in line is nick,
|
||||||
query_find(server, target) == NULL) {
|
add it to lastmsgs */
|
||||||
CHANNEL_REC *channel = channel_find(server, target);
|
p = strchr(msg, ' ');
|
||||||
MODULE_CHANNEL_REC *mchannel;
|
if (p != NULL && p != msg) {
|
||||||
|
msgnick = g_strndup(msg, (int) (p-msg));
|
||||||
mchannel = MODULE_DATA(channel);
|
nick = nicklist_find(channel, msgnick);
|
||||||
|
if (nick == NULL) {
|
||||||
if (channel != NULL) {
|
/* probably ':' or ',' or some other
|
||||||
/* channel msg - if first word in line is nick,
|
char after nick, try without it */
|
||||||
add it to lastmsgs */
|
msgnick[strlen(msgnick)-1] = '\0';
|
||||||
p = strchr(msg, ' ');
|
nick = nicklist_find(channel, msgnick);
|
||||||
if (p != NULL && p != msg) {
|
|
||||||
*p = '\0';
|
|
||||||
nick = nicklist_find(channel, msg);
|
|
||||||
if (nick == NULL) {
|
|
||||||
/* probably ':' or ',' or some other
|
|
||||||
char after nick, try without it */
|
|
||||||
p[-1] = '\0';
|
|
||||||
nick = nicklist_find(channel, msg);
|
|
||||||
}
|
|
||||||
if (nick != NULL && nick != channel->ownnick) {
|
|
||||||
CHANNEL_LAST_MSG_ADD(channel,
|
|
||||||
nick->nick, TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (!server->ischannel(*target)) {
|
|
||||||
/* private msg */
|
|
||||||
SERVER_LAST_MSG_ADD(server, target);
|
|
||||||
}
|
}
|
||||||
|
if (nick != NULL && nick != channel->ownnick)
|
||||||
|
CHANNEL_LAST_MSG_ADD(channel, nick->nick, TRUE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cmd_params_free(free_arg);
|
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 (target != NULL && query_find(server, target) == NULL)
|
||||||
|
SERVER_LAST_MSG_ADD(server, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_nick_removed(CHANNEL_REC *channel, NICK_REC *nick)
|
static void sig_nick_removed(CHANNEL_REC *channel, NICK_REC *nick)
|
||||||
|
|
@ -462,7 +455,7 @@ static void sig_complete_word(GList **list, WINDOW_REC *window,
|
||||||
if (server == NULL && servers != NULL)
|
if (server == NULL && servers != NULL)
|
||||||
server = servers->data;
|
server = servers->data;
|
||||||
|
|
||||||
if (server != NULL && server->ischannel(*word)) {
|
if (server != NULL && server->ischannel(word)) {
|
||||||
/* probably completing a channel name */
|
/* probably completing a channel name */
|
||||||
*list = completion_get_channels(window->active_server, word);
|
*list = completion_get_channels(window->active_server, word);
|
||||||
return;
|
return;
|
||||||
|
|
@ -731,7 +724,8 @@ void chat_completion_init(void)
|
||||||
signal_add("complete command server", (SIGNAL_FUNC) sig_complete_connect);
|
signal_add("complete command server", (SIGNAL_FUNC) sig_complete_connect);
|
||||||
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||||
signal_add("command msg", (SIGNAL_FUNC) cmd_msg);
|
signal_add("message own_public", (SIGNAL_FUNC) sig_message_own_public);
|
||||||
|
signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||||
signal_add("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
signal_add("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
||||||
signal_add("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
signal_add("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
||||||
signal_add("send text", (SIGNAL_FUNC) event_text);
|
signal_add("send text", (SIGNAL_FUNC) event_text);
|
||||||
|
|
@ -748,7 +742,8 @@ void chat_completion_deinit(void)
|
||||||
signal_remove("complete command server", (SIGNAL_FUNC) sig_complete_connect);
|
signal_remove("complete command server", (SIGNAL_FUNC) sig_complete_connect);
|
||||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||||
signal_remove("command msg", (SIGNAL_FUNC) cmd_msg);
|
signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public);
|
||||||
|
signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||||
signal_remove("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
signal_remove("nicklist remove", (SIGNAL_FUNC) sig_nick_removed);
|
||||||
signal_remove("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
signal_remove("nicklist changed", (SIGNAL_FUNC) sig_nick_changed);
|
||||||
signal_remove("send text", (SIGNAL_FUNC) event_text);
|
signal_remove("send text", (SIGNAL_FUNC) event_text);
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ static void cmd_ignore(const char *data)
|
||||||
if (*levels == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*levels == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
if (active_win->active_server != NULL &&
|
if (active_win->active_server != NULL &&
|
||||||
active_win->active_server->ischannel(*mask)) {
|
active_win->active_server->ischannel(mask)) {
|
||||||
chanarg = mask;
|
chanarg = mask;
|
||||||
mask = NULL;
|
mask = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +264,7 @@ static void cmd_unignore(const char *data)
|
||||||
const char *chans[2] = { "*", NULL };
|
const char *chans[2] = { "*", NULL };
|
||||||
|
|
||||||
if (active_win->active_server != NULL &&
|
if (active_win->active_server != NULL &&
|
||||||
active_win->active_server->ischannel(*data)) {
|
active_win->active_server->ischannel(data)) {
|
||||||
chans[0] = data;
|
chans[0] = data;
|
||||||
data = NULL;
|
data = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -504,7 +504,7 @@ static int sig_autoremove(void)
|
||||||
|
|
||||||
server = server_find_tag(logitem->servertag);
|
server = server_find_tag(logitem->servertag);
|
||||||
if (logitem->type == LOG_ITEM_TARGET &&
|
if (logitem->type == LOG_ITEM_TARGET &&
|
||||||
server != NULL && !server->ischannel(*logitem->name))
|
server != NULL && !server->ischannel(logitem->name))
|
||||||
log_close(log);
|
log_close(log);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ char *expand_emphasis(WI_ITEM_REC *item, const char *text)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_nickmode(CHANNEL_REC *channel, const char *nick)
|
char *channel_get_nickmode(CHANNEL_REC *channel, const char *nick)
|
||||||
{
|
{
|
||||||
NICK_REC *nickrec;
|
NICK_REC *nickrec;
|
||||||
char *emptystr;
|
char *emptystr;
|
||||||
|
|
@ -158,7 +158,7 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
|
||||||
else
|
else
|
||||||
freemsg = NULL;
|
freemsg = NULL;
|
||||||
|
|
||||||
nickmode = get_nickmode(chanrec, nick);
|
nickmode = channel_get_nickmode(chanrec, nick);
|
||||||
if (!print_channel) {
|
if (!print_channel) {
|
||||||
/* message to active channel in window */
|
/* message to active channel in window */
|
||||||
if (color != NULL) {
|
if (color != NULL) {
|
||||||
|
|
@ -217,7 +217,7 @@ static void print_own_channel_message(SERVER_REC *server, CHANNEL_REC *channel,
|
||||||
const char *nickmode;
|
const char *nickmode;
|
||||||
int print_channel;
|
int print_channel;
|
||||||
|
|
||||||
nickmode = get_nickmode(channel, server->nick);
|
nickmode = channel_get_nickmode(channel, server->nick);
|
||||||
|
|
||||||
window = channel == NULL ? NULL :
|
window = channel == NULL ? NULL :
|
||||||
window_item_window((WI_ITEM_REC *) channel);
|
window_item_window((WI_ITEM_REC *) channel);
|
||||||
|
|
@ -238,71 +238,45 @@ static void print_own_channel_message(SERVER_REC *server, CHANNEL_REC *channel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
||||||
|
const char *target)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
|
||||||
CHANNEL_REC *channel;
|
CHANNEL_REC *channel;
|
||||||
char *target, *msg, *freestr, *newtarget;
|
|
||||||
void *free_arg;
|
|
||||||
int free_ret;
|
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
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')
|
|
||||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
||||||
server = cmd_options_get_server("msg", optlist, server);
|
|
||||||
|
|
||||||
free_ret = FALSE;
|
|
||||||
if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0) {
|
|
||||||
/* , and . are handled specially */
|
|
||||||
newtarget = parse_special(&target, server, item,
|
|
||||||
NULL, &free_ret, NULL, 0);
|
|
||||||
if (newtarget == NULL) {
|
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
|
||||||
*target == ',' ? IRCTXT_NO_MSGS_GOT :
|
|
||||||
IRCTXT_NO_MSGS_SENT);
|
|
||||||
cmd_params_free(free_arg);
|
|
||||||
signal_stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
target = newtarget;
|
|
||||||
} else if (strcmp(target, "*") == 0 && item != NULL) {
|
|
||||||
/* * means active channel */
|
|
||||||
target = item->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server == NULL || !server->connected)
|
|
||||||
cmd_param_error(CMDERR_NOT_CONNECTED);
|
|
||||||
channel = channel_find(server, target);
|
channel = channel_find(server, target);
|
||||||
|
print_own_channel_message(server, channel, target, msg);
|
||||||
|
}
|
||||||
|
|
||||||
freestr = !free_ret ? NULL : target;
|
static void sig_message_own_private(SERVER_REC *server, const char *msg,
|
||||||
if (*target == '@' && server->ischannel(target[1])) {
|
const char *target, const char *origtarget)
|
||||||
/* Hybrid 6 feature, send msg to all ops in channel
|
{
|
||||||
FIXME: this shouldn't really be here in core.. */
|
QUERY_REC *query;
|
||||||
target++;
|
|
||||||
|
g_return_if_fail(server != NULL);
|
||||||
|
g_return_if_fail(msg != NULL);
|
||||||
|
|
||||||
|
if (target == NULL) {
|
||||||
|
/* this should only happen if some special target failed and
|
||||||
|
we should display some error message. currently the special
|
||||||
|
targets are only ',' and '.'. */
|
||||||
|
g_return_if_fail(strcmp(origtarget, ",") == 0 ||
|
||||||
|
strcmp(origtarget, ".") == 0);
|
||||||
|
|
||||||
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
|
*origtarget == ',' ? IRCTXT_NO_MSGS_GOT :
|
||||||
|
IRCTXT_NO_MSGS_SENT);
|
||||||
|
signal_stop();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server->ischannel(*target)) {
|
query = privmsg_get_query(server, target, TRUE, MSGLEVEL_MSGS);
|
||||||
/* msg to channel */
|
printformat(server, target,
|
||||||
print_own_channel_message(server, channel, target, msg);
|
MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
||||||
} else {
|
query == NULL ? IRCTXT_OWN_MSG_PRIVATE :
|
||||||
/* private message */
|
IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
|
||||||
QUERY_REC *query;
|
|
||||||
|
|
||||||
query = privmsg_get_query(server, target, TRUE, MSGLEVEL_MSGS);
|
|
||||||
printformat(server, target, MSGLEVEL_MSGS |
|
|
||||||
MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
|
|
||||||
query == NULL ? IRCTXT_OWN_MSG_PRIVATE :
|
|
||||||
IRCTXT_OWN_MSG_PRIVATE_QUERY,
|
|
||||||
target, msg, server->nick);
|
|
||||||
}
|
|
||||||
g_free_not_null(freestr);
|
|
||||||
|
|
||||||
cmd_params_free(free_arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_message_join(SERVER_REC *server, const char *channel,
|
static void sig_message_join(SERVER_REC *server, const char *channel,
|
||||||
|
|
@ -502,6 +476,8 @@ void fe_messages_init(void)
|
||||||
|
|
||||||
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||||
|
signal_add("message own_public", (SIGNAL_FUNC) sig_message_own_public);
|
||||||
|
signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||||
signal_add("message join", (SIGNAL_FUNC) sig_message_join);
|
signal_add("message join", (SIGNAL_FUNC) sig_message_join);
|
||||||
signal_add("message part", (SIGNAL_FUNC) sig_message_part);
|
signal_add("message part", (SIGNAL_FUNC) sig_message_part);
|
||||||
signal_add("message quit", (SIGNAL_FUNC) sig_message_quit);
|
signal_add("message quit", (SIGNAL_FUNC) sig_message_quit);
|
||||||
|
|
@ -510,13 +486,14 @@ void fe_messages_init(void)
|
||||||
signal_add("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
|
signal_add("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
|
||||||
signal_add("message invite", (SIGNAL_FUNC) sig_message_invite);
|
signal_add("message invite", (SIGNAL_FUNC) sig_message_invite);
|
||||||
signal_add("message topic", (SIGNAL_FUNC) sig_message_topic);
|
signal_add("message topic", (SIGNAL_FUNC) sig_message_topic);
|
||||||
command_bind_last("msg", NULL, (SIGNAL_FUNC) cmd_msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fe_messages_deinit(void)
|
void fe_messages_deinit(void)
|
||||||
{
|
{
|
||||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||||
|
signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public);
|
||||||
|
signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||||
signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
|
signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
|
||||||
signal_remove("message part", (SIGNAL_FUNC) sig_message_part);
|
signal_remove("message part", (SIGNAL_FUNC) sig_message_part);
|
||||||
signal_remove("message quit", (SIGNAL_FUNC) sig_message_quit);
|
signal_remove("message quit", (SIGNAL_FUNC) sig_message_quit);
|
||||||
|
|
@ -525,5 +502,4 @@ void fe_messages_deinit(void)
|
||||||
signal_remove("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
|
signal_remove("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
|
||||||
signal_remove("message invite", (SIGNAL_FUNC) sig_message_invite);
|
signal_remove("message invite", (SIGNAL_FUNC) sig_message_invite);
|
||||||
signal_remove("message topic", (SIGNAL_FUNC) sig_message_topic);
|
signal_remove("message topic", (SIGNAL_FUNC) sig_message_topic);
|
||||||
command_unbind("msg", (SIGNAL_FUNC) cmd_msg);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,6 @@
|
||||||
underlining or bolding */
|
underlining or bolding */
|
||||||
char *expand_emphasis(WI_ITEM_REC *item, const char *text);
|
char *expand_emphasis(WI_ITEM_REC *item, const char *text);
|
||||||
|
|
||||||
|
char *channel_get_nickmode(CHANNEL_REC *channel, const char *nick);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ INCLUDES = \
|
||||||
libfe_common_irc_a_SOURCES = \
|
libfe_common_irc_a_SOURCES = \
|
||||||
fe-irc-channels.c \
|
fe-irc-channels.c \
|
||||||
fe-irc-commands.c \
|
fe-irc-commands.c \
|
||||||
|
fe-irc-messages.c \
|
||||||
fe-irc-queries.c \
|
fe-irc-queries.c \
|
||||||
fe-irc-server.c \
|
fe-irc-server.c \
|
||||||
fe-ircnet.c \
|
fe-ircnet.c \
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ void fe_irc_channels_deinit(void);
|
||||||
void fe_irc_queries_init(void);
|
void fe_irc_queries_init(void);
|
||||||
void fe_irc_queries_deinit(void);
|
void fe_irc_queries_deinit(void);
|
||||||
|
|
||||||
|
void fe_irc_messages_init(void);
|
||||||
|
void fe_irc_messages_deinit(void);
|
||||||
|
|
||||||
void fe_irc_commands_init(void);
|
void fe_irc_commands_init(void);
|
||||||
void fe_irc_commands_deinit(void);
|
void fe_irc_commands_deinit(void);
|
||||||
|
|
||||||
|
|
@ -99,6 +102,7 @@ void fe_common_irc_init(void)
|
||||||
|
|
||||||
fe_irc_channels_init();
|
fe_irc_channels_init();
|
||||||
fe_irc_queries_init();
|
fe_irc_queries_init();
|
||||||
|
fe_irc_messages_init();
|
||||||
fe_irc_commands_init();
|
fe_irc_commands_init();
|
||||||
fe_ircnet_init();
|
fe_ircnet_init();
|
||||||
fe_irc_server_init();
|
fe_irc_server_init();
|
||||||
|
|
@ -119,6 +123,7 @@ void fe_common_irc_deinit(void)
|
||||||
|
|
||||||
fe_irc_channels_deinit();
|
fe_irc_channels_deinit();
|
||||||
fe_irc_queries_deinit();
|
fe_irc_queries_deinit();
|
||||||
|
fe_irc_messages_deinit();
|
||||||
fe_irc_commands_deinit();
|
fe_irc_commands_deinit();
|
||||||
fe_ircnet_deinit();
|
fe_ircnet_deinit();
|
||||||
fe_irc_server_deinit();
|
fe_irc_server_deinit();
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,15 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
|
||||||
if (nick == NULL) nick = server->real_address;
|
if (nick == NULL) nick = server->real_address;
|
||||||
if (addr == NULL) addr = "";
|
if (addr == NULL) addr = "";
|
||||||
|
|
||||||
signal_emit(ischannel(*target) ?
|
if (*target == '@' && ischannel(target[1])) {
|
||||||
"message public" : "message private", 5,
|
/* Hybrid 6 feature, send msg to all ops in channel */
|
||||||
server, msg, nick, addr, target);
|
signal_emit("message irc op_public", 5,
|
||||||
|
server, msg, nick, addr, target+1);
|
||||||
|
} else {
|
||||||
|
signal_emit(ischannel(*target) ?
|
||||||
|
"message public" : "message private", 5,
|
||||||
|
server, msg, nick, addr, target);
|
||||||
|
}
|
||||||
|
|
||||||
g_free(params);
|
g_free(params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
81
src/fe-common/irc/fe-irc-messages.c
Normal file
81
src/fe-common/irc/fe-irc-messages.c
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
fe-irc-messages.c : irssi
|
||||||
|
|
||||||
|
Copyright (C) 2001 Timo Sirainen
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
#include "signals.h"
|
||||||
|
#include "levels.h"
|
||||||
|
#include "channels.h"
|
||||||
|
|
||||||
|
#include "irc.h"
|
||||||
|
|
||||||
|
/* FIXME: hmm. there's should be some better way to use other module's
|
||||||
|
formats than this since now we can't use this module's formats.. */
|
||||||
|
#include "../core/module-formats.h"
|
||||||
|
#include "printtext.h"
|
||||||
|
#include "fe-messages.h"
|
||||||
|
|
||||||
|
static void sig_message_own_public(SERVER_REC *server, const char *msg,
|
||||||
|
const char *target, const char *origtarget)
|
||||||
|
{
|
||||||
|
char *nickmode;
|
||||||
|
|
||||||
|
if (IS_IRC_SERVER(server) && target != NULL &&
|
||||||
|
*target == '@' && ischannel(target[1])) {
|
||||||
|
/* Hybrid 6 feature, send msg to all ops in channel */
|
||||||
|
nickmode = channel_get_nickmode(channel_find(server, target+1),
|
||||||
|
server->nick);
|
||||||
|
|
||||||
|
printformat_module("fe-common/core", server, target+1,
|
||||||
|
MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT |
|
||||||
|
MSGLEVEL_NO_ACT,
|
||||||
|
IRCTXT_OWN_MSG_CHANNEL,
|
||||||
|
server->nick, target, msg, nickmode);
|
||||||
|
signal_stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sig_message_irc_op_public(SERVER_REC *server, const char *msg,
|
||||||
|
const char *nick, const char *address,
|
||||||
|
const char *target)
|
||||||
|
{
|
||||||
|
char *nickmode, *optarget;
|
||||||
|
|
||||||
|
nickmode = channel_get_nickmode(channel_find(server, target),
|
||||||
|
server->nick);
|
||||||
|
|
||||||
|
optarget = g_strconcat("@", target, NULL);
|
||||||
|
printformat_module("fe-common/core", server, target,
|
||||||
|
MSGLEVEL_PUBLIC | MSGLEVEL_HILIGHT,
|
||||||
|
IRCTXT_PUBMSG_ME_CHANNEL,
|
||||||
|
nick, optarget, msg, nickmode);
|
||||||
|
g_free(optarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fe_irc_messages_init(void)
|
||||||
|
{
|
||||||
|
signal_add("message own_public", (SIGNAL_FUNC) sig_message_own_public);
|
||||||
|
signal_add("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fe_irc_messages_deinit(void)
|
||||||
|
{
|
||||||
|
signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public);
|
||||||
|
signal_remove("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public);
|
||||||
|
}
|
||||||
|
|
@ -68,9 +68,9 @@ static int isnickflag_func(char flag)
|
||||||
return isnickflag(flag);
|
return isnickflag(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ischannel_func(char flag)
|
static int ischannel_func(const char *data)
|
||||||
{
|
{
|
||||||
return ischannel(flag);
|
return ischannel_target(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_message(SERVER_REC *server, const char *target,
|
static void send_message(SERVER_REC *server, const char *target,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@
|
||||||
(a) == '!' || /* secure */ \
|
(a) == '!' || /* secure */ \
|
||||||
(a) == '+') /* modeless */
|
(a) == '+') /* modeless */
|
||||||
|
|
||||||
|
#define ischannel_target(a) \
|
||||||
|
(ischannel((a)[0]) || \
|
||||||
|
((a)[0] == '@' && ischannel((a)[1]))) /* hybrid6 @#channel */
|
||||||
|
|
||||||
#define IS_IRC_ITEM(rec) (IS_IRC_CHANNEL(rec) || IS_IRC_QUERY(rec))
|
#define IS_IRC_ITEM(rec) (IS_IRC_CHANNEL(rec) || IS_IRC_QUERY(rec))
|
||||||
|
|
||||||
extern char *current_server_event; /* current server event being processed */
|
extern char *current_server_event; /* current server event being processed */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue