mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-25 18:52:22 -05:00
Add QUIET command
This commit is contained in:
parent
0dd9ac2e44
commit
612032c9f8
@ -417,33 +417,27 @@ cmd_back (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static char *
|
||||||
ban (session * sess, char *tbuf, char *mask, char *bantypestr, int deop)
|
create_mask (session * sess, char *mask, char *mode, char *typestr, int deop)
|
||||||
{
|
{
|
||||||
int bantype;
|
int type;
|
||||||
struct User *user;
|
struct User *user;
|
||||||
char *at, *dot, *lastdot;
|
char *at, *dot, *lastdot;
|
||||||
char username[64], fullhost[128], domain[128], *mode, *p2;
|
char username[64], fullhost[128], domain[128], tbuf[512], *p2;
|
||||||
server *serv = sess->server;
|
|
||||||
|
|
||||||
user = userlist_find (sess, mask);
|
user = userlist_find (sess, mask);
|
||||||
if (user && user->hostname) /* it's a nickname, let's find a proper ban mask */
|
if (user && user->hostname) /* it's a nickname, let's find a proper ban mask */
|
||||||
{
|
{
|
||||||
if (deop)
|
if (deop)
|
||||||
{
|
|
||||||
mode = "-o+b ";
|
|
||||||
p2 = user->nick;
|
p2 = user->nick;
|
||||||
} else
|
else
|
||||||
{
|
|
||||||
mode = "+b";
|
|
||||||
p2 = "";
|
p2 = "";
|
||||||
}
|
|
||||||
|
|
||||||
mask = user->hostname;
|
mask = user->hostname;
|
||||||
|
|
||||||
at = strchr (mask, '@'); /* FIXME: utf8 */
|
at = strchr (mask, '@'); /* FIXME: utf8 */
|
||||||
if (!at)
|
if (!at)
|
||||||
return; /* can't happen? */
|
return NULL; /* can't happen? */
|
||||||
*at = 0;
|
*at = 0;
|
||||||
|
|
||||||
if (mask[0] == '~' || mask[0] == '+' ||
|
if (mask[0] == '~' || mask[0] == '+' ||
|
||||||
@ -474,23 +468,23 @@ ban (session * sess, char *tbuf, char *mask, char *bantypestr, int deop)
|
|||||||
safe_strcpy (domain, fullhost, sizeof (domain));
|
safe_strcpy (domain, fullhost, sizeof (domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*bantypestr)
|
if (*typestr)
|
||||||
bantype = atoi (bantypestr);
|
type = atoi (typestr);
|
||||||
else
|
else
|
||||||
bantype = prefs.hex_irc_ban_type;
|
type = prefs.hex_irc_ban_type;
|
||||||
|
|
||||||
tbuf[0] = 0;
|
tbuf[0] = 0;
|
||||||
if (inet_addr (fullhost) != -1) /* "fullhost" is really a IP number */
|
if (inet_addr (fullhost) != -1) /* "fullhost" is really a IP number */
|
||||||
{
|
{
|
||||||
lastdot = strrchr (fullhost, '.');
|
lastdot = strrchr (fullhost, '.');
|
||||||
if (!lastdot)
|
if (!lastdot)
|
||||||
return; /* can't happen? */
|
return NULL; /* can't happen? */
|
||||||
|
|
||||||
*lastdot = 0;
|
*lastdot = 0;
|
||||||
strcpy (domain, fullhost);
|
strcpy (domain, fullhost);
|
||||||
*lastdot = '.';
|
*lastdot = '.';
|
||||||
|
|
||||||
switch (bantype)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
snprintf (tbuf, TBUFSIZE, "%s%s *!*@%s.*", mode, p2, domain);
|
snprintf (tbuf, TBUFSIZE, "%s%s *!*@%s.*", mode, p2, domain);
|
||||||
@ -510,7 +504,7 @@ ban (session * sess, char *tbuf, char *mask, char *bantypestr, int deop)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
switch (bantype)
|
switch (type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
snprintf (tbuf, TBUFSIZE, "%s%s *!*@*%s", mode, p2, domain);
|
snprintf (tbuf, TBUFSIZE, "%s%s *!*@*%s", mode, p2, domain);
|
||||||
@ -532,9 +526,23 @@ ban (session * sess, char *tbuf, char *mask, char *bantypestr, int deop)
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
snprintf (tbuf, TBUFSIZE, "+b %s", mask);
|
snprintf (tbuf, TBUFSIZE, "%s %s", mode, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup (tbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ban (session * sess, char *tbuf, char *mask, char *bantypestr, int deop)
|
||||||
|
{
|
||||||
|
char *banmask = create_mask (sess, mask, deop ? "-o+b" : "+b", bantypestr, deop);
|
||||||
|
server *serv = sess->server;
|
||||||
|
|
||||||
|
if (banmask)
|
||||||
|
{
|
||||||
|
serv->p_mode (serv, sess->channel, banmask);
|
||||||
|
g_free (banmask);
|
||||||
}
|
}
|
||||||
serv->p_mode (serv, sess->channel, tbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -2972,6 +2980,61 @@ cmd_query (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_quiet (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
|
{
|
||||||
|
char *quietmask;
|
||||||
|
server *serv = sess->server;
|
||||||
|
|
||||||
|
if (strchr (serv->chanmodes, 'q') == NULL)
|
||||||
|
{
|
||||||
|
PrintText (sess, _("Quiet is not supported by this server."));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*word[2])
|
||||||
|
{
|
||||||
|
quietmask = create_mask (sess, word[2], "+q", word[3], 0);
|
||||||
|
|
||||||
|
if (quietmask)
|
||||||
|
{
|
||||||
|
serv->p_mode (serv, sess->channel, quietmask);
|
||||||
|
g_free (quietmask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serv->p_mode (serv, sess->channel, "+q"); /* quietlist */
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmd_unquiet (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
|
{
|
||||||
|
/* Allow more than one mask in /unban -- tvk */
|
||||||
|
int i = 2;
|
||||||
|
|
||||||
|
if (strchr (sess->server->chanmodes, 'q') == NULL)
|
||||||
|
{
|
||||||
|
PrintText (sess, _("Quiet is not supported by this server."));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (!*word[i])
|
||||||
|
{
|
||||||
|
if (i == 2)
|
||||||
|
return FALSE;
|
||||||
|
send_channel_modes (sess, tbuf, word, 2, i, '-', 'q', 0);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmd_quote (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
cmd_quote (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||||
{
|
{
|
||||||
@ -3822,6 +3885,8 @@ const struct commands xc_cmds[] = {
|
|||||||
N_("PING <nick | channel>, CTCP pings nick or channel")},
|
N_("PING <nick | channel>, CTCP pings nick or channel")},
|
||||||
{"QUERY", cmd_query, 0, 0, 1,
|
{"QUERY", cmd_query, 0, 0, 1,
|
||||||
N_("QUERY [-nofocus] <nick>, opens up a new privmsg window to someone")},
|
N_("QUERY [-nofocus] <nick>, opens up a new privmsg window to someone")},
|
||||||
|
{"QUIET", cmd_quiet, 1, 1, 1,
|
||||||
|
N_("QUIET <mask> [<quiettype>], quiet everyone matching the mask in the current channel if supported by the server.")},
|
||||||
{"QUIT", cmd_quit, 0, 0, 1,
|
{"QUIT", cmd_quit, 0, 0, 1,
|
||||||
N_("QUIT [<reason>], disconnects from the current server")},
|
N_("QUIT [<reason>], disconnects from the current server")},
|
||||||
{"QUOTE", cmd_quote, 1, 0, 1,
|
{"QUOTE", cmd_quote, 1, 0, 1,
|
||||||
@ -3870,6 +3935,8 @@ const struct commands xc_cmds[] = {
|
|||||||
N_("UNBAN <mask> [<mask>...], unbans the specified masks.")},
|
N_("UNBAN <mask> [<mask>...], unbans the specified masks.")},
|
||||||
{"UNIGNORE", cmd_unignore, 0, 0, 1, N_("UNIGNORE <mask> [QUIET]")},
|
{"UNIGNORE", cmd_unignore, 0, 0, 1, N_("UNIGNORE <mask> [QUIET]")},
|
||||||
{"UNLOAD", cmd_unload, 0, 0, 1, N_("UNLOAD <name>, unloads a plugin or script")},
|
{"UNLOAD", cmd_unload, 0, 0, 1, N_("UNLOAD <name>, unloads a plugin or script")},
|
||||||
|
{"UNQUIET", cmd_unquiet, 1, 1, 1,
|
||||||
|
N_("UNQUIET <mask> [<mask>...], unquiets the specified masks if supported by the server.")},
|
||||||
{"URL", cmd_url, 0, 0, 1, N_("URL <url>, opens a URL in your browser")},
|
{"URL", cmd_url, 0, 0, 1, N_("URL <url>, opens a URL in your browser")},
|
||||||
{"USELECT", cmd_uselect, 0, 1, 0,
|
{"USELECT", cmd_uselect, 0, 1, 0,
|
||||||
N_("USELECT [-a] [-s] <nick1> <nick2> etc, highlights nick(s) in channel userlist")},
|
N_("USELECT [-a] [-s] <nick1> <nick2> etc, highlights nick(s) in channel userlist")},
|
||||||
|
Loading…
Reference in New Issue
Block a user