This commit is contained in:
2018-11-23 16:35:12 +01:00
parent d7ceb5a85a
commit 5706796da5
2 changed files with 10 additions and 7 deletions

View File

@@ -54,14 +54,16 @@ void IrcPlugin::enableProcessTask(Scheduler *scheduler)
processTask.enable(); processTask.enable();
} }
int IrcPlugin::checkConfig(){
int isValid = server.length() == 0 || port == 0 || nick.length() == 0 || user.length() == 0;
publish("irc/configValid", String(isValid));
return isValid;
}
void IrcPlugin::connect() void IrcPlugin::connect()
{ {
if (server.length() == 0 || port == 0 || nick.length() == 0 || user.length() == 0) if (checkConfig() && !client->connected())
{
publish("irc/needsConfig", "");
return;
}
if (!client->connected())
{ {
PRINT_MSG(Serial, "IRC", String("Attempting connection to " + server + ":" + String(port)).c_str()); PRINT_MSG(Serial, "IRC", String("Attempting connection to " + server + ":" + String(port)).c_str());
PRINT_MSG(Serial, "IRC", String("NICK " + nick).c_str()); PRINT_MSG(Serial, "IRC", String("NICK " + nick).c_str());
@@ -82,7 +84,7 @@ void IrcPlugin::connect()
void IrcPlugin::join(String c) void IrcPlugin::join(String c)
{ {
if (client->connected()) if (checkConfig() && client->connected())
{ {
channel = c; channel = c;

View File

@@ -43,6 +43,7 @@ private:
virtual void debugSentCallback(String data); virtual void debugSentCallback(String data);
void join(String channel); void join(String channel);
void sendMessage(String msg); void sendMessage(String msg);
virtual int checkConfig();
}; };
#endif #endif