Exemple #1
0
        def __init__(self):
            self.db = QSqlDatabase.addDatabase("QSQLITE", "__pyTSon_config__")
            self.db.setDatabaseName(os.path.join(ts3lib.getConfigPath(),
                                                 "settings.db"))

            if not self.db.isValid():
                raise Exception("Database not valid")

            if not self.db.open():
                raise Exception("Database could not be opened")
    def __init__(self):           

        # --------------------------------------------
        # Database
        # --------------------------------------------

        # Database connect for plugin main.db
        self.db = QSqlDatabase.addDatabase("QSQLITE", "pyTSon_contactmanager")
        self.db.setDatabaseName(path.join(self.directory, "main.db"))

        if not self.db.isValid(): raise Exception("Database main.db is invalid")
        if not self.db.open(): raise Exception("Could not open Database main.db")

        # Database connect for internal teamspeak settings.db
        self.db_c = QSqlDatabase.addDatabase("QSQLITE","pyTSon_contacts")
        self.db_c.setDatabaseName(ts3.getConfigPath() + "settings.db")

        if not self.db_c.isValid(): raise Exception("Database settings.db is invalid")
        if not self.db_c.open(): raise Exception("Could not open Database settings.db")

        # --------------------------------------------
        # Load General Settings
        # --------------------------------------------
        
        s = self.db.exec_("SELECT * FROM settings LIMIT 1")
        if not self.db.lastError().isValid():
            if s.next():
                self.settings["f_channelgroup"]     = bool(s.value("db_f_channelgroup"))
                self.settings["f_talkpower"]        = bool(s.value("db_f_talkpower"))
                self.settings["f_message"]          = bool(s.value("db_f_message"))
                self.settings["f_message_message"]  = s.value("db_f_message_message")
                self.settings["b_channelgroup"]     = bool(s.value("db_b_channelgroup"))
                self.settings["b_kick"]             = bool(s.value("db_b_kick"))
                self.settings["b_kick_message"]     = s.value("db_b_kick_message")
                self.settings["b_message"]          = bool(s.value("db_b_message"))
                self.settings["b_message_message"]  = s.value("db_b_message_message")
Exemple #3
0
 def __init__(self):
     self.db = QSqlDatabase.addDatabase("QSQLITE", "pyTSon_linkinfo")
     self.db.setDatabaseName(path.join(self.directory, "linkinfo.db"))
     if not self.db.isValid():
         raise Exception("Database invalid")
     if not self.db.open():
         raise Exception("Could not open database.")
     d = self.db.exec_("SELECT * FROM domains ORDER BY domain ASC")
     while d.next():
         self.domains.append(str(d.value("domain")))
     p = self.db.exec_("SELECT * FROM protocols ORDER BY protocol ASC")
     while p.next():
         self.protocols.append(str(p.value("protocol")))
     s = self.db.exec_("SELECT * FROM settings")
     if s.next():
         self.status = bool(s.value("status"))
         self.mode = bool(s.value("mode"))
     self.dlg = None
Exemple #4
0
 def __init__(self):
     if path.isfile(self.ini): self.cfg.read(self.ini)
     else:
         self.cfg['general'] = {"cfgversion": "1", "debug": "False", "enabled": "True"}
         self.cfg['autoban'] = {"enabled": "True"}
         self.cfg['automod'] = {"enabled": "True", "autotp": "True"}
         self.cfg['antirecord'] = {"enabled": "True"}
         self.cfg['autokickonban'] = {"enabled": "True"}
         self.cfg['groups'] = {"banned": ["BAN", "NOT WELCOME"], "mod": ["MOD", "OPERATOR"], "admin": ["ADMIN"]}
         with open(self.ini, 'w') as configfile: self.cfg.write(configfile)
     self.db = QSqlDatabase.addDatabase("QSQLITE","channelWatcher")
     self.db.setDatabaseName(ts3lib.getConfigPath() + "settings.db")
     if self.db.isValid(): self.db.open()
     schid = ts3lib.getCurrentschid()
     if schid:
         self.requested = True
         ts3lib.requestChannelGroupList(schid)
         (error, ownID) = ts3lib.getClientID(schid)
         (error, cid) = ts3lib.getChannelOfClient(schid, ownID)
         self.ownchannels.extend([cid])
     if self.debug: ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(self.timestamp(),self.name,self.author))
Exemple #5
0
 def stop(self):
     self.db.close();self.db.delete()
     QSqlDatabase.removeDatabase("channelWatcher")
Exemple #6
0
 def stop(self):
     self.db.close()
     self.db.delete()
     QSqlDatabase.removeDatabase(self.__class__.__name__)
Exemple #7
0
 def __del__(self):
     self.db.close()
     self.db.delete()
     QSqlDatabase.removeDatabase("__pyTSon_config__")
Exemple #8
0
 def stop(self):
     self.db.close()
     self.db.delete()
     QSqlDatabase.removeDatabase("pyTSon_linkinfo")
Exemple #9
0
 def __del__(self):
     self.db.close()
     self.db.delete()
     QSqlDatabase.removeDatabase("__pyTSon_config__")