Esempio n. 1
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("sqlite")
        if len(serviceProviders) == 0:
            self.log.error(
                "Tell: Could not find a valid sqlite service provider")
        else:
            self.log.info("Tell: Selecting sqlite service provider: %s" %
                          serviceProviders[0])
            self.db = serviceProviders[0].opendb("tell.db")

        if not self.db.tableExists("tells"):
            self.log.info("Remind: Creating table: tells")
            self.db.query("""CREATE TABLE IF NOT EXISTS `tells` (
            `id` INTEGER PRIMARY KEY,
            `sender` varchar(64),
            `channel` varchar(64),
            `when` INTEGER,
            `recip` varchar(64),
            `message` varchar(2048)
            ) ;""").close()

        # Purge expired tells
        self.db.query("DELETE FROM `tells` WHERE `when`<?",
                      (int(mktime(datetime.datetime.now().timetuple())) -
                       self.config["maxage"], )).close()
Esempio n. 2
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("sqlite")
        if not serviceProviders:
            self.log.error(
                "Remind: Could not find a valid sqlite service provider")
        else:
            self.log.info("Remind: Selecting sqlite service provider: %s" %
                          serviceProviders[0])
            self.db = serviceProviders[0].opendb("remind.db")

        if not self.db.tableExists("reminders"):
            self.log.info("Remind: Creating table: reminders")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `reminders` (
            `id` INTEGER PRIMARY KEY,
            `sender` varchar(64),
            `senderch` varchar(64),
            `when` timestamp,
            `message` varchar(2048)
            ) ;""")
            c.close()

        self.disabled = False

        # Start monitor thread
        self.t = Thread(target=self.monitor_thread)
        self.t.daemon = True
        self.t.start()
Esempio n. 3
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.host, self.port = self.config.get("servers")[0].split(":")
     self.bus = None
     self.bus_listener_thread = Thread(target=self.bus_listener)
     self.bus_listener_thread.daemon = True
     self.bus_listener_thread.start()
Esempio n. 4
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("sqlite")
        if not serviceProviders:
            self.log.error("Remind: Could not find a valid sqlite service provider")
        else:
            self.log.info("Remind: Selecting sqlite service provider: %s" % serviceProviders[0])
            self.db = serviceProviders[0].opendb("remind.db")

        if not self.db.tableExists("reminders"):
            self.log.info("Remind: Creating table: reminders")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `reminders` (
            `id` INTEGER PRIMARY KEY,
            `sender` varchar(64),
            `senderch` varchar(64),
            `when` timestamp,
            `message` varchar(2048)
            ) ;""")
            c.close()

        self.hooks = [ModuleHook("PRIVMSG", self.remindin),
                      ModuleHook("PRIVMSG", self.remindat)]

        self.disabled = False

        # Start monitor thread
        self.t = Thread(target=self.monitor_thread)
        self.t.daemon = True
        self.t.start()
Esempio n. 5
0
    def __init__(self, bot, moduleName):
        # init the base module
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = [ModuleHook("PRIVMSG", self.scramble)]

        # Dictionary
        self.wordsCount = 0
        self.wordsFile = self.getFilePath("words.txt")
        print(self.wordsFile)
        wordsF = open(self.wordsFile, "r")
        while True:
            word = wordsF.readline()
            if not word:
                break
            self.wordsCount += 1
        wordsF.close
        self.log.info("Scramble: Loaded %s words" % str(self.wordsCount))
        # Load scores
        self.scoresFile = self.getFilePath("scores.json")
        if not os.path.exists(self.scoresFile):
            json.dump({}, open(self.scoresFile, 'w'))
        self.scores = json.load(open(self.scoresFile, 'r'))
        # Per channel games
        self.games = {}
        # Hook in
        self.hooks = [ModuleHook("PRIVMSG", self.scramble)]
Esempio n. 6
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.gotmsg)]
     # Load attribute storage
     self.attr = self.bot.getBestModuleForService("attributes")
     # Load doge RPC
     self.doge = self.bot.getBestModuleForService("dogerpc")
Esempio n. 7
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks.append(ModuleHook("PRIVMSG", self.handleMessage))
     self.prefixes = [person for person in self.config["people"]]
     self.bot = bot
     self.timer = None
     self.setupTimer()
Esempio n. 8
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks.append(ModuleHook("PRIVMSG", self.handleMessage))
     self.prefixes = [person for person in self.config["people"]]
     self.bot = bot
     self.timer = None
     self.setupTimer()
