added NeonBackup bot
[NeonServV5.git] / src / main.c
index 1287faf242dcba4c22148ccc945e55931ad570ea..08193780344d6b59b4257ececd6c636b4342c824 100644 (file)
@@ -40,6 +40,7 @@
 #include "version.h"
 #include "modules.h"
 #include "module_commands.h"
+#include "ModuleFunctions.h"
 
 time_t start_time;
 static int running, hard_restart;
@@ -295,6 +296,7 @@ main:
     register_module_commands();
     init_handleinfohandler();
     init_tools();
+    init_modulefunctions();
     loadModules();
     init_bots();
     init_DBHelper();
@@ -429,15 +431,24 @@ static AUTHLOOKUP_CALLBACK(main_checkauths_callback) {
     printf_mysql_query("SELECT `user_id`, `user_registered` FROM `users` WHERE `user_user` = '%s'", escape_string(auth));
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) != NULL) {
-        if(!exists || (strcmp(row[1], "0") && registered != atoi(row[1]))) {
+        int diff = registered - atoi(row[1]);
+        if(diff < 0)
+            diff *= -1;
+        if(!exists || (strcmp(row[1], "0") && diff > 86400)) {
             //User is no longer valid! Delete it...
             deleteUser(atoi(row[0]));
             char *alertchan = get_string_field("General.CheckAuths.alertchan");
             if(alertchan) {
+                char reason[MAXLEN];
+                if(!exists) {
+                    strcpy(reason, "USER_NOT_EXISTS");
+                } else {
+                    sprintf(reason, "USER_REGISTERED_MISSMATCH: %lu, expected %d (diff: %d)", (unsigned long) registered, atoi(row[1]), diff);
+                }
                 struct ChanNode *alertchan_chan = getChanByName(alertchan);
                 struct ClientSocket *alertclient;
                 if(alertchan_chan && (alertclient = getChannelBot(alertchan_chan, 0)) != NULL) {
-                    putsock(alertclient, "PRIVMSG %s :Deleted User %s", alertchan_chan->name, auth);
+                    putsock(alertclient, "PRIVMSG %s :Deleted User %s (%s)", alertchan_chan->name, auth, reason);
                 }
             }
         } else if(exists && !strcmp(row[1], "0")) {