Add a field (in the configure form) to specifiy an after-connect IRC command
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
<field name="server" type="string" length="3071"/>
|
<field name="server" type="string" length="3071"/>
|
||||||
|
|
||||||
<field name="pass" type="string" length="1024" default=""/>
|
<field name="pass" type="string" length="1024" default=""/>
|
||||||
|
<field name="afterConnectionCommand" type="string" length="510" default=""/>
|
||||||
<field name="tlsPorts" type="string" length="4096" default="6697;6670" />
|
<field name="tlsPorts" type="string" length="4096" default="6697;6670" />
|
||||||
<field name="ports" type="string" length="4096" default="6667" />
|
<field name="ports" type="string" length="4096" default="6667" />
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ void IrcClient::send_message(IrcMessage&& message)
|
|||||||
|
|
||||||
void IrcClient::send_raw(const std::string& txt)
|
void IrcClient::send_raw(const std::string& txt)
|
||||||
{
|
{
|
||||||
|
log_debug("IRC SENDING (raw): (" << this->get_hostname() << ") " << txt);
|
||||||
this->send_data(txt + "\r\n");
|
this->send_data(txt + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,6 +609,12 @@ void IrcClient::on_welcome_message(const IrcMessage& message)
|
|||||||
{
|
{
|
||||||
this->current_nick = message.arguments[0];
|
this->current_nick = message.arguments[0];
|
||||||
this->welcomed = true;
|
this->welcomed = true;
|
||||||
|
#ifdef USE_DATABASE
|
||||||
|
auto options = Database::get_irc_server_options(this->bridge->get_bare_jid(),
|
||||||
|
this->get_hostname());
|
||||||
|
if (!options.afterConnectionCommand.value().empty())
|
||||||
|
this->send_raw(options.afterConnectionCommand.value());
|
||||||
|
#endif
|
||||||
// Install a repeated events to regularly send a PING
|
// Install a repeated events to regularly send a PING
|
||||||
TimedEventsManager::instance().add_event(TimedEvent(240s, std::bind(&IrcClient::send_ping_command, this),
|
TimedEventsManager::instance().add_event(TimedEvent(240s, std::bind(&IrcClient::send_ping_command, this),
|
||||||
"PING"s + this->hostname + this->bridge->get_jid()));
|
"PING"s + this->hostname + this->bridge->get_jid()));
|
||||||
|
|||||||
@@ -177,6 +177,20 @@ void ConfigureIrcServerStep1(XmppComponent* xmpp_component, AdhocSession& sessio
|
|||||||
pass.add_child(required);
|
pass.add_child(required);
|
||||||
x.add_child(std::move(pass));
|
x.add_child(std::move(pass));
|
||||||
|
|
||||||
|
XmlNode after_cnt_cmd("field");
|
||||||
|
after_cnt_cmd["var"] = "after_connect_command";
|
||||||
|
after_cnt_cmd["type"] = "text-single";
|
||||||
|
after_cnt_cmd["desc"] = "Custom IRC command sent after the connection is established with the server.";
|
||||||
|
after_cnt_cmd["label"] = "After-connection IRC command";
|
||||||
|
if (!options.afterConnectionCommand.value().empty())
|
||||||
|
{
|
||||||
|
XmlNode after_cnt_cmd_value("value");
|
||||||
|
after_cnt_cmd_value.set_inner(options.afterConnectionCommand.value());
|
||||||
|
after_cnt_cmd.add_child(std::move(after_cnt_cmd_value));
|
||||||
|
}
|
||||||
|
after_cnt_cmd.add_child(required);
|
||||||
|
x.add_child(std::move(after_cnt_cmd));
|
||||||
|
|
||||||
command_node.add_child(std::move(x));
|
command_node.add_child(std::move(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,6 +230,10 @@ void ConfigureIrcServerStep2(XmppComponent* xmpp_component, AdhocSession& sessio
|
|||||||
else if (field->get_tag("var") == "pass" &&
|
else if (field->get_tag("var") == "pass" &&
|
||||||
value && !value->get_inner().empty())
|
value && !value->get_inner().empty())
|
||||||
options.pass = value->get_inner();
|
options.pass = value->get_inner();
|
||||||
|
|
||||||
|
else if (field->get_tag("var") == "after_connect_command" &&
|
||||||
|
value && !value->get_inner().empty())
|
||||||
|
options.afterConnectionCommand = value->get_inner();
|
||||||
}
|
}
|
||||||
|
|
||||||
options.update();
|
options.update();
|
||||||
|
|||||||
Reference in New Issue
Block a user