mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 17:53:13 +02:00
Send channel topic to relay client when joining a channel
This commit is contained in:
+45
-19
@@ -324,39 +324,65 @@ irc_info_get_infolist_cb (void *data, const char *infolist_name,
|
||||
{
|
||||
if (arguments && arguments[0])
|
||||
{
|
||||
ptr_server = irc_server_search (arguments);
|
||||
if (ptr_server)
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
argv = weechat_string_split (arguments, ",", 0, 0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
if (pointer && !irc_channel_valid (ptr_server, pointer))
|
||||
return NULL;
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
if (argc >= 1)
|
||||
{
|
||||
if (pointer)
|
||||
ptr_server = irc_server_search (argv[0]);
|
||||
if (!ptr_server)
|
||||
{
|
||||
/* build list with only one channel */
|
||||
if (!irc_channel_add_to_infolist (ptr_infolist, pointer))
|
||||
weechat_string_free_split (argv);
|
||||
return NULL;
|
||||
}
|
||||
if (!pointer && (argc >= 2))
|
||||
{
|
||||
pointer = irc_channel_search (ptr_server, argv[1]);
|
||||
if (!pointer)
|
||||
{
|
||||
weechat_infolist_free (ptr_infolist);
|
||||
weechat_string_free_split (argv);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
}
|
||||
else
|
||||
}
|
||||
weechat_string_free_split (argv);
|
||||
if (ptr_server)
|
||||
{
|
||||
if (pointer && !irc_channel_valid (ptr_server, pointer))
|
||||
return NULL;
|
||||
|
||||
ptr_infolist = weechat_infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
/* build list with all channels of server */
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
if (pointer)
|
||||
{
|
||||
/* build list with only one channel */
|
||||
if (!irc_channel_add_to_infolist (ptr_infolist,
|
||||
ptr_channel))
|
||||
pointer))
|
||||
{
|
||||
weechat_infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
return ptr_infolist;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* build list with all channels of server */
|
||||
for (ptr_channel = ptr_server->channels;
|
||||
ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (!irc_channel_add_to_infolist (ptr_infolist,
|
||||
ptr_channel))
|
||||
{
|
||||
weechat_infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ptr_infolist;
|
||||
}
|
||||
return ptr_infolist;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,7 +565,7 @@ irc_info_init ()
|
||||
weechat_hook_infolist ("irc_channel",
|
||||
N_("list of channels for an IRC server"),
|
||||
N_("channel pointer (optional)"),
|
||||
N_("server name"),
|
||||
N_("server,channel (channel is optional)"),
|
||||
&irc_info_get_infolist_cb, NULL);
|
||||
weechat_hook_infolist ("irc_nick",
|
||||
N_("list of nicks for an IRC channel"),
|
||||
|
||||
@@ -444,10 +444,10 @@ relay_client_irc_send_join (struct t_relay_client *client,
|
||||
const char *channel)
|
||||
{
|
||||
char *infolist_name, *nicks;
|
||||
const char *nick, *prefix;
|
||||
const char *nick, *prefix, *topic;
|
||||
char *host;
|
||||
int length, length_nicks;
|
||||
struct t_infolist *infolist_nick, *infolist_nicks;
|
||||
struct t_infolist *infolist_nick, *infolist_channel, *infolist_nicks;
|
||||
|
||||
length = strlen (client->protocol_args) + 1 + strlen (channel) + 1
|
||||
+ strlen (RELAY_IRC_DATA(client, nick)) + 1;
|
||||
@@ -481,7 +481,26 @@ relay_client_irc_send_join (struct t_relay_client *client,
|
||||
snprintf (infolist_name, length, "%s,%s",
|
||||
client->protocol_args,
|
||||
channel);
|
||||
infolist_nicks = weechat_infolist_get ("irc_nick", NULL, infolist_name);
|
||||
infolist_channel = weechat_infolist_get ("irc_channel", NULL,
|
||||
infolist_name);
|
||||
if (infolist_channel)
|
||||
{
|
||||
if (weechat_infolist_next (infolist_channel))
|
||||
{
|
||||
topic = weechat_infolist_string (infolist_channel, "topic");
|
||||
if (topic && topic[0])
|
||||
{
|
||||
relay_client_irc_sendf (client,
|
||||
":%s 332 %s %s :%s",
|
||||
RELAY_IRC_DATA(client, address),
|
||||
RELAY_IRC_DATA(client, nick),
|
||||
channel, topic);
|
||||
}
|
||||
}
|
||||
weechat_infolist_free (infolist_channel);
|
||||
}
|
||||
infolist_nicks = weechat_infolist_get ("irc_nick", NULL,
|
||||
infolist_name);
|
||||
if (infolist_nicks)
|
||||
{
|
||||
length_nicks = 0;
|
||||
|
||||
Reference in New Issue
Block a user