Esempio n. 9
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [
         ModuleHook("PRIVMSG", self.got_msg),
         ModuleHook("JOIN", self.join_ch)
     ]
     self.loadConfig()
     self.games = {}
Esempio n. 10
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("_CONNECT", self.doConnect),
                   ModuleHook("433", self.nickTaken),
                   ModuleHook("001", self.initservices),
                   ModuleHook("INVITE", self.invited), ]
     self.current_nick = 0
     self.do_ghost = False
Esempio n. 11
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.timer = PingRespondTimer(self)
     self.hooks = [
         ModuleHook("PING", self.pingrespond),
         ModuleHook("_RECV", self.resettimer),
         ModuleHook("_SEND", self.resettimer)
     ]
Esempio n. 12
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.cache = None
        self.cacheAge = 0

        self.hooks = [
            ModuleHook(["PRIVMSG"], self.btc)
        ]
Esempio n. 13
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.host, self.port = self.config.get("servers")[0].split(":")
     self.bus = None
     self.services = (self.bot.getmodulesbyservice("services")
                      or [None]).pop(0)
     self.bus_listener_thread = Thread(target=self.bus_listener)
     self.bus_listener_thread.daemon = True
     self.bus_listener_thread.start()
Esempio n. 14
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.gotMsg)]
     # Load attribute storage
     self.attr = self.bot.getBestModuleForService("attributes")
     # Load doge RPC
     self.doge = self.bot.getBestModuleForService("dogerpc")
     # Dict of #channel -> game object
     self.games = {}
Esempio n. 15
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.gotMsg)]
     # Load attribute storage
     self.attr = self.bot.getBestModuleForService("attributes")
     # Load doge RPC
     self.doge = self.bot.getBestModuleForService("dogerpc")
     # Dict of #channel -> game object
     self.games = {}
