]> jfr.im git - irc/rizon/acid.git/commitdiff
Merge branch 'master' into culex/acid+stats
authorCuleX <redacted>
Thu, 25 Sep 2014 03:44:55 +0000 (05:44 +0200)
committerCuleX <redacted>
Thu, 25 Sep 2014 03:44:55 +0000 (05:44 +0200)
19 files changed:
acid/src/main/java/net/rizon/acid/commands/Shutdown.java
acid/src/main/java/net/rizon/acid/conf/Config.java
acid/src/main/java/net/rizon/acid/core/Acidictive.java
acid/src/main/java/net/rizon/acid/sql/SQL.java
pyva/config.example.ini
pyva/pyva-native
pyva/pyva/src/main/python/control/control.py
pyva/pyva/src/main/python/ctcp/ctcp.py
pyva/pyva/src/main/python/erepublik/erepublik.py
pyva/pyva/src/main/python/esim/esim.py
pyva/pyva/src/main/python/internets/cmd_user.py
pyva/pyva/src/main/python/internets/internets.py
pyva/pyva/src/main/python/limitserv/limitserv.py
pyva/pyva/src/main/python/moo/requests.py
pyva/pyva/src/main/python/pseudoclient/sys_antiflood.py
pyva/pyva/src/main/python/quotes/quotes.py
pyva/pyva/src/main/python/registration/registration.py
pyva/pyva/src/main/python/trivia/trivia.py
pyva/pyva/src/main/python/trivia/trivia_engine.py

index acc857158495aa1def77c4c45243bf6b3c8274b3..1daba5d4f06a8a6e44312c222b18e03933a1b389 100644 (file)
@@ -37,8 +37,7 @@ public class Shutdown extends Command
                /* Given DB changes are always written when they occur, all we need to
                 * flush are our SQL and socket buffers.
                 */
-               SQL.shutdownAllConnections();
-               
+               Acidictive.acidcore_sql.shutdown();
                
                for (Iterator<String> it = User.getUsers().iterator(); it.hasNext();)
                {
index 082c4ae4bfb13b7f1447a4e098eae7a344dbe524..4b21c6b04dff19075895ba170dd858430c4a3186 100644 (file)
@@ -1,12 +1,12 @@
 package net.rizon.acid.conf;
 
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
+
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.util.List;
 
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
-
 public class Config extends Configuration
 {
        public boolean debug, protocol_debug;
@@ -40,7 +40,6 @@ public class Config extends Configuration
                // Rehashing, other = newer config
                
                other.serverinfo = this.serverinfo;
-               other.database = this.database;
        }
        
        public String getChannelNamed(String name)
index bb07e2d5fa72b4dc38766599d5bbdb6edf797c9f..0e5a7d61a16b16bed2d2f0aa6155b6dd2d382fd2 100644 (file)
@@ -1,5 +1,12 @@
 package net.rizon.acid.core;
 
+import net.rizon.acid.conf.Client;
+import net.rizon.acid.conf.Config;
+import net.rizon.acid.sql.SQL;
+import net.rizon.acid.util.Blowfish;
+import net.rizon.acid.util.ClassLoader;
+import net.rizon.acid.util.Util;
+
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
@@ -15,13 +22,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.logging.Level;
 
-import net.rizon.acid.conf.Client;
-import net.rizon.acid.conf.Config;
-import net.rizon.acid.sql.SQL;
-import net.rizon.acid.util.Blowfish;
-import net.rizon.acid.util.ClassLoader;
-import net.rizon.acid.util.Util;
-
 public class Acidictive extends AcidCore
 {
        private static final Logger log = Logger.getLogger(Acidictive.class.getName());
@@ -99,6 +99,8 @@ public class Acidictive extends AcidCore
                        System.exit(-1);
                }
 
+               acidcore_sql.shutdown();
+
                System.exit(0);
        }
 
@@ -370,7 +372,7 @@ public class Acidictive extends AcidCore
                        if (u instanceof AcidUser)
                        {
                                AcidUser au = (AcidUser) u;
-                               if (au.client.version != null)
+                               if (au.client != null && au.client.version != null)
                                        Acidictive.notice(au.getUID(), creator, "\1VERSION " + au.client.version + "\1");
                        }
                }
