Change send_text() to combine command, hook and log arguments into one set of flags
This function is exported to modules, so it requires updating a few modules and rolling the module table version.
This commit is contained in:
@@ -843,6 +843,8 @@ char *tmp = NULL;
|
||||
/* display the offerlist to current channel */
|
||||
int l_plist(char *args, char *rest)
|
||||
{
|
||||
const unsigned stxt_flags = (do_notice_list ? STXT_NOTICE : 0) | (do_cdcc_echo ? 0 : STXT_QUIET);
|
||||
const char * const type_msg = do_notice_list ? "NOTICE" : "PRIVMSG";
|
||||
pack *ptr;
|
||||
char *chan = NULL;
|
||||
char size[20];
|
||||
@@ -851,7 +853,6 @@ int l_plist(char *args, char *rest)
|
||||
char bytes_out[30];
|
||||
char bytes_in[30];
|
||||
char speed_out[30];
|
||||
char *type_msg;
|
||||
int maxdccs, blocksize, maxqueue;
|
||||
|
||||
if (!get_current_channel_by_refnum(0) || !cdcc_numpacks || (args && *args && !is_channel(args))) {
|
||||
@@ -860,7 +861,6 @@ int l_plist(char *args, char *rest)
|
||||
"have no packs offered!");
|
||||
return 0;
|
||||
}
|
||||
type_msg = (do_notice_list)? "NOTICE":"PRIVMSG";
|
||||
|
||||
if (args && *args)
|
||||
chan = LOCAL_COPY(args);
|
||||
@@ -888,14 +888,14 @@ int l_plist(char *args, char *rest)
|
||||
if (get_int_var(QUEUE_SENDS_VAR))
|
||||
{
|
||||
queue_send_to_server(from_server, "%s %s :%s",
|
||||
do_notice_list?"NOTICE":"PRIVMSG", chan, msg1);
|
||||
type_msg, chan, msg1);
|
||||
queue_send_to_server(from_server, "%s %s :%s",
|
||||
do_notice_list?"NOTICE":"PRIVMSG", chan, msg2);
|
||||
type_msg, chan, msg2);
|
||||
}
|
||||
else
|
||||
{
|
||||
send_text(chan, msg1, do_notice_list?"NOTICE":NULL, do_cdcc_echo, 0);
|
||||
send_text(chan, msg2, do_notice_list?"NOTICE":NULL, do_cdcc_echo, 0);
|
||||
send_text(chan, msg1, stxt_flags);
|
||||
send_text(chan, msg2, stxt_flags);
|
||||
}
|
||||
new_free(&msg1);
|
||||
new_free(&msg2);
|
||||
@@ -917,11 +917,11 @@ int l_plist(char *args, char *rest)
|
||||
if (get_int_var(QUEUE_SENDS_VAR))
|
||||
{
|
||||
queue_send_to_server(from_server, "%s %s :%s",
|
||||
do_notice_list?"NOTICE":"PRIVMSG", chan, msg);
|
||||
type_msg, chan, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
send_text(chan, msg, do_notice_list?"NOTICE":NULL, do_cdcc_echo, 0);
|
||||
send_text(chan, msg, stxt_flags);
|
||||
}
|
||||
new_free(&msg);
|
||||
}
|
||||
@@ -930,9 +930,9 @@ int l_plist(char *args, char *rest)
|
||||
char *msg = m_sprintf("\t%s", ptr->notes);
|
||||
if (get_int_var(QUEUE_SENDS_VAR))
|
||||
queue_send_to_server(from_server, "%s %s :%s",
|
||||
do_notice_list?"NOTICE":"PRIVMSG", chan, msg);
|
||||
type_msg, chan, msg);
|
||||
else
|
||||
send_text(chan, msg, do_notice_list?"NOTICE":NULL, do_cdcc_echo, 0);
|
||||
send_text(chan, msg, stxt_flags);
|
||||
new_free(&msg);
|
||||
}
|
||||
}
|
||||
@@ -981,7 +981,7 @@ static int l_notice(char *args, char *rest)
|
||||
if (get_int_var(QUEUE_SENDS_VAR))
|
||||
queue_send_to_server(from_server, "NOTICE %s :%s", chan, msg);
|
||||
else
|
||||
send_text(chan, msg, "NOTICE", do_cdcc_echo, 0);
|
||||
send_text(chan, msg, STXT_NOTICE | (do_cdcc_echo ? 0 : STXT_QUIET));
|
||||
new_free(&msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -3313,8 +3313,11 @@ BUILT_IN_COMMAND(e_wall)
|
||||
*/
|
||||
BUILT_IN_COMMAND(e_privmsg)
|
||||
{
|
||||
char *nick;
|
||||
unsigned stxt_flags = (window_display ? 0 : STXT_QUIET) | STXT_LOG;
|
||||
char *nick;
|
||||
|
||||
if (command && !strcmp(command, "NOTICE"))
|
||||
stxt_flags |= STXT_NOTICE;
|
||||
|
||||
if ((nick = next_arg(args, &args)) != NULL)
|
||||
{
|
||||
@@ -3336,7 +3339,7 @@ BUILT_IN_COMMAND(e_privmsg)
|
||||
}
|
||||
else if (!strcmp(nick, "*") && (!(nick = get_current_channel_by_refnum(0))))
|
||||
nick = zero;
|
||||
send_text(nick, args, command, window_display, 1);
|
||||
send_text(nick, args, stxt_flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3732,7 +3735,7 @@ int command_exist (char *command)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void redirect_text (int to_server, const char *nick_list, const char *text, char *command, int hook, int log)
|
||||
void redirect_text(int to_server, const char *nick_list, const char *text, unsigned flags)
|
||||
{
|
||||
static int recursion = 0;
|
||||
int old_from_server = from_server;
|
||||
@@ -3746,7 +3749,7 @@ static int recursion = 0;
|
||||
* Dont hook /ON REDIRECT if we're being called recursively
|
||||
*/
|
||||
if (allow)
|
||||
send_text(nick_list, text, command, hook, log);
|
||||
send_text(nick_list, text, flags);
|
||||
|
||||
recursion--;
|
||||
from_server = old_from_server;
|
||||
@@ -3868,10 +3871,9 @@ int current_target = 0;
|
||||
* end up in one of the above mentioned buckets get sent out all
|
||||
* at once.
|
||||
*/
|
||||
void BX_send_text(const char *nick_list, const char *text, char *command, int hook, int log)
|
||||
void BX_send_text(const char *nick_list, const char *text, unsigned flags)
|
||||
{
|
||||
static int sent_text_recursion = 0;
|
||||
unsigned flags = (hook ? 0 : STXT_QUIET) | (log ? STXT_LOG : 0);
|
||||
|
||||
int i,
|
||||
done_forward = 0,
|
||||
@@ -3907,9 +3909,6 @@ void BX_send_text(const char *nick_list, const char *text, char *command, int h
|
||||
|
||||
window_display = !(flags & STXT_QUIET);
|
||||
|
||||
if (command && !strcmp(command, "NOTICE"))
|
||||
flags |= STXT_NOTICE;
|
||||
|
||||
free_nick = next_nick = m_strdup(nick_list);
|
||||
|
||||
while ((current_nick = next_nick))
|
||||
@@ -4071,9 +4070,9 @@ BUILT_IN_COMMAND(do_send_text)
|
||||
else
|
||||
#endif
|
||||
if (!my_stricmp(cmd, "SAY") || !my_stricmp(cmd, "PRIVMSG") || !my_stricmp(cmd, "MSG"))
|
||||
send_text(tmp, text, NULL, 1, 1);
|
||||
send_text(tmp, text, STXT_LOG);
|
||||
else if (!my_stricmp(cmd, "NOTICE"))
|
||||
send_text(tmp, text, "NOTICE", 1, 1);
|
||||
send_text(tmp, text, STXT_NOTICE | STXT_LOG);
|
||||
else if (!my_strnicmp(cmd, "WALLO", 5))
|
||||
e_wall("WALLOPS", text, NULL, NULL);
|
||||
else if (!my_strnicmp(cmd, "SWALLO", 6))
|
||||
@@ -4087,10 +4086,10 @@ BUILT_IN_COMMAND(do_send_text)
|
||||
cmsg(NULL, text, NULL, NULL);
|
||||
#endif
|
||||
else
|
||||
send_text(tmp, text, NULL, 1, 1);
|
||||
send_text(tmp, text, STXT_LOG);
|
||||
}
|
||||
else
|
||||
send_text(tmp, text, NULL, 1, 1);
|
||||
send_text(tmp, text, STXT_LOG);
|
||||
}
|
||||
|
||||
BUILT_IN_COMMAND(do_msay)
|
||||
@@ -4110,7 +4109,7 @@ BUILT_IN_COMMAND(do_msay)
|
||||
}
|
||||
from_server = i;
|
||||
if (channels)
|
||||
send_text(channels, args, NULL, 1, 1);
|
||||
send_text(channels, args, STXT_LOG);
|
||||
new_free(&channels);
|
||||
from_server = old_from_server;
|
||||
} else
|
||||
|
||||
@@ -933,7 +933,7 @@ BUILT_IN_COMMAND(show_version)
|
||||
nick = next_arg(args, &args);
|
||||
else
|
||||
nick = get_current_channel_by_refnum(0);
|
||||
send_text(nick, version_buf, "PRIVMSG", 1, 0);
|
||||
send_text(nick, version_buf, 0);
|
||||
new_free(&version_buf);
|
||||
}
|
||||
|
||||
@@ -1979,7 +1979,7 @@ BUILT_IN_COMMAND(pastecmd)
|
||||
if (start_pos && start_pos->line)
|
||||
{
|
||||
if (do_hook(PASTE_LIST, "%s %s", channel, start_pos->line))
|
||||
send_text(channel, convert_output_format(fget_string_var(FORMAT_PASTE_FSET),"%s %d %s", channel, line, start_pos->line), NULL, 1, 0);
|
||||
send_text(channel, convert_output_format(fget_string_var(FORMAT_PASTE_FSET),"%s %d %s", channel, line, start_pos->line), 0);
|
||||
start_pos = start_pos->next;
|
||||
}
|
||||
count--;
|
||||
|
||||
@@ -1584,7 +1584,7 @@ extern void send_ctcp (int type, char *to, int datatag, char *format, ...)
|
||||
|
||||
putbuf2[len - 2] = CTCP_DELIM_CHAR;
|
||||
putbuf2[len - 1] = 0;
|
||||
send_text(to, putbuf2, ctcp_type[type], 0, 0);
|
||||
send_text(to, putbuf2, (type == CTCP_NOTICE ? STXT_NOTICE : 0) | STXT_QUIET);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -860,7 +860,7 @@ static void handle_filedesc (Process *proc, int *fd, int hook_nonl, int hook_nl
|
||||
|
||||
if (proc->redirect)
|
||||
redirect_text(proc->server, proc->who,
|
||||
exec_buffer, proc->redirect, 1, 0);
|
||||
exec_buffer, !strcmp(proc->redirect, "NOTICE") ? STXT_NOTICE : 0);
|
||||
|
||||
if (hook_nl == EXEC_LIST && proc->stdoutc)
|
||||
parse_line("EXEC", proc->stdoutc, exec_buffer, 0, 0, 1);
|
||||
|
||||
@@ -2832,13 +2832,13 @@ void gtk_main_paste (int refnum)
|
||||
{
|
||||
if(*current_window->query_nick && bit && *bit)
|
||||
if (do_hook(PASTE_LIST, "%s %s", current_window->query_nick, bit))
|
||||
send_text(current_window->query_nick, bit, NULL, 1, 0);
|
||||
send_text(current_window->query_nick, bit, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(channel && *channel && bit && *bit)
|
||||
if (do_hook(PASTE_LIST, "%s %s", channel, bit))
|
||||
send_text(channel, bit, NULL, 1, 0);
|
||||
send_text(channel, bit, 0);
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -2905,13 +2905,13 @@ void gtk_main_paste (int refnum)
|
||||
{
|
||||
if(*current_window->query_nick && *smart)
|
||||
if (do_hook(PASTE_LIST, "%s %s", current_window->query_nick, smart))
|
||||
send_text(current_window->query_nick, smart, NULL, 1, 0);
|
||||
send_text(current_window->query_nick, smart, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(channel && *channel && *smart)
|
||||
if (do_hook(PASTE_LIST, "%s %s", channel, smart))
|
||||
send_text(channel, smart, NULL, 1, 0);
|
||||
send_text(channel, smart, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3248,12 +3248,12 @@ void gui_paste(char *args)
|
||||
if(current_window->query_nick)
|
||||
{
|
||||
if (do_hook(PASTE_LIST, "%s %s", current_window->query_nick, bit))
|
||||
send_text(current_window->query_nick, bit, NULL, 1, 0);
|
||||
send_text(current_window->query_nick, bit, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (do_hook(PASTE_LIST, "%s %s", channel, bit))
|
||||
send_text(channel, bit, NULL, 1, 0);
|
||||
send_text(channel, bit, 0);
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -3316,12 +3316,12 @@ void gui_paste(char *args)
|
||||
if(current_window->query_nick)
|
||||
{
|
||||
if (do_hook(PASTE_LIST, "%s %s", current_window->query_nick, smart))
|
||||
send_text(current_window->query_nick, smart, NULL, 1, 0);
|
||||
send_text(current_window->query_nick, smart, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (do_hook(PASTE_LIST, "%s %s", channel, smart))
|
||||
send_text(channel, smart, NULL, 1, 0);
|
||||
send_text(channel, smart, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -206,8 +206,8 @@ void BX_add_to_window(Window *window, const char *str)
|
||||
|
||||
if (window->server >= 0 && get_server_redirect(window->server))
|
||||
redirect_text(window->server,
|
||||
get_server_redirect(window->server),
|
||||
str, NULL, 0, 0);
|
||||
get_server_redirect(window->server), str, STXT_QUIET);
|
||||
|
||||
if (do_hook(WINDOW_LIST, "%u %s", window->refnum, str))
|
||||
{
|
||||
char **lines;
|
||||
|
||||
@@ -421,7 +421,7 @@ int i;
|
||||
}
|
||||
for (i = 2; i < argc; i++)
|
||||
m_s3cat(&buffer, space, argv[i]);
|
||||
send_text(argv[1], buffer, !strcmp(argv[0], "notice")?"NOTICE":"PRIVMSG", 1, 1);
|
||||
send_text(argv[1], buffer, (!strcmp(argv[0], "notice") ? STXT_NOTICE : 0) | STXT_LOG);
|
||||
new_free(&buffer);
|
||||
return TCL_OK;
|
||||
}
|
||||
@@ -438,7 +438,7 @@ int i;
|
||||
}
|
||||
for (i = 1; i < argc; i++)
|
||||
m_s3cat(&buffer, space, argv[i]);
|
||||
send_text(get_current_channel_by_refnum(0), buffer, "PRIVMSG", 1, 1);
|
||||
send_text(get_current_channel_by_refnum(0), buffer, STXT_LOG);
|
||||
new_free(&buffer);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user