fixes for multi thread support
[NeonServV5.git] / src / event_neonspam_join.c
index a192d792c284154c3a74be5d51c971c2f8fd1a70..5a169f207487c0c702e3752363704a14da9750d4 100644 (file)
@@ -1,5 +1,5 @@
-/* event_neonspam_join.c - NeonServ v5.2
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* event_neonspam_join.c - NeonServ v5.3
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -30,6 +30,11 @@ static void neonspam_event_join(struct ChanUser *chanuser) {
     if(chanuser->user->flags & USERFLAG_WAS_REGISTRING) return;
     struct ClientSocket *client = getChannelBot(chanuser->chan, BOTID);
     if(!client) return; //we can't "see" this event
+    if(chanuser->user == client->user) {
+        requestOp(client->user, chanuser->chan);
+        return;
+    }
+    if(chanuser->user->flags & USERFLAG_ISBOT) return;
     loadNeonSpamSettings(chanuser->chan);
     struct NeonSpamSettings *settings = chanuser->chan->spam_settings;
     if(!settings || !(settings->flags & SPAMSETTINGS_JOINSCAN)) return;
@@ -92,7 +97,7 @@ static void neonspam_event_join_punish(struct ClientSocket *client, struct ChanU
                 banmask = generate_banmask(chanuser->user, banmaskBuf);
                 printf_mysql_query("INSERT INTO `bans` (`ban_channel`, `ban_mask`, `ban_triggered`, `ban_timeout`, `ban_owner`, `ban_reason`) VALUES ('%d', '%s', UNIX_TIMESTAMP(), '%lu', '%d', '%s')", chanuser->chan->channel_id, escape_string(banmask), (unsigned long) (duration ? (time(0) + duration) : 0), 0, escape_string(reason));
                 if(duration) {
-                    int banid = (int) mysql_insert_id(mysql_conn);
+                    int banid = (int) mysql_insert_id(get_mysql_conn());
                     char nameBuf[MAXLEN];
                     char banidBuf[20];
                     sprintf(nameBuf, "ban_%d", banid);