コード例 #1
0
ファイル: Tell.py プロジェクト: r3cursive/pyircbot
    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()
コード例 #2
0
ファイル: Remind.py プロジェクト: r3cursive/pyircbot
    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()
コード例 #3
0
ファイル: PubSubClient.py プロジェクト: dpedu/pyircbot3
 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()
コード例 #4
0
ファイル: Remind.py プロジェクト: dpedu/pyircbot3
    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()
コード例 #5
0
ファイル: Scramble.py プロジェクト: dpedu/pyircbot3
    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)]
コード例 #6
0
ファイル: DogeWallet.py プロジェクト: r3cursive/pyircbot
 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")
コード例 #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()
コード例 #8
0
ファイル: TextCDC.py プロジェクト: dpedu/pyircbot3
 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()
コード例 #9
0
ファイル: Election.py プロジェクト: r3cursive/pyircbot
 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 = {}
コード例 #10
0
ファイル: Services.py プロジェクト: dpedu/pyircbot3
 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
コード例 #11
0
ファイル: PingResponder.py プロジェクト: dpedu/pyircbot3
 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)
     ]
コード例 #12
0
ファイル: BitcoinPrice.py プロジェクト: dpedu/pyircbot3
    def __init__(self, bot, moduleName):
        ModuleBase.__init__(self, bot, moduleName)

        self.cache = None
        self.cacheAge = 0

        self.hooks = [
            ModuleHook(["PRIVMSG"], self.btc)
        ]
コード例 #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()
コード例 #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 = {}
コード例 #15
0
ファイル: GameBase.py プロジェクト: dpedu/pyircbot3
 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 = {}
コード例 #16
0
ファイル: Calc.py プロジェクト: dpedu/pyircbot3
    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()
コード例 #17
0
ファイル: Calc.py プロジェクト: r3cursive/pyircbot
    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()
コード例 #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()
コード例 #19
0
ファイル: DuckHunt.py プロジェクト: dpedu/pyircbot3
    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()
コード例 #20
0
ファイル: Seen.py プロジェクト: dpedu/pyircbot3
 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"
コード例 #21
0
ファイル: UnoPlay.py プロジェクト: r3cursive/pyircbot
 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 = []
コード例 #22
0
ファイル: SMS.py プロジェクト: r3cursive/pyircbot
    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())
コード例 #23
0
ファイル: UnoPlay.py プロジェクト: dpedu/pyircbot3
 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 = []
コード例 #24
0
ファイル: Seen.py プロジェクト: r3cursive/pyircbot
 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`))"
         )
コード例 #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 = {}
コード例 #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 = {}
コード例 #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()
コード例 #28
0
ファイル: DogeScramble.py プロジェクト: dpedu/pyircbot3
    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 = {}
コード例 #29
0
ファイル: Weather.py プロジェクト: r3cursive/pyircbot
    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
コード例 #30
0
ファイル: Weather.py プロジェクト: dpedu/pyircbot3
    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)]
コード例 #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()
コード例 #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 = {}
コード例 #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()
コード例 #34
0
ファイル: RandQuote.py プロジェクト: dpedu/pyircbot3
    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)]
コード例 #35
0
ファイル: Scramble.py プロジェクト: r3cursive/pyircbot
    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 = {}
コード例 #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()
コード例 #37
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.REQUEST_SIZE_LIMIT = 10 * 1024
コード例 #38
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.dotest)]
コード例 #39
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["sqlite"]
コード例 #40
0
ファイル: ServerPassword.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("_CONNECT", self.doConnect)]
コード例 #41
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.cache = None
     self.cacheAge = 0
コード例 #42
0
ファイル: Triggered.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.quietuntil = time()
     self.hooks.append(ModuleHook("PRIVMSG", self.check))
コード例 #43
0
ファイル: LMGTFY.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks.append(ModuleHook("PRIVMSG", self.handleMessage))
     self.bot = bot
コード例 #44
0
ファイル: EchoExample.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.loadConfig()
     print(self.config)
     self.hooks=[ModuleHook("PRIVMSG", self.echo)]
コード例 #45
0
ファイル: DogeRPC.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = []
     self.services = ["dogerpc"]
     self.rpc = DogeController(self)
コード例 #46
0
ファイル: LinkTitler.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.REQUEST_SIZE_LIMIT = 10 * 1024
     self.hooks = [ModuleHook("PRIVMSG", self.searches)]
コード例 #47
0
ファイル: MySQL.py プロジェクト: r3cursive/pyircbot
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["mysql"]
     self.connection = self.getConnection()
コード例 #48
0
ファイル: ASCII.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.running_asciis = defaultdict(lambda: None)
     self.killed_channels = defaultdict(lambda: False)
コード例 #49
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
コード例 #50
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["dogerpc"]
     self.rpc = DogeController(self)
コード例 #51
0
ファイル: Election.py プロジェクト: dpedu/pyircbot3
 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 = {}
コード例 #52
0
ファイル: CryptoWalletRPC.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = []
     self.services = ["bitcoinrpc"]
     self.rpcservices = {}
     self.loadrpcservices()
コード例 #53
0
ファイル: ASCII.py プロジェクト: r3cursive/pyircbot
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.running_asciis = defaultdict(lambda: None)
     self.killed_channels = defaultdict(lambda: False)
コード例 #54
0
ファイル: CryptoWalletRPC.py プロジェクト: r3cursive/pyircbot
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.services = ["bitcoinrpc"]
     self.rpcservices = {}
     self.loadrpcservices()
コード例 #55
0
ファイル: Error.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.error)]
コード例 #56
0
ファイル: StockPlay.py プロジェクト: r3cursive/pyircbot
    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()
コード例 #57
0
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.timer = PingRespondTimer(self)
コード例 #58
0
ファイル: UserModule.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
コード例 #59
0
ファイル: NickUser.py プロジェクト: dpedu/pyircbot3
 def __init__(self, bot, moduleName):
     ModuleBase.__init__(self, bot, moduleName)
     self.hooks = [ModuleHook("PRIVMSG", self.gotmsg)]
     self.services = ["login"]