コード例 #1
0
ファイル: app.py プロジェクト: gitter-badger/XLeague
    def privmsg(self, user, channel, msg):
        global QueuedPlayers
        global NeededToStart
        global GameType
        global PodGames
        global GameOpen
        global runninggames

        user = user.split('!', 1)[0]
        status = "%s in %s: %s" % (user, channel, msg)
        log(status)

        if channel == self.nickname:
            ignore = ['ChanServ', 'AuthServ', 'iScrE4m']
            if user == 'iScrE4m':
                command = msg.split()
                channel = command[0]
                msg = " ".join(command[1:])
                sendmsg(self, channel, msg)
            elif user not in ignore:
                msg = "Please use %s for commands." % s.channel
                channel = user
                sendmsg(self, channel, msg)

        if msg.startswith(".join"):
            authed = yield self.deferredwhois(user)
            player = db.getplayer(authed)
            games = db.getrunning()
            if player is not None:
                if player['Name'] not in QueuedPlayers and player[
                        'Name'] not in games and GameOpen == 1:
                    addtoqueue(authed)
                    if len(QueuedPlayers) == NeededToStart:
                        msg = startpod(self)
                    else:
                        msg = str(
                            NeededToStart - len(QueuedPlayers)
                        ) + " to start %s. Type .join to join" % GameType

                elif GameOpen == 0:
                    msg = "No games open. Ask a Judge to open a game for you."
                else:
                    msg = "You are already in a queue"
            else:
                msg = "You are not vouched"
            sendmsg(self, channel, msg)

        if msg.startswith(".leave"):
            authed = yield self.deferredwhois(user)
            if authed in QueuedPlayers:
                removefromqueue(authed)
                msg = "%s left the queue" % authed
            else:
                msg = "You can't leave if you didn't join, silly"
            sendmsg(self, channel, msg)

        if msg.startswith(".players"):
            if GameOpen == 1:
                msg = "%i out of %i in queue for %s: " % (
                    len(QueuedPlayers), NeededToStart, GameType) + ", ".join(
                        map(str, QueuedPlayers))
            else:
                msg = "No games open. Ask a Judge to open a game for you."
            sendmsg(self, channel, msg)

        if msg.startswith(".player "):
            player = msg.split()
            player = player[1]
            try:
                stats = db.getplayer(player)
                try:
                    wlr = str(int(stats['W'] / stats['Played'] * 100)) + "%"
                except ZeroDivisionError:
                    wlr = "N/A"
                msg = "Stats for %s - Rating: %i - Games Played: %i - Wins: %i - Losses: %i - WLR: %s" % (
                    stats['Name'], stats['ELO'], stats['Played'], stats['W'],
                    stats['L'], wlr)
            except TypeError:
                msg = "No player named '%s' found" % player
            sendmsg(self, channel, msg)

        if msg.startswith(".card"):
            card = msg.split(" ", 1)[1]
            fetchcarddatabyname(self, channel, card)

        if msg.startswith(".games"):
            running = db.getrunning()
            if not running:
                msg = "No games are in progress."
            else:
                msg = "Games in progress "
                for row in running:
                    msg += "| #%s " % str(row[0])
            sendmsg(self, channel, msg)

        if msg.startswith(".info"):
            id = msg.split()
            id = int(id[1])
            game = db.getgameid(id)
            if game is not None:
                # noinspection PyPep8
                msg = "Game #%i - Running: %s - Type: %s - Pod size: %i - Games Played: %i - Players: %s, %s, %s, %s, %s, %s, %s, %s" % (
                    game['ID'], game['Running'], game['GameType'], game['Pod'],
                    game['GamesPlayed'], game['Player 1'], game['Player 2'],
                    game['Player 3'], game['Player 4'], game['Player 5'],
                    game['Player 6'], game['Player 7'], game['Player 8'])
                msg = msg.replace(", None", "")
            else:
                msg = "There is no game with ID %i" % id
            sendmsg(self, channel, msg)

        if msg.startswith(".help"):
            channel = user
            authed = yield self.deferredwhois(user)
            msg = "My commands:\n"
            msg += ".join ~~~ Joins queue for an open game\n"
            msg += ".leave ~~~ Leaves Queue you were in\n"
            msg += ".players ~~~ Lists players queued for an open game\n"
            msg += ".player <nick> ~~~ Gets stats of player\n"
            msg += ".games ~~~ Lists IDs of running games\n"
            msg += ".info <GameID> ~~~ Gets info about game\n"
            msg += ".card <CardName> ~~~ Gets details of a card\n"  # Since this I learned how to make """superstrings"""
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                msg += "===== JUDGE COMMANDS =====\n"
                msg += ".confirmvouch <nick> ~~~ Vouches player (or .denyvouch)\n"
                msg += ".open <GameType> <Players> ~~~ Opens a draft/sealed for number of players\n"
                msg += ".close <GameID> ~~~ Closes game (Used for games in database, NOT for queues)\n"
                msg += ".result <GameID> <Winner> <WinnerScore> <LoserScore> <Loser> ~~~ Reports a result for GameID.\n"
                msg += ".updateleader ~~~ Updates leaderboard on the website"
            sendmsg(self, channel, msg)

        # Judge commands

        if msg.startswith(".confirmvouch"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                vouched = msg.split()
                vouched = vouched[1]
                msg = db.confirmvouch(vouched)
            else:
                msg = "You don't have sufficient permissions to vouch anybody"
            sendmsg(self, channel, msg)

        if msg.startswith(".denyvouch"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                vouched = msg.split()
                vouched = vouched[1]
                msg = db.denyvouch(vouched)
            else:
                msg = "You don't have sufficient permissions to deny a vouch requests"
            sendmsg(self, channel, msg)

        if msg.startswith(".open"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                msg = msg.split()
                GameOpen = 1
                GameType = msg[1]
                NeededToStart = int(msg[2])
                QueuedPlayers = []
                msg = "%s for %i players is now open. Type .join to join" % (
                    GameType, NeededToStart)
            else:
                msg = "You don't have sufficient permissions to open new game."
            sendmsg(self, channel, msg)

        if msg.startswith(".close"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                msg = msg.split()
                id = int(msg[1])
                db.closegame(id)
                runninggames.remove(str(id))
                msg = "Game closed."
            else:
                msg = "You don't have sufficient permissions to clos games."
            sendmsg(self, channel, msg)

        if msg.startswith(".result"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                result = msg.split()
                id = int(result[1])

                winner = result[2]
                winnerdict = db.getplayer(winner)
                playedw = winnerdict['Played'] + 1
                ww = winnerdict['W'] + 1
                lw = winnerdict['L']

                loser = result[5]
                loserdict = db.getplayer(loser)
                playedl = loserdict['Played'] + 1
                wl = loserdict['W']
                ll = loserdict['L'] + 1

                winnerelo = ELO.newelo("W", winnerdict, loserdict)
                loserelo = ELO.newelo("L", winnerdict, loserdict)
                changewinner = winnerelo - winnerdict['ELO']
                changeloser = loserelo - loserdict['ELO']

                msg = "New Ratings: %s %i [+%i] %s %i [%i]" % (
                    winner, winnerelo, changewinner, loser, loserelo,
                    changeloser)

                db.ratingchange(winner, winnerelo, playedw, ww, lw)
                db.ratingchange(loser, loserelo, playedl, wl, ll)

                game = db.getgameid(id)
                played = game['GamesPlayed'] + 1
                db.gamenewplayed(played, id)
                if played == PodGames[game['Pod']]:
                    db.closegame(id)
                    runninggames.remove(str(id))
                    msg += "\nGame #%i ended." % id
            else:
                msg = "You don't have sufficient permissions to report results. Ask a judge to report them for you."
            sendmsg(self, channel, msg)

        # Admin commands

        if msg.startswith(".promote"):
            authed = yield self.deferredwhois(user)
            admins = ['iScrE4m']
            if authed in admins:
                judge = msg.split()
                judge = judge[1]
                db.makejudge(judge)
                giveop(self, judge)
                msg = "%s is now Judge" % judge
            else:
                msg = "Only admin can promote players."
            sendmsg(self, channel, msg)
コード例 #2
0
ファイル: app.py プロジェクト: iScrE4m/XLeague
    def privmsg(self, user, channel, msg):
        global QueuedPlayers
        global NeededToStart
        global GameType
        global PodGames
        global GameOpen
        global runninggames

        user = user.split("!", 1)[0]
        status = "{} in {}: {}".format(user, channel, msg)
        log(status)

        if channel == self.nickname:
            ignore = ["ChanServ", "AuthServ", "iScrE4m"]
            if user == "iScrE4m":
                command = msg.split()
                channel = command[0]
                msg = " ".join(command[1:])
                sendmsg(self, channel, msg)
            elif user not in ignore:
                msg = "Please use {} for commands.".format(s.channel)
                channel = user
                sendmsg(self, channel, msg)

        if msg.startswith(".join"):
            authed = yield self.deferredwhois(user)
            player = db.getplayer(authed)
            games = db.getrunning()
            if player is not None:
                if player["Name"] not in QueuedPlayers and player["Name"] not in games and GameOpen == 1:
                    addtoqueue(authed)
                    if len(QueuedPlayers) == NeededToStart:
                        msg = startpod(self)
                    else:
                        players_left = NeededToStart - len(QueuedPlayers)
                        msg = "{} to start {}. Type .join to join".format(players_left, GameType)

                elif GameOpen == 0:
                    msg = "No games open. Ask a Judge to open a game for you."
                else:
                    msg = "You are already in a queue"
            else:
                msg = "You are not vouched"
            sendmsg(self, channel, msg)

        if msg.startswith(".leave"):
            authed = yield self.deferredwhois(user)
            if authed in QueuedPlayers:
                removefromqueue(authed)
                msg = "{} left the queue".format(authed)
            else:
                msg = "You can't leave if you didn't join, silly"
            sendmsg(self, channel, msg)

        if msg.startswith(".players"):
            if GameOpen == 1:
                players = ", ".join(map(str, QueuedPlayers))
                msg = "{} out of {} in queue for {}: {}".format(len(QueuedPlayers), NeededToStart, GameType, players)
            else:
                msg = "No games open. Ask a Judge to open a game for you."
            sendmsg(self, channel, msg)

        if msg.startswith(".player "):
            player = msg.split()
            player = player[1]
            try:
                stats = db.getplayer(player)
                try:
                    wlr = str(int(stats["W"] / stats["Played"] * 100)) + "%"
                except ZeroDivisionError:
                    wlr = "N/A"
                msg = "\n".join(
                    ["Stats for {} - Rating: {} - Games Played: {}", " - Wins: {} - Losses: {} - WLR: {}"]
                ).format(stats["Name"], stats["ELO"], stats["Played"], stats["W"], stats["L"], wlr)
            except TypeError:
                msg = "No player named '{}' found".format(player)
            sendmsg(self, channel, msg)

        if msg.startswith(".card"):
            card = msg.split(" ", 1)[1]
            fetchcarddatabyname(self, channel, card)

        if msg.startswith(".games"):
            running = db.getrunning()
            if not running:
                msg = "No games are in progress."
            else:
                games = " | ".join(["#{}".format(str(row[0])) for row in running])
                msg = "Games in progress | {}".format(games)
            sendmsg(self, channel, msg)

        if msg.startswith(".info"):
            id = msg.split()
            id = int(id[1])
            game = db.getgameid(id)
            if game is not None:
                players = ", ".join([game["Player {}".format(ix)] for ix in range(1, 9)])
                msg = "\n".join(
                    ["Game #{} - Running: {} - Type: {}", " - Pod size: {} - Games Played: {} - Players: {}"]
                ).join(game["ID"], game["Running"], game["GameType"], game["Pod"], game["GamesPlayed"], players)
                msg = msg.replace(", None", "")
            else:
                msg = "There is no game with ID {}".format(id)
            sendmsg(self, channel, msg)

        if msg.startswith(".help"):
            channel = user
            authed = yield self.deferredwhois(user)
            msg = "\n".join(
                [
                    "My commands:",
                    ".join ~~~ Joins queue for an open game",
                    ".leave ~~~ Leaves Queue you were in",
                    ".players ~~~ Lists players queued for an open game",
                    ".player <nick> ~~~ Gets stats of player",
                    ".games ~~~ Lists IDs of running games",
                    ".info <GameID> ~~~ Gets info about game",
                    ".card <CardName> ~~~ Gets details of a card",
                ]
            )
            judge = db.getplayer(authed)
            if judge["Judge"] == 1:
                msg += "\n".join(
                    [
                        "",
                        "===== JUDGE COMMANDS =====",
                        ".confirm_vouch_req <nick> ~~~ Vouches player (or .deny_vouch_req)",
                        ".open <GameType> <Players> ~~~ Opens a draft/sealed for" + " number of players",
                        ".close <GameID> ~~~ Closes game (Used for games in" + " database, NOT for queues)",
                        ".result <GameID> <Winner> <WinnerScore> <LoserScore>"
                        + " <Loser> ~~~ Reports a result for GameID.",
                        ".updateleader ~~~ Updates leaderboard on the website",
                    ]
                )
            sendmsg(self, channel, msg)

        # Judge commands

        if msg.startswith(".confirm_vouch_req"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge["Judge"] == 1:
                vouched = msg.split()
                vouched = vouched[1]
                msg = db.confirm_vouch_req(vouched)
            else:
                msg = "You don't have sufficient permissions to vouch anybody"
            sendmsg(self, channel, msg)

        if msg.startswith(".deny_vouch_req"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge["Judge"] == 1:
                vouched = msg.split()
                vouched = vouched[1]
                msg = db.deny_vouch_req(vouched)
            else:
                msg = " ".join(["You don't have sufficient permissions", "to deny a vouch requests"])
            sendmsg(self, channel, msg)

        if msg.startswith(".open"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge["Judge"] == 1:
                msg = msg.split()
                GameOpen = 1
                GameType = msg[1]
                NeededToStart = int(msg[2])
                QueuedPlayers = []
                msg = ("{} for {} players is now open." + " Type .join to join").format(GameType, NeededToStart)
            else:
                msg = "You don't have sufficient permissions to open new game."
            sendmsg(self, channel, msg)

        if msg.startswith(".close"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge["Judge"] == 1:
                msg = msg.split()
                id = int(msg[1])
                db.closegame(id)
                runninggames.remove(str(id))
                msg = "Game closed."
            else:
                msg = "You don't have sufficient permissions to clos games."
            sendmsg(self, channel, msg)

        if msg.startswith(".result"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge["Judge"] == 1:
                result = msg.split()
                id = int(result[1])

                winner = result[2]
                winnerdict = db.getplayer(winner)
                playedw = winnerdict["Played"] + 1
                ww = winnerdict["W"] + 1
                lw = winnerdict["L"]

                loser = result[5]
                loserdict = db.getplayer(loser)
                playedl = loserdict["Played"] + 1
                wl = loserdict["W"]
                ll = loserdict["L"] + 1

                winnerelo = ELO.newelo("W", winnerdict, loserdict)
                loserelo = ELO.newelo("L", winnerdict, loserdict)
                changewinner = winnerelo - winnerdict["ELO"]
                changeloser = loserelo - loserdict["ELO"]

                msg = "New Ratings: {} {} [+{}] {} {} [{}]".format(
                    winner, winnerelo, changewinner, loser, loserelo, changeloser
                )

                db.rating_change(winner, winnerelo, playedw, ww, lw)
                db.rating_change(loser, loserelo, playedl, wl, ll)

                game = db.getgameid(id)
                played = game["GamesPlayed"] + 1
                db.gamenewplayed(played, id)
                if played == PodGames[game["Pod"]]:
                    db.closegame(id)
                    runninggames.remove(str(id))
                    msg += "\nGame #{} ended.".format(id)
            else:
                msg = " ".join(
                    ["You don't have sufficient permissions to report results.", "Ask a judge to report them for you."]
                )
            sendmsg(self, channel, msg)

        # Admin commands

        if msg.startswith(".promote"):
            authed = yield self.deferredwhois(user)
            admins = ["iScrE4m"]
            if authed in admins:
                judge = msg.split()
                judge = judge[1]
                db.makejudge(judge)
                giveop(self, judge)
                msg = "{} is now Judge".format(judge)
            else:
                msg = "Only admin can promote players."
            sendmsg(self, channel, msg)
コード例 #3
0
ファイル: app.py プロジェクト: gitter-badger/XLeague
    def privmsg(self, user, channel, msg):
        global QueuedPlayers
        global NeededToStart
        global GameType
        global PodGames
        global GameOpen
        global runninggames

        user = user.split('!', 1)[0]
        status = "%s in %s: %s" % (user, channel, msg)
        log(status)

        if channel == self.nickname:
            ignore = ['ChanServ', 'AuthServ', 'iScrE4m']
            if user == 'iScrE4m':
                command = msg.split()
                channel = command[0]
                msg = " ".join(command[1:])
                sendmsg(self, channel, msg)
            elif user not in ignore:
                msg = "Please use %s for commands." % s.channel
                channel = user
                sendmsg(self, channel, msg)

        if msg.startswith(".join"):
            authed = yield self.deferredwhois(user)
            player = db.getplayer(authed)
            games = db.getrunning()
            if player is not None:
                if player['Name'] not in QueuedPlayers and player['Name'] not in games and GameOpen == 1:
                    addtoqueue(authed)
                    if len(QueuedPlayers) == NeededToStart:
                        msg = startpod(self)
                    else:
                        msg = str(NeededToStart - len(QueuedPlayers)) + " to start %s. Type .join to join" % GameType

                elif GameOpen == 0:
                    msg = "No games open. Ask a Judge to open a game for you."
                else:
                    msg = "You are already in a queue"
            else:
                msg = "You are not vouched"
            sendmsg(self, channel, msg)

        if msg.startswith(".leave"):
            authed = yield self.deferredwhois(user)
            if authed in QueuedPlayers:
                removefromqueue(authed)
                msg = "%s left the queue" % authed
            else:
                msg = "You can't leave if you didn't join, silly"
            sendmsg(self, channel, msg)

        if msg.startswith(".players"):
            if GameOpen == 1:
                msg = "%i out of %i in queue for %s: " % (len(QueuedPlayers), NeededToStart, GameType) + ", ".join(
                    map(str, QueuedPlayers))
            else:
                msg = "No games open. Ask a Judge to open a game for you."
            sendmsg(self, channel, msg)

        if msg.startswith(".player "):
            player = msg.split()
            player = player[1]
            try:
                stats = db.getplayer(player)
                try:
                    wlr = str(int(stats['W'] / stats['Played'] * 100)) + "%"
                except ZeroDivisionError:
                    wlr = "N/A"
                msg = "Stats for %s - Rating: %i - Games Played: %i - Wins: %i - Losses: %i - WLR: %s" % (
                    stats['Name'], stats['ELO'], stats['Played'], stats['W'], stats['L'], wlr)
            except TypeError:
                msg = "No player named '%s' found" % player
            sendmsg(self, channel, msg)

        if msg.startswith(".card"):
            card = msg.split(" ", 1)[1]
            fetchcarddatabyname(self, channel, card)

        if msg.startswith(".games"):
            running = db.getrunning()
            if not running:
                msg = "No games are in progress."
            else:
                msg = "Games in progress "
                for row in running:
                    msg += "| #%s " % str(row[0])
            sendmsg(self, channel, msg)

        if msg.startswith(".info"):
            id = msg.split()
            id = int(id[1])
            game = db.getgameid(id)
            if game is not None:
                # noinspection PyPep8
                msg = "Game #%i - Running: %s - Type: %s - Pod size: %i - Games Played: %i - Players: %s, %s, %s, %s, %s, %s, %s, %s" % (
                    game['ID'], game['Running'], game['GameType'], game['Pod'], game['GamesPlayed'], game['Player 1'],
                    game['Player 2'], game['Player 3'], game['Player 4'], game['Player 5'], game['Player 6'],
                    game['Player 7'], game['Player 8'])
                msg = msg.replace(", None", "")
            else:
                msg = "There is no game with ID %i" % id
            sendmsg(self, channel, msg)

        if msg.startswith(".help"):
            channel = user
            authed = yield self.deferredwhois(user)
            msg = "My commands:\n"
            msg += ".join ~~~ Joins queue for an open game\n"
            msg += ".leave ~~~ Leaves Queue you were in\n"
            msg += ".players ~~~ Lists players queued for an open game\n"
            msg += ".player <nick> ~~~ Gets stats of player\n"
            msg += ".games ~~~ Lists IDs of running games\n"
            msg += ".info <GameID> ~~~ Gets info about game\n"
            msg += ".card <CardName> ~~~ Gets details of a card\n" # Since this I learned how to make """superstrings"""
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                msg += "===== JUDGE COMMANDS =====\n"
                msg += ".confirmvouch <nick> ~~~ Vouches player (or .denyvouch)\n"
                msg += ".open <GameType> <Players> ~~~ Opens a draft/sealed for number of players\n"
                msg += ".close <GameID> ~~~ Closes game (Used for games in database, NOT for queues)\n"
                msg += ".result <GameID> <Winner> <WinnerScore> <LoserScore> <Loser> ~~~ Reports a result for GameID.\n"
                msg += ".updateleader ~~~ Updates leaderboard on the website"
            sendmsg(self, channel, msg)

        # Judge commands

        if msg.startswith(".confirmvouch"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                vouched = msg.split()
                vouched = vouched[1]
                msg = db.confirmvouch(vouched)
            else:
                msg = "You don't have sufficient permissions to vouch anybody"
            sendmsg(self, channel, msg)

        if msg.startswith(".denyvouch"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                vouched = msg.split()
                vouched = vouched[1]
                msg = db.denyvouch(vouched)
            else:
                msg = "You don't have sufficient permissions to deny a vouch requests"
            sendmsg(self, channel, msg)

        if msg.startswith(".open"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                msg = msg.split()
                GameOpen = 1
                GameType = msg[1]
                NeededToStart = int(msg[2])
                QueuedPlayers = []
                msg = "%s for %i players is now open. Type .join to join" % (GameType, NeededToStart)
            else:
                msg = "You don't have sufficient permissions to open new game."
            sendmsg(self, channel, msg)

        if msg.startswith(".close"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                msg = msg.split()
                id = int(msg[1])
                db.closegame(id)
                runninggames.remove(str(id))
                msg = "Game closed."
            else:
                msg = "You don't have sufficient permissions to clos games."
            sendmsg(self, channel, msg)

        if msg.startswith(".result"):
            authed = yield self.deferredwhois(user)
            judge = db.getplayer(authed)
            if judge['Judge'] == 1:
                result = msg.split()
                id = int(result[1])

                winner = result[2]
                winnerdict = db.getplayer(winner)
                playedw = winnerdict['Played'] + 1
                ww = winnerdict['W'] + 1
                lw = winnerdict['L']

                loser = result[5]
                loserdict = db.getplayer(loser)
                playedl = loserdict['Played'] + 1
                wl = loserdict['W']
                ll = loserdict['L'] + 1

                winnerelo = ELO.newelo("W", winnerdict, loserdict)
                loserelo = ELO.newelo("L", winnerdict, loserdict)
                changewinner = winnerelo - winnerdict['ELO']
                changeloser = loserelo - loserdict['ELO']

                msg = "New Ratings: %s %i [+%i] %s %i [%i]" % (
                    winner, winnerelo, changewinner, loser, loserelo, changeloser)

                db.ratingchange(winner, winnerelo, playedw, ww, lw)
                db.ratingchange(loser, loserelo, playedl, wl, ll)

                game = db.getgameid(id)
                played = game['GamesPlayed'] + 1
                db.gamenewplayed(played, id)
                if played == PodGames[game['Pod']]:
                    db.closegame(id)
                    runninggames.remove(str(id))
                    msg += "\nGame #%i ended." % id
            else:
                msg = "You don't have sufficient permissions to report results. Ask a judge to report them for you."
            sendmsg(self, channel, msg)

        # Admin commands

        if msg.startswith(".promote"):
            authed = yield self.deferredwhois(user)
            admins = ['iScrE4m']
            if authed in admins:
                judge = msg.split()
                judge = judge[1]
                db.makejudge(judge)
                giveop(self, judge)
                msg = "%s is now Judge" % judge
            else:
                msg = "Only admin can promote players."
            sendmsg(self, channel, msg)