Esempio n. 16
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.hooks = [ModuleHook("PRIVMSG", self.calc)]
        self.timers = {}

        self.sqlite = self.bot.getBestModuleForService("sqlite")
        if self.sqlite is None:
            self.log.error("Calc: SQLIite service is required.")
            return

        self.sql = self.sqlite.opendb("calc.db")

        if not self.sql.tableExists("calc_addedby"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_addedby` (
                  `id` INTEGER PRIMARY KEY,
                  `username` varchar(32),
                  `userhost` varchar(128)
                ) ;
            """)
            c.close()
        if not self.sql.tableExists("calc_channels"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_channels` (
                  `id` INTEGER PRIMARY KEY,
                  `channel` varchar(32)
                ) ;
            """)
        if not self.sql.tableExists("calc_definitions"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_definitions` (
                  `id` INTEGER PRIMARY KEY,
                  `word` INTEGET,
                  `definition` varchar(512),
                  `addedby` INTEGER,
                  `date` timestamp,
                  `status` varchar(16)
                ) ;
            """)
        if not self.sql.tableExists("calc_words"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_words` (
                  `id` INTEGER PRIMARY KEY,
                  `channel` INTEGER,
                  `word` varchar(512),
                  `status` varchar(32),
                  unique(`channel`,`word`)
                );
            """)
            c.close()
Esempio n. 17
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.timers = {}

        self.sqlite = self.bot.getBestModuleForService("sqlite")
        if self.sqlite is None:
            raise MissingDependancyException(
                "Calc: SQLIite service is required.")

        self.sql = self.sqlite.opendb("calc.db")

        if not self.sql.tableExists("calc_addedby"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_addedby` (
                  `id` INTEGER PRIMARY KEY,
                  `username` varchar(32),
                  `userhost` varchar(128)
                ) ;
            """)
            c.close()
        if not self.sql.tableExists("calc_channels"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_channels` (
                  `id` INTEGER PRIMARY KEY,
                  `channel` varchar(32)
                ) ;
            """)
        if not self.sql.tableExists("calc_definitions"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_definitions` (
                  `id` INTEGER PRIMARY KEY,
                  `word` INTEGET,
                  `definition` varchar(512),
                  `addedby` INTEGER,
                  `date` timestamp,
                  `status` varchar(16)
                ) ;
            """)
        if not self.sql.tableExists("calc_words"):
            c = self.sql.getCursor()
            c.execute("""
                CREATE TABLE `calc_words` (
                  `id` INTEGER PRIMARY KEY,
                  `channel` INTEGER,
                  `word` varchar(512),
                  `status` varchar(32),
                  unique(`channel`,`word`)
                );
            """)
            c.close()
Esempio n. 18
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.jsonPath = self.getFilePath("scores.json")

        self.timer = None
        self.isDuckOut = False
        self.outStart = 0
        self.misses = {}

        self.startHunt()
Esempio n. 19
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = [ModuleHook("PRIVMSG", self.hunt)]

        self.jsonPath = self.getFilePath("scores.json")

        self.timer = None
        self.isDuckOut = False
        self.outStart = 0
        self.misses = {}

        self.startHunt()
Esempio n. 20
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.lastSeen)]
     # if the database doesnt exist, it will be created
     sql = self.getSql()
     c = sql.cursor()
     # check if our table exists
     c.execute("SELECT * FROM SQLITE_MASTER WHERE `type`='table' AND `name`='seen'")
     if len(c.fetchall()) == 0:
         self.log.info("Seen: Creating database")
         # if no, create it.
         c.execute("CREATE TABLE `seen` (`nick` VARCHAR(32), `date` INTEGER, PRIMARY KEY(`nick`))")
     self.x = "asdf"
Esempio n. 21
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.servicesModule = self.bot.getmodulebyname("Services")
     self.current_card = None
     self.shouldgo = False
     self.has_drawn = False
     self.has_joined = False
     self.games_played = 0
     self.strategies = {
         "play_high_value": self.play_high_value,
         "play_by_chains": self.play_by_chains
     }
     assert self.config["strategy"] in self.strategies
     self.cards = []
Esempio n. 22
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.apithread = None
        self.twilio = Client(self.config["account_sid"], self.config["auth_token"])

        # limit-related vars
        # How many messages can be bursted
        self.bucket_max = int(self.config["limit"]["max"])
        # burst bucket, initial value is 1 or half the max, whichever is more
        self.bucket = max(1, self.bucket_max / 2)
        # how often the bucket has 1 item added
        self.bucket_period = int(self.config["limit"]["period"])
        # last time the burst bucket was filled
        self.bucket_lastfill = int(time())
Esempio n. 23
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.servicesModule = self.bot.getmodulebyname("Services")
     self.hooks = [ModuleHook("PRIVMSG", self.unoplay),
                   ModuleHook("PRIVMSG", self.trigger),
                   ModuleHook("NOTICE", self.decklisten)]
     self.current_card = None
     self.shouldgo = False
     self.has_drawn = False
     self.has_joined = False
     self.games_played = 0
     self.strategies = {"play_high_value": self.play_high_value,
                        "play_by_chains": self.play_by_chains}
     assert self.config["strategy"] in self.strategies
     self.cards = []
Esempio n. 24
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     # if the database doesnt exist, it will be created
     sql = self.getSql()
     c = sql.cursor()
     # check if our table exists
     c.execute(
         "SELECT * FROM SQLITE_MASTER WHERE `type`='table' AND `name`='seen'"
     )
     if len(c.fetchall()) == 0:
         self.log.info("Seen: Creating database")
         # if no, create it.
         c.execute(
             "CREATE TABLE `seen` (`nick` VARCHAR(32), `date` INTEGER, PRIMARY KEY(`nick`))"
         )
Esempio n. 25
0
    def __init__(self, bot, moduleName):
        # init the base module
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = [ModuleHook("PRIVMSG", self.scramble)]

        # Dictionary
        self.whitesFile = open(self.getFilePath("answers.txt"), 'r')
        self.blacksFile = open(self.getFilePath("questions.txt"), 'r')
        self.whites = [line.rstrip() for line in self.whitesFile]
        self.blacks = [line.rstrip() for line in self.blacksFile]
        self.currentBlack = ""
        self.whitesFile.close()
        self.blacksFile.close()
        self.log.info("CAH: Loaded." + str(len(self.whites)) + " White Cards " + str(len(self.blacks)) + " Black Cards")
        # Per channel games
        self.games = {}
Esempio n. 26
0
    def __init__(self, bot, moduleName):
        # init the base module
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = [ModuleHook("PRIVMSG", self.scramble)]

        # Dictionary
        self.whitesFile = open(self.getFilePath("answers.txt"), 'r')
        self.blacksFile = open(self.getFilePath("questions.txt"), 'r')
        self.whites = [line.rstrip() for line in self.whitesFile]
        self.blacks = [line.rstrip() for line in self.blacksFile]
        self.currentBlack = ""
        self.whitesFile.close()
        self.blacksFile.close()
        self.log.info("CAH: Loaded." + str(len(self.whites)) +
                      " White Cards " + str(len(self.blacks)) + " Black Cards")
        # Per channel games
        self.games = {}
Esempio n. 27
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.services = ["attributes"]
        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("mysql")
        if len(serviceProviders) == 0:
            self.log.error(
                "AttributeStorage: Could not find a valid mysql service provider"
            )
        else:
            self.log.info(
                "AttributeStorage: Selecting mysql service provider: %s" %
                serviceProviders[0])
            self.db = serviceProviders[0]

        if not self.db.connection.tableExists("attribute"):
            self.log.info("AttributeStorage: Creating table: attribute")
            c = self.db.connection.query(
                """CREATE TABLE IF NOT EXISTS `attribute` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `attribute` varchar(128) NOT NULL,
            PRIMARY KEY (`id`),
            UNIQUE KEY `attribute` (`attribute`)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;""")
            c.close()

        if not self.db.connection.tableExists("items"):
            self.log.info("AttributeStorage: Creating table: items")
            c = self.db.connection.query(
                """CREATE TABLE IF NOT EXISTS `items` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `item` varchar(512) CHARACTER SET utf8 NOT NULL,
            PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;""")
            c.close()

        if not self.db.connection.tableExists("values"):
            self.log.info("AttributeStorage: Creating table: values")
            c = self.db.connection.query(
                """CREATE TABLE IF NOT EXISTS `values` (
            `itemid` int(11) NOT NULL,
            `attributeid` int(11) NOT NULL,
            `value` varchar(512) CHARACTER SET utf8 NOT NULL,
            PRIMARY KEY (`itemid`,`attributeid`)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;""")
            c.close()
Esempio n. 28
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = [ModuleHook("PRIVMSG", self.scramble)]
        # Load attribute storage
        self.attr = None
        serviceProviders = self.bot.getmodulesbyservice("attributes")
        if len(serviceProviders) == 0:
            self.log.error("DogeScramble: Could not find a valid attributes service provider")
        else:
            self.log.info("DogeScramble: Selecting attributes service provider: %s" % serviceProviders[0])
            self.attr = serviceProviders[0]

        # Load doge RPC
        self.doge = self.bot.getBestModuleForService("dogerpc")

        # Per channel games
        self.games = {}
Esempio n. 29
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        assert "get an API key" not in self.config["apikey"]

        self.login = self.bot.getBestModuleForService("login")
        try:
            assert self.login is not None
        except AssertionError as _ae:
            self.log.error("Weather: A 'login' service is required")
            return

        self.attr = self.bot.getBestModuleForService("attributes")
        try:
            assert self.attr is not None
        except AssertionError as _ae:  # NOQA
            self.log.error("Weather: An 'attributes' service is required")
            return
Esempio n. 30
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        assert "get an API key" not in self.config["apikey"]

        self.login = self.bot.getBestModuleForService("login")
        try:
            assert self.login is not None
        except AssertionError as _ae:
            self.log.error("Weather: A 'login' service is required")
            return

        self.attr = self.bot.getBestModuleForService("attributes")
        try:
            assert self.attr is not None
        except AssertionError as _ae:  # NOQA
            self.log.error("Weather: An 'attributes' service is required")
            return

        self.hooks = [ModuleHook("PRIVMSG", self.weather)]
Esempio n. 31
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("sqlite")
        if not serviceProviders:
            self.log.error(
                "Inventory: Could not find a valid sqlite service provider")
        else:
            self.log.info("Inventory: Selecting sqlite service provider: %s" %
                          serviceProviders[0])
            self.db = serviceProviders[0].opendb("inventory.db")

        if not self.db.tableExists("inventory"):
            self.log.info("Inventory: Creating table: inventory")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `inventory` (
            `id` INTEGER PRIMARY KEY,
            `date` INTEGER,
            `donor` varchar(64),
            `item` varchar(64)
            ) ;""")
            c.close()
Esempio n. 32
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = [ModuleHook("PRIVMSG", self.scramble)]
        # Load attribute storage
        self.attr = None
        serviceProviders = self.bot.getmodulesbyservice("attributes")
        if len(serviceProviders) == 0:
            self.log.error(
                "DogeScramble: Could not find a valid attributes service provider"
            )
        else:
            self.log.info(
                "DogeScramble: Selecting attributes service provider: %s" %
                serviceProviders[0])
            self.attr = serviceProviders[0]

        # Load doge RPC
        self.doge = self.bot.getBestModuleForService("dogerpc")

        # Per channel games
        self.games = {}
Esempio n. 33
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = []
        self.services = ["attributes"]
        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("sqlite")
        if len(serviceProviders) == 0:
            self.log.error("Could not find a valid sqlite service provider")
            raise Exception("No sqlite provider available")
        else:
            self.log.info("Selecting sqlite service provider: %s" % serviceProviders[0])
            self.db = serviceProviders[0].opendb("attributes.db")

        if not self.db.tableExists("attribute"):
            self.log.info("Creating table: attribute")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `attribute` (
            `id` INTEGER PRIMARY KEY,
            `attribute` varchar(128) UNIQUE
            ) ;""")
            c.close()

        if not self.db.tableExists("items"):
            self.log.info("Creating table: items")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `items` (
            `id` INTEGER PRIMARY KEY,
            `item` varchar(512)
            ) ;""")
            c.close()

        if not self.db.tableExists("values"):
            self.log.info("Creating table: values")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `values` (
            `itemid` INTEGER NOT NULL,
            `attributeid` INTEGER NOT NULL,
            `value` TEXT,
            PRIMARY KEY (`itemid`, `attributeid`)
            ) ;""")
            c.close()
Esempio n. 34
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.hooks = []
        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("sqlite")
        if not serviceProviders:
            self.log.error("RandQuote: Could not find a valid sqlite service provider")
        else:
            self.log.info("RandQuote: Selecting sqlite service provider: %s" % serviceProviders[0])
            self.db = serviceProviders[0].opendb("randquote.db")

        if not self.db.tableExists("chat"):
            self.log.info("RandQuote: Creating table: chat")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `chat` (
            `id` INTEGER PRIMARY KEY,
            `date` INTEGER,
            `sender` varchar(64),
            `message` varchar(2048)
            ) ;""")
            c.close()

        self.hooks = [ModuleHook("PRIVMSG", self.logquote),
                      ModuleHook("PRIVMSG", self.fetchquotes)]
Esempio n. 35
0
    def __init__(self, bot, moduleName):
        # init the base module
        ModuleBase.__init__(self, bot, moduleName)

        # Dictionary
        self.wordsCount = 0
        self.wordsFile = self.getFilePath("words.txt")
        print(self.wordsFile)
        wordsF = open(self.wordsFile, "r")
        while True:
            word = wordsF.readline()
            if not word:
                break
            self.wordsCount += 1
        wordsF.close
        self.log.info("Scramble: Loaded %s words" % str(self.wordsCount))
        # Load scores
        self.scoresFile = self.getFilePath("scores.json")
        if not os.path.exists(self.scoresFile):
            json.dump({}, open(self.scoresFile, 'w'))
        self.scores = json.load(open(self.scoresFile, 'r'))
        # Per channel games
        self.games = {}
Esempio n. 36
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.services = ["attributes"]
        self.db = None
        serviceProviders = self.bot.getmodulesbyservice("sqlite")
        if len(serviceProviders) == 0:
            self.log.error("Could not find a valid sqlite service provider")
            raise Exception("No sqlite provider available")
        else:
            self.log.info("Selecting sqlite service provider: %s" % serviceProviders[0])
            self.db = serviceProviders[0].opendb("attributes.db")

        if not self.db.tableExists("attribute"):
            self.log.info("Creating table: attribute")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `attribute` (
            `id` INTEGER PRIMARY KEY,
            `attribute` varchar(128) UNIQUE
            ) ;""")
            c.close()

        if not self.db.tableExists("items"):
            self.log.info("Creating table: items")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `items` (
            `id` INTEGER PRIMARY KEY,
            `item` varchar(512)
            ) ;""")
            c.close()

        if not self.db.tableExists("values"):
            self.log.info("Creating table: values")
            c = self.db.query("""CREATE TABLE IF NOT EXISTS `values` (
            `itemid` INTEGER NOT NULL,
            `attributeid` INTEGER NOT NULL,
            `value` TEXT,
            PRIMARY KEY (`itemid`, `attributeid`)
            ) ;""")
            c.close()
Esempio n. 37
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.REQUEST_SIZE_LIMIT = 10 * 1024
Esempio n. 38
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.dotest)]
Esempio n. 39
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["sqlite"]
Esempio n. 40
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("_CONNECT", self.doConnect)]
Esempio n. 41
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.cache = None
     self.cacheAge = 0
Esempio n. 42
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.quietuntil = time()
     self.hooks.append(ModuleHook("PRIVMSG", self.check))
Esempio n. 43
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks.append(ModuleHook("PRIVMSG", self.handleMessage))
     self.bot = bot
Esempio n. 44
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.loadConfig()
     print(self.config)
     self.hooks=[ModuleHook("PRIVMSG", self.echo)]
Esempio n. 45
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = []
     self.services = ["dogerpc"]
     self.rpc = DogeController(self)
Esempio n. 46
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.REQUEST_SIZE_LIMIT = 10 * 1024
     self.hooks = [ModuleHook("PRIVMSG", self.searches)]
Esempio n. 47
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["mysql"]
     self.connection = self.getConnection()
Esempio n. 48
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.running_asciis = defaultdict(lambda: None)
     self.killed_channels = defaultdict(lambda: False)
Esempio n. 49
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
Esempio n. 50
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["dogerpc"]
     self.rpc = DogeController(self)
Esempio n. 51
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.got_msg), ModuleHook("JOIN", self.join_ch)]
     self.loadConfig()
     self.games = {}
Esempio n. 52
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = []
     self.services = ["bitcoinrpc"]
     self.rpcservices = {}
     self.loadrpcservices()
Esempio n. 53
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.running_asciis = defaultdict(lambda: None)
     self.killed_channels = defaultdict(lambda: False)
Esempio n. 54
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["bitcoinrpc"]
     self.rpcservices = {}
     self.loadrpcservices()
Esempio n. 55
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.error)]
Esempio n. 56
0
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)
        self.sqlite = self.bot.getBestModuleForService("sqlite")

        if self.sqlite is None:
            raise MissingDependancyException(
                "StockPlay: SQLIite service is required.")

        self.sql = self.sqlite.opendb("stockplay.db")

        with closing(self.sql.getCursor()) as c:
            if not self.sql.tableExists("stockplay_balances"):
                c.execute("""CREATE TABLE `stockplay_balances` (
                      `nick` varchar(64) PRIMARY KEY,
                      `cents` integer
                    );""")
                c.execute("""INSERT INTO `stockplay_balances` VALUES (?, ?)""",
                          (DUSTACCT, 0))
            if not self.sql.tableExists("stockplay_holdings"):
                c.execute("""CREATE TABLE `stockplay_holdings` (
                      `nick` varchar(64),
                      `symbol` varchar(12),
                      `count` integer,
                      PRIMARY KEY (nick, symbol)
                    );""")
            if not self.sql.tableExists("stockplay_trades"):
                c.execute("""CREATE TABLE `stockplay_trades` (
                      `nick` varchar(64),
                      `time` integer,
                      `type` varchar(8),
                      `symbol` varchar(12),
                      `count` integer,
                      `price` integer,
                      `quoteprice` varchar(12)
                    );""")
            if not self.sql.tableExists("stockplay_prices"):
                c.execute("""CREATE TABLE `stockplay_prices` (
                      `symbol` varchar(12) PRIMARY KEY,
                      `time` integer,
                      `attempt_time` integer,
                      `data` text
                    );""")
            if not self.sql.tableExists("stockplay_balance_history"):
                c.execute("""CREATE TABLE `stockplay_balance_history` (
                      `nick` varchar(64),
                      `day` text,
                      `cents` integer,
                      PRIMARY KEY(nick, day)
                    );""")
            # if not self.sql.tableExists("stockplay_report_cache"):
            #     c.execute("""CREATE TABLE `stockplay_report_cache` (
            #           `nick` varchar(64) PRIMARY KEY,
            #           `time` integer,
            #           `data` text
            #         );""")

        self.cache = PriceCache(self)

        # Last time the interval tasks were executed
        self.task_time = 0

        # background work executor thread
        self.asyncq = Queue()
        self.running = True

        self.trader = Thread(target=self.trader_background)
        self.trader.start()

        # quote updater thread
        self.pricer = Thread(target=self.price_updater)
        self.pricer.start()
Esempio n. 57
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.timer = PingRespondTimer(self)
Esempio n. 58
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
Esempio n. 59
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.gotmsg)]
     self.services = ["login"]