/* 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();)
{
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;
// Rehashing, other = newer config
other.serverinfo = this.serverinfo;
- other.database = this.database;
}
public String getChannelNamed(String name)
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;
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());
System.exit(-1);
}
+ acidcore_sql.shutdown();
+
System.exit(0);
}
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");
}
}
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;
}
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());
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
{
this.url = url;
this.username = username;
this.password = password;
- this.referenceCount = 1;
this.connect();
this.start();
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...");
}
}
}
-
- public void increaseReferenceCount()
- {
- this.referenceCount++;
- }
private static long lastWarn = 0;
public static void handleException(final String reason, SQLException ex)
}
}
- 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;
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)
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
[trivia]
nick: Trivia
channel: #a
-
-Subproject commit d6c87c802761008a826b99075879ad2268dd7c55
+Subproject commit 7050ab8708e03a4da9fb17d6e763024b3d1f796d
from plugin import AcidPlugin
-from plugin import modules
+from plugin import modules, getPlugins
from core import *
import time
from istring import istring
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):
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
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
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()
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)
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()
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
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
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()
import cmd_admin, sys_auth, limitmanager
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
class limitserv(
AcidPlugin,
inviteable.InviteablePseudoclient
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()
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)
import time
import threading
from sys_base import *
-import istring
+from istring import istring
class AntiFloodManager(Subsystem):
def __init__(self, module):
import cmd_admin, sys_auth
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
class quotes(
AcidPlugin,
inviteable.InviteablePseudoclient
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()
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)
import cmd_admin, sys_auth, trivia_engine
+import pyva_net_rizon_acid_core_AcidCore as AcidCore
+
class trivia(
AcidPlugin,
inviteable.InviteablePseudoclient
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()
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