Пример #1
0
 def _insertPlayers(playerlist):
     for player in playerlist:
         if isinstance(player, StringTypes):
             db.runOperation("""INSERT INTO
                 pickup_players_games(game_id, name, game, time)
                 VALUES(?, ?, ?, ?)
             """, (id_, player, game.nick, itime()))
         else:
             _insertPlayers(player)
Пример #2
0
 def _setTopic(r):
     if len(r):
         self.motd_from_str(r[0][0])
         self.setmotd()
     else:
         db.runOperation("""
             INSERT INTO
             meta(key, val)
             VALUES("motd", "")
         """)
Пример #3
0
    def motdCmd(self, call, args):
        """!motd [...|--]]
        
        Sets the message of the day in the channel topic.
        !motd -- will make it empty"""

        if not args:
            call.reply(config.getescaped('Topic', 'separator').join(self.motd_str))
            return

        if len(args) == 1 and args[0] == '--':
            self.motd_str = []
        else:
            self.motd_from_str(' '.join(args))
            db.runOperation("""
                UPDATE meta
                SET val=?
                WHERE key="motd"
            """, (' '.join(args),))
        self.setmotd()
Пример #4
0
    def __init__(self, bot):
        db.runOperation("""
            CREATE TABLE IF NOT EXISTS
            pickup_games
            (
                id      INTEGER PRIMARY KEY AUTOINCREMENT,
                game    TEXT,
                time    INTEGER,
                players TEXT,
                captains TEXT
            )""")
        db.runOperation("""
            CREATE TABLE IF NOT EXISTS
            pickup_players_games
            (
                game_id INTEGER,
                name    TEXT,
                game    TEXT,
                time    INTEGER
            )
            """)

        self.pickup = bot.load('pickup')
Пример #5
0
 def _purge(self, keep=0):
     """used by clearGames and purgeGames"""
     res = defer.gatherResults([
         db.runOperation("""
             DELETE FROM """ + table + """
             WHERE time < ?
             """, (itime() - keep,))
         for table in ['pickup_games', 'pickup_players_games']
         ])
     def onErr(failure):
         log.err(failure, "purge games, keep = {0}".format(keep))
         return failure
     res.addErrback(onErr)
     return res