@@ -394,7 +396,7 @@ public class Acidictive extends AcidCore
                if (creator.equalsIgnoreCase("nickserv") && msg.matches("^.*registered\\s+and\\s+protected.*$"))
                {
                        AcidUser au = (AcidUser) User.findUser(recipient);
-                       if (au != null && !au.getNSPass().isEmpty())
+                       if (au != null && au.getNSPass() != null && !au.getNSPass().isEmpty())
                                Protocol.privmsg(recipient, creator, "IDENTIFY " + au.getNSPass());
                        return;
                }
index be374eb443361d00fa26f5789a81fb9c8cb9ba7f..701901274f1fecb870c01c00a528bd22cd4f2924 100644 (file)
@@ -1,18 +1,17 @@
 package net.rizon.acid.sql;
 
+import net.rizon.acid.conf.Database;
+import net.rizon.acid.core.Acidictive;
+import net.rizon.acid.core.Logger;
+
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.logging.Level;
 
-import net.rizon.acid.conf.Database;
-import net.rizon.acid.core.Acidictive;
-import net.rizon.acid.core.Logger;
-
 public class SQL extends Thread
 {
        private static final Logger log = Logger.getLogger(SQL.class.getName());
@@ -24,8 +23,6 @@ public class SQL extends Thread
        private long last_connect = 0;
        private volatile Object queryLock = new Object();
        private volatile LinkedList<PreparedStatement> pendingQueries = new LinkedList<PreparedStatement>();
-       private static final HashMap<String, SQL> connections = new HashMap<String, SQL>();
-       private int referenceCount;
 
        public SQL(final String url, final String username, final String password) throws ClassNotFoundException, SQLException
        {
@@ -34,7 +31,6 @@ public class SQL extends Thread
                this.url = url;
                this.username = username;
                this.password = password;
-               this.referenceCount = 1;
 
                this.connect();
                this.start();
@@ -53,10 +49,6 @@ public class SQL extends Thread
 
        public void shutdown()
        {
-               if (--this.referenceCount > 0)
-                       /* Another plugin still needs the connection here */
-                       return;
-               
                this.shuttingDown = true;
 
                log.log(Level.INFO, "Flushing pending SQL queries...");
@@ -211,11 +203,6 @@ public class SQL extends Thread
                        }
                }
        }
-       
-       public void increaseReferenceCount()
-       {
-               this.referenceCount++;
-       }
 
        private static long lastWarn = 0;
        public static void handleException(final String reason, SQLException ex)
@@ -228,14 +215,6 @@ public class SQL extends Thread
                }
        }
        
-       public static void shutdownAllConnections()
-       {
-               for (final SQL conn : SQL.connections.values())
-                       conn.shutdown();
-               
-               SQL.connections.clear();
-       }
-       
        public static SQL getConnection(final String name)
        {
                SQL sql = null;
@@ -247,15 +226,7 @@ public class SQL extends Thread
                                if (!d.name.equals(name))
                                        continue;
                                
-                               if (SQL.connections.containsKey(name))
-                               {
-                                       sql = SQL.connections.get(name);
-                                       sql.increaseReferenceCount();
-                                       return sql;
-                               }
-                               
-                               sql = new SQL(d.host, d.user, d.pass);
-                               SQL.connections.put(d.name, sql);
+                               return sql = new SQL(d.host, d.user, d.pass);
                        }
                }
                catch (ClassNotFoundException ex)
index 52465f918057bd2dc801c45bce5747d833f12d81..9a78f037043ee09c9a06a448e2e6fc4f901a6699 100644 (file)
@@ -30,18 +30,18 @@ sock: /var/lib/mysql/mysql.sock
 nick: py-ctcp
 
 [vhost]
-channel: #v
-logchan: #debug
+channel: #vhost
+logchan: #services
 nick: py-moo
 
 [registration]
 nick: Welcome
