Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / event_neonspam_join.c
index 1578a0154ec551d82367749ad631cc7f62288f33..3b31b926f3461818b995fed1eb207af0ab7eeaf3 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
@@ -27,8 +27,14 @@ struct neonspam_event_join_cache {
 };
 
 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;
@@ -62,7 +68,7 @@ static USERAUTH_CALLBACK(neonspam_event_join_nick_lookup) {
 static void neonspam_event_join_punish(struct ClientSocket *client, struct ChanUser *chanuser, struct NeonSpamSettings *settings, int action) {
     int uaccess = 0;
     if(chanuser->user->flags & USERFLAG_ISAUTHED)
-        uaccess = getChannelAccess(chanuser->user, chanuser->chan, 0);
+        uaccess = getChannelAccess(chanuser->user, chanuser->chan);
     if(uaccess >= settings->exceptlevel[SPAMSETTINGS_JOINEXCINDEX]) return;
     //scanops / scanvoiced
     MYSQL_RES *res;
@@ -87,7 +93,7 @@ static void neonspam_event_join_punish(struct ClientSocket *client, struct ChanU
         char banmaskBuf[NICKLEN+USERLEN+HOSTLEN+3];
         char *banmask = NULL;
         switch (atoi((row[0] ? row[0] : defaults[0]))) {
-            case 3: //TIMEBAN: 1h
+            case 2: //TIMEBAN
                 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) {