mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
/BAN #channel now shows bans and ban exceptions in specified channel
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@533 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
94c4d228fd
commit
0b2448b97f
@ -312,68 +312,93 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
|||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: BAN [<channel>] [<nicks>] */
|
static void bans_ask_channel(const char *channel, IRC_SERVER_REC *server,
|
||||||
static void cmd_ban(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
|
WI_IRC_REC *item)
|
||||||
|
{
|
||||||
|
GString *str;
|
||||||
|
|
||||||
|
str = g_string_new(NULL);
|
||||||
|
g_string_sprintf(str, "%s b", channel);
|
||||||
|
signal_emit("command mode", 3, str->str, server, item);
|
||||||
|
if (server->emode_known) {
|
||||||
|
g_string_sprintf(str, "%s e", channel);
|
||||||
|
signal_emit("command mode", 3, str->str, server, item);
|
||||||
|
}
|
||||||
|
g_string_free(str, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bans_show_channel(CHANNEL_REC *channel, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CHANNEL_REC *cur_channel, *channel;
|
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
if (channel->banlist == NULL && channel->ebanlist == NULL) {
|
||||||
if (*data != '\0')
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
||||||
return; /* setting ban - don't handle here */
|
IRCTXT_NO_BANS, channel->name);
|
||||||
|
return;
|
||||||
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
|
|
||||||
|
|
||||||
/* display bans */
|
|
||||||
cur_channel = irc_item_channel(item);
|
|
||||||
if (cur_channel == NULL) cmd_return_error(CMDERR_NOT_JOINED);
|
|
||||||
|
|
||||||
if (strcmp(data, "*") == 0 || *data == '\0')
|
|
||||||
channel = cur_channel;
|
|
||||||
else {
|
|
||||||
channel = channel_find(server, data);
|
|
||||||
if (channel == NULL) {
|
|
||||||
/* not joined to such channel, but ask ban lists from server */
|
|
||||||
GString *str;
|
|
||||||
|
|
||||||
str = g_string_new(NULL);
|
|
||||||
g_string_sprintf(str, "%s b", data);
|
|
||||||
signal_emit("command mode", 3, str->str, server, cur_channel);
|
|
||||||
g_string_sprintf(str, "%s e", data);
|
|
||||||
signal_emit("command mode", 3, str->str, server, cur_channel);
|
|
||||||
g_string_free(str, TRUE);
|
|
||||||
signal_stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel == NULL) cmd_return_error(CMDERR_CHAN_NOT_FOUND);
|
|
||||||
|
|
||||||
/* show bans.. */
|
/* show bans.. */
|
||||||
for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) {
|
for (tmp = channel->banlist; tmp != NULL; tmp = tmp->next) {
|
||||||
BAN_REC *rec;
|
BAN_REC *rec = tmp->data;
|
||||||
|
|
||||||
rec = (BAN_REC *) tmp->data;
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
||||||
if (*rec->setby == '\0')
|
*rec->setby == '\0' ? IRCTXT_BANLIST :
|
||||||
printformat(server, channel->name, MSGLEVEL_CRAP, IRCTXT_BANLIST, channel->name, rec->ban);
|
IRCTXT_BANLIST_LONG, channel->name, rec->ban,
|
||||||
else
|
rec->setby, (int) (time(NULL)-rec->time));
|
||||||
printformat(server, channel->name, MSGLEVEL_CRAP, IRCTXT_BANLIST,
|
|
||||||
channel->name, rec->ban, rec->setby, (gint) (time(NULL)-rec->time));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ..and show ban exceptions.. */
|
/* ..and show ban exceptions.. */
|
||||||
for (tmp = channel->ebanlist; tmp != NULL; tmp = tmp->next) {
|
for (tmp = channel->ebanlist; tmp != NULL; tmp = tmp->next) {
|
||||||
BAN_REC *rec;
|
BAN_REC *rec = tmp->data;
|
||||||
|
|
||||||
rec = (BAN_REC *) tmp->data;
|
printformat(server, channel->name, MSGLEVEL_CRAP,
|
||||||
if (*rec->setby == '\0')
|
*rec->setby == '\0' ? IRCTXT_EBANLIST :
|
||||||
printformat(server, channel->name, MSGLEVEL_CRAP, IRCTXT_EBANLIST, channel->name, rec->ban);
|
IRCTXT_EBANLIST_LONG, channel->name, rec->ban,
|
||||||
else
|
rec->setby, (int) (time(NULL)-rec->time));
|
||||||
printformat(server, channel->name, MSGLEVEL_CRAP, IRCTXT_EBANLIST,
|
}
|
||||||
channel->name, rec->ban, rec->setby, (gint) (time(NULL)-rec->time));
|
}
|
||||||
|
|
||||||
|
/* SYNTAX: BAN [<channel>] [<nicks>] */
|
||||||
|
static void cmd_ban(const char *data, IRC_SERVER_REC *server,
|
||||||
|
WI_IRC_REC *item)
|
||||||
|
{
|
||||||
|
CHANNEL_REC *chanrec;
|
||||||
|
char *channel, *nicks;
|
||||||
|
void *free_arg;
|
||||||
|
|
||||||
|
g_return_if_fail(data != NULL);
|
||||||
|
if (server == NULL || !server->connected)
|
||||||
|
cmd_return_error(CMDERR_NOT_CONNECTED);
|
||||||
|
|
||||||
|
if (!cmd_get_params(data, &free_arg, 2 |
|
||||||
|
PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
||||||
|
item, &channel, &nicks))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (*nicks != '\0') {
|
||||||
|
/* setting ban - don't handle here */
|
||||||
|
cmd_params_free(free_arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* display bans */
|
||||||
|
chanrec = irc_item_channel(item);
|
||||||
|
if (chanrec == NULL && *channel == '\0')
|
||||||
|
cmd_param_error(CMDERR_NOT_JOINED);
|
||||||
|
|
||||||
|
if (*channel != '\0' && strcmp(channel, "*") != 0)
|
||||||
|
chanrec = channel_find(server, channel);
|
||||||
|
|
||||||
|
if (chanrec == NULL) {
|
||||||
|
/* not joined to such channel,
|
||||||
|
but ask ban lists from server */
|
||||||
|
bans_ask_channel(channel, server, item);
|
||||||
|
} else {
|
||||||
|
bans_show_channel(chanrec, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
signal_stop();
|
signal_stop();
|
||||||
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: INVITELIST [<channel>] */
|
/* SYNTAX: INVITELIST [<channel>] */
|
||||||
|
@ -86,6 +86,7 @@ FORMAT_REC fecommon_irc_formats[] = {
|
|||||||
{ "server_chanmode_change", "%RServerMode/%c$0 %K[%n$1%K]%n by %_$2", 3, { 0, 0, 0 } },
|
{ "server_chanmode_change", "%RServerMode/%c$0 %K[%n$1%K]%n by %_$2", 3, { 0, 0, 0 } },
|
||||||
{ "channel_mode", "mode/%c$0 %K[%n$1%K]", 2, { 0, 0 } },
|
{ "channel_mode", "mode/%c$0 %K[%n$1%K]", 2, { 0, 0 } },
|
||||||
{ "bantype", "Ban type changed to %_$0", 1, { 0 } },
|
{ "bantype", "Ban type changed to %_$0", 1, { 0 } },
|
||||||
|
{ "no_bans", "No bans in channel %_$0%_", 1, { 0 } },
|
||||||
{ "banlist", "%_$0%_: ban %c$1", 2, { 0, 0 } },
|
{ "banlist", "%_$0%_: ban %c$1", 2, { 0, 0 } },
|
||||||
{ "banlist_long", "%_$0%_: ban %c$1 %K[%nby %_$2%_, $3 secs ago%K]", 4, { 0, 0, 0, 1 } },
|
{ "banlist_long", "%_$0%_: ban %c$1 %K[%nby %_$2%_, $3 secs ago%K]", 4, { 0, 0, 0, 1 } },
|
||||||
{ "ebanlist", "%_$0%_: ban exception %c$1", 2, { 0, 0 } },
|
{ "ebanlist", "%_$0%_: ban exception %c$1", 2, { 0, 0 } },
|
||||||
|
@ -63,6 +63,7 @@ enum {
|
|||||||
IRCTXT_SERVER_CHANMODE_CHANGE,
|
IRCTXT_SERVER_CHANMODE_CHANGE,
|
||||||
IRCTXT_CHANNEL_MODE,
|
IRCTXT_CHANNEL_MODE,
|
||||||
IRCTXT_BANTYPE,
|
IRCTXT_BANTYPE,
|
||||||
|
IRCTXT_NO_BANS,
|
||||||
IRCTXT_BANLIST,
|
IRCTXT_BANLIST,
|
||||||
IRCTXT_BANLIST_LONG,
|
IRCTXT_BANLIST_LONG,
|
||||||
IRCTXT_EBANLIST,
|
IRCTXT_EBANLIST,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user