-reg1:Hi, I am a Rizon Help Bot! If this is your first channel, welcome! If not, you can ignore me.
-reg2:Rizon Services have many settings, you should complete the following Rizon University courses:
-reg3:Channel Management 101 - http://tr.im/rizon101
-reg4:Channel Management 102 - http://tr.im/rizon102
-reg5:Adv Channel Modes  300 - http://tr.im/rizon300
-reg6:After reading these, you should be all set, but feel free to join #help if you get stuck. Thanks for flying Rizon!
+text: Hi, I am a Rizon Help Bot! If this is your first channel, welcome! If not, you can ignore me.
+      Rizon Services have many settings, you should complete the following Rizon University courses:
+      Channel Management 101 - http://s.rizon.net/chan101
+      Channel Management 102 - http://s.rizon.net/chan102
+      Adv Channel Modes  300 - http://s.rizon.net/chan300
+      After reading these, you should be all set, but feel free to join #help if you get stuck. Thanks for flying Rizon!
 
 [listbots]
 nick: FunServ
@@ -78,4 +78,3 @@ channel: #a
 [trivia]
 nick: Trivia
 channel: #a
-
index d6c87c802761008a826b99075879ad2268dd7c55..7050ab8708e03a4da9fb17d6e763024b3d1f796d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit d6c87c802761008a826b99075879ad2268dd7c55
+Subproject commit 7050ab8708e03a4da9fb17d6e763024b3d1f796d
index dccb5410bdd4df687088992023a968358cb524d0..9b3a47e9e30a087d29911a09ecf1f70dee0d11e0 100644 (file)
@@ -1,5 +1,5 @@
 from plugin import AcidPlugin
-from plugin import modules
+from plugin import modules, getPlugins
 from core import *
 import time
 from istring import istring
@@ -20,7 +20,7 @@ class control(AcidPlugin):
                        las = ["unk", "unk", "unk"]
 
                self.inter.privmsg(self.control, target, "Load: [%s %s %s]" % (las[0], las[1], las[2]))
-               self.inter.privmsg(self.control, target, "Modules loaded: %s" % (", ".join(self.get_module_list())))
+               self.inter.privmsg(self.control, target, "Modules loaded: %s" % (", ".join(getPlugins())))
                return True
 
        def cmd_help(self, source, target, pieces):
index 63fbd29f1de1c40b823c7bc7d798e6a5c49f3957..98e5a2bfdc84e97722f0d66a17c429d61383df16 100644 (file)
@@ -110,14 +110,17 @@ class ctcp(AcidPlugin):
                        return # Can this throw?
 
                #ctcp website reply
-               if reply.lower().startswith(u"website"):
-                       reply = reply[8:]
-                       try:
-                               self.dbp.execute(u"INSERT INTO ctcp_website (reply, found) VALUES(%s, 1) ON DUPLICATE KEY UPDATE found=found+1;", (reply,))
-                       except Exception, err:
-                               self.log.exception(u"Error updating ctcp_website: %s (%s)" % (reply, err))
-                       user['website'] = reply
-                       return
+               try:
+                       if reply.lower().startswith(u"website"):
+                               reply = reply[8:]
+                               try:
+                                       self.dbp.execute(u"INSERT INTO ctcp_website (reply, found) VALUES(%s, 1) ON DUPLICATE KEY UPDATE found=found+1;", (reply,))
+                               except Exception, err:
+                                       self.log.exception(u"Error updating ctcp_website: %s (%s)" % (reply, err))
+                               user['website'] = reply
+                               return
+               except:
+                       return # XXX
 
                #ctcp version reply
                if not reply.lower().startswith(u"version"): return
index 4271aed1883aa77299975de1cd27a62e459a593b..cdedab501fa70426b103152abe6d6202c2fc0a65 100644 (file)
@@ -25,6 +25,8 @@ import sys_auth, sys_news, erepparser
 from erepublik_utils import *
 from api import citizen, company, country, feed, region
 
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
 class erepublik(AcidPlugin):
        initialized = False
 
@@ -92,10 +94,11 @@ class erepublik(AcidPlugin):
 
                self.elog.debug('Started subsystems.')
 
-               for channel in self.channels.list_valid():
-                       self.join(channel.name)
+               if not AcidCore.me.isBursting():
+                       for channel in self.channels.list_valid():
+                               self.join(channel.name)
 
