mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 22:36:38 +02:00
This commit is contained in:
@@ -1233,7 +1233,7 @@ irc_command_devoice (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_command_die: shotdown the server
|
||||
* irc_command_die: shutdown the server
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -3992,7 +3992,8 @@ irc_command_users (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_command_version: gives the version info of nick or server (current or specified)
|
||||
* irc_command_version: gives the version info of nick or server (current or
|
||||
* specified)
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -4069,9 +4070,119 @@ irc_command_voice (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_command_wallchops: send a notice to channel ops
|
||||
*/
|
||||
|
||||
int
|
||||
irc_command_wallchops (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
char *pos_channel;
|
||||
int pos_args;
|
||||
const char *support_wallchops, *support_statusmsg;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
|
||||
IRC_COMMAND_CHECK_SERVER("wallchops", 1);
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (irc_channel_is_channel (argv[1]))
|
||||
{
|
||||
pos_channel = argv[1];
|
||||
pos_args = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos_channel = NULL;
|
||||
pos_args = 1;
|
||||
}
|
||||
|
||||
/* channel not given, use default buffer */
|
||||
if (!pos_channel)
|
||||
{
|
||||
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
|
||||
pos_channel = ptr_channel->name;
|
||||
else
|
||||
{
|
||||
weechat_printf (ptr_server->buffer,
|
||||
_("%s%s: \"%s\" command can only be "
|
||||
"executed in a channel buffer"),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
"wallchops");
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_channel = irc_channel_search (ptr_server, pos_channel);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
weechat_printf (ptr_server->buffer,
|
||||
_("%s%s: you are not on channel \"%s\""),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
pos_channel);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat_printf (ptr_channel->buffer,
|
||||
"%s%sNoticeOp%s -> %s%s%s: %s",
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_NOTICE,
|
||||
IRC_COLOR_CHAT,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
ptr_channel->name,
|
||||
IRC_COLOR_CHAT,
|
||||
argv_eol[pos_args]);
|
||||
|
||||
support_wallchops = irc_server_get_isupport_value (ptr_server,
|
||||
"WALLCHOPS");
|
||||
support_statusmsg = irc_server_get_isupport_value (ptr_server,
|
||||
"STATUSMSG");
|
||||
if (support_wallchops
|
||||
|| (support_statusmsg && strchr (support_statusmsg, '@')))
|
||||
{
|
||||
/*
|
||||
* if WALLCHOPS is supported, or if STATUSMSG includes '@',
|
||||
* then send a notice to @#channel
|
||||
*/
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
|
||||
"NOTICE @%s :%s",
|
||||
ptr_channel->name, argv_eol[pos_args]);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* if WALLCHOPS is not supported and '@' not in STATUSMSG,
|
||||
* then send a notice to each op of channel
|
||||
*/
|
||||
for (ptr_nick = ptr_channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (IRC_NICK_IS_OP(ptr_nick)
|
||||
&& (strcmp (ptr_nick->name, ptr_server->nick) != 0))
|
||||
{
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_LOW,
|
||||
"NOTICE %s :%s",
|
||||
ptr_nick->name, argv_eol[pos_args]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "wallchops");
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_command_wallops: send a message to all currently connected users who
|
||||
* have set the 'w' user mode for themselves
|
||||
* have set the 'w' user mode for themselves
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -4771,6 +4882,12 @@ irc_command_init ()
|
||||
N_("[nickname [nickname]]"),
|
||||
"",
|
||||
"%(nicks)|%*", &irc_command_voice, NULL);
|
||||
weechat_hook_command ("wallchops",
|
||||
N_("send a notice to channel ops"),
|
||||
N_("[channel] text"),
|
||||
N_("channel: channel name\n"
|
||||
" test: text to send"),
|
||||
NULL, &irc_command_wallchops, NULL);
|
||||
weechat_hook_command ("wallops",
|
||||
N_("send a message to all currently connected users "
|
||||
"who have set the 'w' user mode for themselves"),
|
||||
|
||||
@@ -517,10 +517,7 @@ irc_nick_count (struct t_irc_channel *channel, int *total, int *count_op,
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
(*total)++;
|
||||
if ((ptr_nick->flags & IRC_NICK_CHANOWNER) ||
|
||||
(ptr_nick->flags & IRC_NICK_CHANADMIN) ||
|
||||
(ptr_nick->flags & IRC_NICK_CHANADMIN2) ||
|
||||
(ptr_nick->flags & IRC_NICK_OP))
|
||||
if (IRC_NICK_IS_OP(ptr_nick))
|
||||
(*count_op)++;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -38,6 +38,12 @@
|
||||
else \
|
||||
nick->flags &= 0xFFFF - flag;
|
||||
|
||||
#define IRC_NICK_IS_OP(__nick) \
|
||||
((__nick->flags & IRC_NICK_CHANOWNER) || \
|
||||
(__nick->flags & IRC_NICK_CHANADMIN) || \
|
||||
(__nick->flags & IRC_NICK_CHANADMIN2) || \
|
||||
(__nick->flags & IRC_NICK_OP))
|
||||
|
||||
#define IRC_NICK_GROUP_CHANOWNER "01|chanowner"
|
||||
#define IRC_NICK_GROUP_CHANADMIN "02|chanadmin"
|
||||
#define IRC_NICK_GROUP_CHANADMIN2 "03|chanadmin2"
|
||||
|
||||
@@ -994,7 +994,7 @@ IRC_PROTOCOL_CALLBACK(notice)
|
||||
char *pos_target, *pos_args;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
int notify_private;
|
||||
int notify_private, notice_op;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/*
|
||||
@@ -1009,10 +1009,19 @@ IRC_PROTOCOL_CALLBACK(notice)
|
||||
if (ignored)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
notice_op = 0;
|
||||
|
||||
if (argv[0][0] == ':')
|
||||
{
|
||||
pos_target = argv[2];
|
||||
if ((pos_target[0] == '@') && (irc_channel_is_channel (pos_target + 1)))
|
||||
{
|
||||
pos_target++;
|
||||
notice_op = 1;
|
||||
}
|
||||
pos_args = (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3];
|
||||
if (notice_op && (pos_args[0] == '@') && (pos_args[1] == ' '))
|
||||
pos_args += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1034,9 +1043,10 @@ IRC_PROTOCOL_CALLBACK(notice)
|
||||
ptr_nick = irc_nick_search (ptr_channel, nick);
|
||||
weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer,
|
||||
irc_protocol_tags (command, "notify_message"),
|
||||
"%s%sNotice%s(%s%s%s)%s: %s",
|
||||
"%s%sNotice%s%s(%s%s%s)%s: %s",
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_NOTICE,
|
||||
(notice_op) ? "Op" : "",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
(nick && nick[0]) ? nick : "?",
|
||||
|
||||
Reference in New Issue
Block a user