1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 09:13:14 +02:00

irc: evaluate content of server options "username" and "realname"

This commit is contained in:
Sebastien Helleu
2014-02-28 15:00:39 +01:00
parent 4196dcf7a5
commit cf48fa4642
29 changed files with 333 additions and 210 deletions
+4 -2
View File
@@ -1742,7 +1742,8 @@ irc_config_server_new_option (struct t_config_file *config_file,
new_option = weechat_config_new_option (
config_file, section,
option_name, "string",
N_("user name to use on server"),
N_("user name to use on server "
"(note: content is evaluated, see /help eval)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
@@ -1754,7 +1755,8 @@ irc_config_server_new_option (struct t_config_file *config_file,
new_option = weechat_config_new_option (
config_file, section,
option_name, "string",
N_("real name to use on server"),
N_("real name to use on server "
"(note: content is evaluated, see /help eval)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
+25 -13
View File
@@ -332,7 +332,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
char *
irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
{
char *res, *temp;
char *res, *temp, *username, *realname;
const char *info;
time_t now;
struct tm *local_time;
@@ -463,23 +463,35 @@ irc_ctcp_replace_variables (struct t_irc_server *server, const char *format)
* $username: user name, example:
* name
*/
temp = weechat_string_replace (res, "$username",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME));
free (res);
if (!temp)
return NULL;
res = temp;
username = weechat_string_eval_expression (
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME),
NULL, NULL, NULL);
if (username)
{
temp = weechat_string_replace (res, "$username", username);
free (res);
if (!temp)
return NULL;
res = temp;
free (username);
}
/*
* $realname: real name, example:
* John doe
*/
temp = weechat_string_replace (res, "$realname",
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME));
free (res);
if (!temp)
return NULL;
res = temp;
realname = weechat_string_eval_expression (
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME),
NULL, NULL, NULL);
if (realname)
{
temp = weechat_string_replace (res, "$realname", realname);
free (res);
if (!temp)
return NULL;
res = temp;
free (realname);
}
/* return result */
return res;
+19 -10
View File
@@ -3110,22 +3110,24 @@ irc_server_reconnect_schedule (struct t_irc_server *server)
void
irc_server_login (struct t_irc_server *server)
{
const char *username, *realname, *capabilities;
char *password, *username2;
const char *capabilities;
char *password, *username, *realname, *username2;
password = weechat_string_eval_expression (
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PASSWORD),
NULL, NULL, NULL);
username = weechat_string_eval_expression (
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME),
NULL, NULL, NULL);
realname = weechat_string_eval_expression (
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME),
NULL, NULL, NULL);
password = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_PASSWORD),
NULL, NULL, NULL);
username = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME);
realname = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME);
capabilities = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CAPABILITIES);
if (password && password[0])
irc_server_sendf (server, 0, NULL, "PASS %s", password);
if (password)
free (password);
if (!server->nick)
{
irc_server_set_nick (server,
@@ -3161,6 +3163,13 @@ irc_server_login (struct t_irc_server *server)
0, 1,
&irc_server_timer_connection_cb,
server);
if (password)
free (password);
if (username)
free (username);
if (realname)
free (realname);
}
/*