-               self.log.debug('Joined channels.')
+                       self.log.debug('Joined channels.')
 
                try:
                        self.start_threads()
index d794928694f0612936dcfbd147ab1de7d6f9d216..208e5cb9cb30f39e64310ed966b08a78c1b128b9 100644 (file)
@@ -24,6 +24,8 @@ from plugin import *
 from api import citizen, region, feed
 import cmd_admin, cmd_private, cmd_user, esimparser, sys_auth, esim_users, esim_channels
 
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
 class esim(AcidPlugin):
        def bind_function(self, function):
                func = types.MethodType(function, self, esim)
@@ -89,10 +91,11 @@ class esim(AcidPlugin):
 
                self.elog.debug('Started subsystems.')
 
-               for channel in self.channels.list_valid():
-                       self.join(channel.name)
+               if not AcidCore.me.isBursting():
+                       for channel in self.channels.list_valid():
+                               self.join(channel.name)
 
-               self.log.debug('Joined channels.')
+                       self.log.debug('Joined channels.')
 
                try:
                        self.start_threads()
index 156aafd5ba68ff445b55f4cb8b1921064f8648e4..748ac563f816a8b3481be2649e0f7a78cfdb64a1 100644 (file)
@@ -172,7 +172,9 @@ def command_google_search(self, manager, opts, arg, channel, sender, userinfo):
        self.msg(channel, '[Google] @b%(title)s@b <@u%(url)s@u>' % {
                                        'title': unescape(json['titleNoFormatting']), 
                                        'url': json['unescapedUrl']})
-       self.msg(channel, '[Google] @bDescription@b: %s' % unescape(json['content']).replace('<b>', '@b').replace('</b>', '@b'))
+
+       if json['content'] != '':
+               self.msg(channel, '[Google] @bDescription@b: %s' % unescape(json['content']).replace('<b>', '@b').replace('</b>', '@b'))
 
 def command_calc(self, manager, opts, arg, channel, sender, userinfo):
        try:  # local calculation using PyParsing
