mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 04:13:32 +02:00
Implement CHANTYPES support
This commit is contained in:
parent
c122a2a226
commit
16c71cf1fb
23 changed files with 57 additions and 55 deletions
|
|
@ -186,7 +186,7 @@ static void command_set_ban(const char *data, IRC_SERVER_REC *server,
|
|||
|
||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
||||
item, &channel, &nicks)) return;
|
||||
if (!ischannel(*channel)) cmd_param_error(CMDERR_NOT_JOINED);
|
||||
if (!server_ischannel(SERVER(server), channel)) cmd_param_error(CMDERR_NOT_JOINED);
|
||||
if (*nicks == '\0') {
|
||||
if (g_strcmp0(data, "*") != 0)
|
||||
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ static void event_target_unavailable(IRC_SERVER_REC *server, const char *data)
|
|||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2, NULL, &channel);
|
||||
if (ischannel(*channel)) {
|
||||
if (server_ischannel(SERVER(server), channel)) {
|
||||
chanrec = irc_channel_find(server, channel);
|
||||
if (chanrec != NULL && chanrec->joined) {
|
||||
/* dalnet event - can't change nick while
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ static void irc_channels_join(IRC_SERVER_REC *server, const char *data,
|
|||
tmp = chanlist;
|
||||
for (;; tmp++) {
|
||||
if (*tmp != NULL) {
|
||||
channel = ischannel(**tmp) ? g_strdup(*tmp) :
|
||||
channel = server_ischannel(SERVER(server), *tmp) ? g_strdup(*tmp) :
|
||||
g_strdup_printf("#%s", *tmp);
|
||||
|
||||
chanrec = irc_channel_find(server, channel);
|
||||
|
|
@ -134,7 +134,7 @@ static void irc_channels_join(IRC_SERVER_REC *server, const char *data,
|
|||
if (use_keys)
|
||||
cmdlen += outkeys->len;
|
||||
if (*tmpstr != NULL)
|
||||
cmdlen += ischannel(**tmpstr) ? strlen(*tmpstr) :
|
||||
cmdlen += server_ischannel(SERVER(server), *tmpstr) ? strlen(*tmpstr) :
|
||||
strlen(*tmpstr)+1;
|
||||
if (*tmpkey != NULL)
|
||||
cmdlen += strlen(*tmpkey);
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||
return;
|
||||
|
||||
if (*channame == '\0' || *nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
if (!ischannel(*channame)) cmd_param_error(CMDERR_NOT_JOINED);
|
||||
if (!server_ischannel(SERVER(server), channame)) cmd_param_error(CMDERR_NOT_JOINED);
|
||||
|
||||
recoded = recode_out(SERVER(server), reason, channame);
|
||||
g_string_printf(tmpstr, "KICK %s %s :%s", channame, nicks, recoded);
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ static void event_target_unavailable(IRC_SERVER_REC *server, const char *data)
|
|||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 2, NULL, &channel);
|
||||
if (!ischannel(*channel)) {
|
||||
if (!server_ischannel(SERVER(server), channel)) {
|
||||
/* nick is unavailable. */
|
||||
event_nick_in_use(server, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ static void check_query_changes(IRC_SERVER_REC *server, const char *nick,
|
|||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
if (ischannel(*target))
|
||||
return;
|
||||
if (server_ischannel(SERVER(server), target))
|
||||
return;
|
||||
|
||||
query = irc_query_find(server, nick);
|
||||
if (query == NULL)
|
||||
|
|
|
|||
|
|
@ -71,13 +71,20 @@ static int isnickflag_func(SERVER_REC *server, char flag)
|
|||
|
||||
static int ischannel_func(SERVER_REC *server, const char *data)
|
||||
{
|
||||
if (*data == '@') {
|
||||
/* @#channel, @+#channel */
|
||||
data++;
|
||||
if (*data == '+' && ischannel(data[1]))
|
||||
return 1;
|
||||
}
|
||||
return ischannel(*data);
|
||||
IRC_SERVER_REC *irc_server = (IRC_SERVER_REC *) server;
|
||||
char *chantypes;
|
||||
|
||||
chantypes = g_hash_table_lookup(irc_server->isupport, "chantypes");
|
||||
if (chantypes == NULL)
|
||||
chantypes = "#&!+"; /* normal, local, secure, modeless */
|
||||
|
||||
/* @#channel, @+#channel */
|
||||
if (data[0] == '@' && data[1] == '+')
|
||||
data += 2;
|
||||
else if (data[0] == '@')
|
||||
data += 1;
|
||||
|
||||
return strchr(chantypes, *data) != NULL;
|
||||
}
|
||||
|
||||
static char **split_line(const SERVER_REC *server, const char *line,
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ typedef struct _REDIRECT_REC REDIRECT_REC;
|
|||
#define isnickflag(server, a) \
|
||||
(server->prefix[(int)(unsigned char) a] != '\0')
|
||||
|
||||
#define ischannel(a) \
|
||||
((a) == '#' || /* normal */ \
|
||||
(a) == '&' || /* local */ \
|
||||
(a) == '!' || /* secure */ \
|
||||
(a) == '+') /* modeless */
|
||||
|
||||
#define IS_IRC_ITEM(rec) (IS_IRC_CHANNEL(rec) || IS_IRC_QUERY(rec))
|
||||
#define IRC_PROTOCOL (chat_protocol_lookup("IRC"))
|
||||
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ static void event_mode(IRC_SERVER_REC *server, const char *data,
|
|||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
|
||||
&channel, &mode);
|
||||
|
||||
if (!ischannel(*channel)) {
|
||||
if (!server_ischannel(SERVER(server), channel)) {
|
||||
/* user mode change */
|
||||
parse_user_mode(server, mode);
|
||||
} else {
|
||||
|
|
@ -536,7 +536,7 @@ static void sig_req_usermode_change(IRC_SERVER_REC *server, const char *data,
|
|||
|
||||
params = event_get_params(data, 2 | PARAM_FLAG_GETREST,
|
||||
&target, &mode);
|
||||
if (!ischannel(*target)) {
|
||||
if (!server_ischannel(SERVER(server), target)) {
|
||||
/* we requested a user mode change, save this */
|
||||
mode = modes_join(NULL, server->wanted_usermode, mode, FALSE);
|
||||
g_free_not_null(server->wanted_usermode);
|
||||
|
|
@ -856,7 +856,7 @@ static void cmd_mode(const char *data, IRC_SERVER_REC *server,
|
|||
target = chanrec->name;
|
||||
|
||||
irc_send_cmdv(server, "MODE %s", target);
|
||||
} else if (ischannel(*target))
|
||||
} else if (server_ischannel(SERVER(server), target))
|
||||
channel_set_mode(server, target, mode);
|
||||
else {
|
||||
if (g_ascii_strcasecmp(target, server->nick) == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue