mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 01:03:14 +02:00
irc: add option irc.look.join_auto_add_chantype (closes #65)
This commit is contained in:
@@ -463,6 +463,39 @@ irc_channel_is_channel (struct t_irc_server *server, const char *string)
|
||||
1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a string with a channel type to add in front of a channel name,
|
||||
* if it doesn't have a valid channel type for the given server.
|
||||
*
|
||||
* It returns an empty string if the channel already has a valid channel type,
|
||||
* or if the option irc.look.join_auto_add_chantype is off.
|
||||
*/
|
||||
|
||||
const char *
|
||||
irc_channel_get_auto_chantype (struct t_irc_server *server,
|
||||
const char *channel_name)
|
||||
{
|
||||
static char chantype[2];
|
||||
|
||||
chantype[0] = '\0';
|
||||
chantype[1] = '\0';
|
||||
|
||||
if (weechat_config_boolean (irc_config_look_join_auto_add_chantype)
|
||||
&& !irc_channel_is_channel (server, channel_name)
|
||||
&& server->chantypes
|
||||
&& server->chantypes[0])
|
||||
{
|
||||
/*
|
||||
* use '#' if it's in chantypes (anywhere in the string), because it is
|
||||
* the most common channel type, and fallback on first channel type
|
||||
*/
|
||||
chantype[0] = (strchr (server->chantypes, '#')) ?
|
||||
'#' : server->chantypes[0];
|
||||
}
|
||||
|
||||
return chantype;
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes away for all nicks on a channel.
|
||||
*/
|
||||
|
||||
@@ -96,6 +96,8 @@ extern struct t_irc_channel *irc_channel_search (struct t_irc_server *server,
|
||||
const char *channel_name);
|
||||
extern int irc_channel_is_channel (struct t_irc_server *server,
|
||||
const char *string);
|
||||
extern const char *irc_channel_get_auto_chantype (struct t_irc_server *server,
|
||||
const char *channel_name);
|
||||
extern void irc_channel_remove_away (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel);
|
||||
extern void irc_channel_check_away (struct t_irc_server *server,
|
||||
|
||||
@@ -2224,9 +2224,6 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
|
||||
free (new_args);
|
||||
}
|
||||
|
||||
/*
|
||||
* add "#" in front of each channel if no prefix is given
|
||||
*/
|
||||
if (channels)
|
||||
{
|
||||
length = strlen (arguments) + num_channels + 1;
|
||||
@@ -2236,7 +2233,7 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
|
||||
if (manual_join)
|
||||
{
|
||||
snprintf (new_args, length, "%s%s",
|
||||
(irc_channel_is_channel (server, channels[0])) ? "" : "#",
|
||||
irc_channel_get_auto_chantype (server, channels[0]),
|
||||
channels[0]);
|
||||
ptr_channel = irc_channel_search (server, new_args);
|
||||
if (ptr_channel)
|
||||
@@ -2255,10 +2252,8 @@ irc_command_join_server (struct t_irc_server *server, const char *arguments,
|
||||
if (i > 0)
|
||||
strcat (new_args, ",");
|
||||
pos_channel = new_args + strlen (new_args);
|
||||
if (!irc_channel_is_channel (server, channels[i]))
|
||||
{
|
||||
strcat (new_args, "#");
|
||||
}
|
||||
strcat (new_args,
|
||||
irc_channel_get_auto_chantype (server, channels[i]));
|
||||
strcat (new_args, channels[i]);
|
||||
if (manual_join || noswitch)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,7 @@ struct t_config_option *irc_config_look_item_channel_modes_hide_args;
|
||||
struct t_config_option *irc_config_look_item_display_server;
|
||||
struct t_config_option *irc_config_look_item_nick_modes;
|
||||
struct t_config_option *irc_config_look_item_nick_prefix;
|
||||
struct t_config_option *irc_config_look_join_auto_add_chantype;
|
||||
struct t_config_option *irc_config_look_msgbuffer_fallback;
|
||||
struct t_config_option *irc_config_look_new_channel_position;
|
||||
struct t_config_option *irc_config_look_new_pv_position;
|
||||
@@ -2443,6 +2444,15 @@ irc_config_init ()
|
||||
N_("display nick prefix in bar item \"input_prompt\""),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_bar_item_input_prompt, NULL, NULL, NULL);
|
||||
irc_config_look_join_auto_add_chantype = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"join_auto_add_chantype", "boolean",
|
||||
N_("automatically add channel type in front of channel name on "
|
||||
"command /join if the channel name does not start with a valid "
|
||||
"channel type for the server; for example: \"/join weechat\" will "
|
||||
"in fact send: \"/join #weechat\""),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
irc_config_look_msgbuffer_fallback = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"msgbuffer_fallback", "integer",
|
||||
|
||||
@@ -123,6 +123,7 @@ extern struct t_config_option *irc_config_look_item_channel_modes_hide_args;
|
||||
extern struct t_config_option *irc_config_look_item_display_server;
|
||||
extern struct t_config_option *irc_config_look_item_nick_modes;
|
||||
extern struct t_config_option *irc_config_look_item_nick_prefix;
|
||||
extern struct t_config_option *irc_config_look_join_auto_add_chantype;
|
||||
extern struct t_config_option *irc_config_look_msgbuffer_fallback;
|
||||
extern struct t_config_option *irc_config_look_new_channel_position;
|
||||
extern struct t_config_option *irc_config_look_new_pv_position;
|
||||
|
||||
Reference in New Issue
Block a user