index d2e7f31100a225c9d91f8f1d0158abdfcc77a91e..147fc32d77ccaf5f448601018717f7d7d40fab13 100644 (file)
@@ -23,6 +23,8 @@ import cmd_admin, cmd_user, erepparser, internets_users
 from api import bing, calc, google, imdb, ipinfo, lastfm, quotes, urbandictionary, urls, weather, wolfram, words
 from internets_utils import *
 
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
 class internets(
        AcidPlugin,
        inviteable.InviteablePseudoclient
@@ -121,10 +123,11 @@ class internets(
                        self.log.exception('Error initializing internets module (%s)' % err)
                        raise
 
-               for channel in self.channels.list_valid():
-                       self.join(channel.name)
+               if not AcidCore.me.isBursting():
+                       for channel in self.channels.list_valid():
+                               self.join(channel.name)
 
-               self.log.debug('Joined channels.')
+                       self.log.debug('Joined channels.')
 
                try:
                        self.start_threads()
index f47c5aa84895e421eb574d41e0eba905c1dfbb70..7bad1b41e95827d3dc8bbcb828e4630b95a9bcc6 100644 (file)
@@ -16,6 +16,8 @@ from plugin import *
 
 import cmd_admin, sys_auth, limitmanager
 
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
 class limitserv(
        AcidPlugin,
        inviteable.InviteablePseudoclient
@@ -81,11 +83,12 @@ class limitserv(
                except Exception, err:
                        self.log.exception('Error initializing subsystems for limitserv module (%s)' % err)
                        raise
-                       
-               for channel in self.channels.list_valid():
-                       self.join(channel.name)
 
-               self.elog.debug('Joined channels.')
+               if not AcidCore.me.isBursting():
+                       for channel in self.channels.list_valid():
+                               self.join(channel.name)
+
+                       self.elog.debug('Joined channels.')
                
                try:
                        self.start_threads()
index 5624c7846da6e208dcd0632c07a8ba8099306f1a..eead77638da233733a6bfecd954ed32ed3dc74d5 100644 (file)
@@ -358,6 +358,8 @@ class RequestManager(object):
        def __is_resolvable(self, host):
                try:
                        res = getaddrinfo(host, 80)
+                       if res[0][4][0] == '127.0.53.53': # https://www.icann.org/news/announcement-2-2014-08-01-en
+                               return (False, None, None)
                        return (True, res[0][4][0], host)
                except gaierror, e:
                        return (False, None, None)
index 90075ff69a632a10936fb2dc3a352b64d5c7997d..a3198c980b531c5da8bb0c927e34d41bab4407be 100644 (file)
@@ -1,7 +1,7 @@
 import time
 import threading
 from sys_base import *
-import istring
+from istring import istring
 
 class AntiFloodManager(Subsystem):
        def __init__(self, module):
index ea622ffc00a49fb62a32b0bfb7b38fe326ea116e..8ef2cc04585be02aa817e11b92cdfcf23f96761e 100644 (file)
@@ -16,6 +16,8 @@ from plugin import *
 
 import cmd_admin, sys_auth
 
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
 class quotes(
        AcidPlugin,
        inviteable.InviteablePseudoclient
@@ -79,11 +81,12 @@ class quotes(
                except Exception, err:
                        self.log.exception('Error initializing subsystems for quotes module (%s)' % err)
                        raise
-                       
-               for channel in self.channels.list_valid():
-                       self.join(channel.name)
 
-               self.elog.debug('Joined channels.')
+               if not AcidCore.me.isBursting():
+                       for channel in self.channels.list_valid():
+                               self.join(channel.name)
+
+                       self.elog.debug('Joined channels.')
                
                try:
                        self.start_threads()
index 691527b6ce7dc6392056032fd708e115bed32fff..239215e604d83d7a3524fb0dff14ff96a27ed4b3 100644 (file)
@@ -36,14 +36,8 @@ class registration(AcidPlugin):
                
                me.joinChan(chan)
                
-               
-               #s XXX lol?
-               self.inter.privmsg(self.client, chan, self.config.get('registration', 'reg1'))
-               self.inter.privmsg(self.client, chan, self.config.get('registration', 'reg2'))
-               self.inter.privmsg(self.client, chan, self.config.get('registration', 'reg3'))
-               self.inter.privmsg(self.client, chan, self.config.get('registration', 'reg4'))
-               self.inter.privmsg(self.client, chan, self.config.get('registration', 'reg5'))
-               self.inter.privmsg(self.client, chan, self.config.get('registration', 'reg6'))
+               for line in self.config.get('registration', 'text').split('\n'):
+                       self.inter.privmsg(self.client, chan, line) #line.strip()
 
                #logging fun
                self.inter.privmsg(self.client, self.logchan, "registration info sent to %s" % chan)
index ab316ec8a3262829e72dd2c2b1b4d49412eecf48..f59f6ee928fc5e599632f71c25a7bedd5b632456 100644 (file)
@@ -19,6 +19,8 @@ from plugin import *
 
 import cmd_admin, sys_auth, trivia_engine
 
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
 class trivia(
        AcidPlugin,
        inviteable.InviteablePseudoclient
@@ -99,11 +101,12 @@ class trivia(
                except Exception, err:
                        self.log.exception('Error initializing subsystems for trivia module (%s)' % err)
                        raise
-                       
-               for channel in self.channels.list_valid():
-                       self.join(channel.name)
 
-               self.elog.debug('Joined channels.')
+               if not AcidCore.me.isBursting():
+                       for channel in self.channels.list_valid():
+                               self.join(channel.name)
+
+                       self.elog.debug('Joined channels.')
                
                try:
                        self.start_threads()
index 901ddba4137f539e25979ca44f2560a242049424..47e2c238bd72d78f8745d8e32e3e7edb31263cb1 100644 (file)
@@ -161,9 +161,12 @@ class Trivia(object):
 
                found = False
                for a in self.answer:
-                       if a.lower() in answer.lower():
-                               found = True
-                               break
+                       try:
+                               if a.lower() in answer.lower():
+                                       found = True
+                                       break
+                       except:
+                               pass # XXX unicode
 
                if not found:
                        return