Esempio n. 1
0
def _save_player_alias(sess, steamid, player_name, timestamp=None):
    name = sess.query(PlayerName).filter(
        PlayerName.name == player_name,
        PlayerName.steamid == steamid).one_or_none()

    if timestamp:
        dt = datetime.datetime.fromtimestamp(timestamp)
    else:
        dt = datetime.datetime.now()
    if not name:
        name = PlayerName(name=player_name, steamid=steamid, last_seen=dt)
        sess.add(name)
        logger.info("Adding player %s with new name %s", steamid.steam_id_64,
                    player_name)
        sess.commit()
    else:
        name.last_seen = dt
        sess.commit()

    return name
Esempio n. 2
0
def _save_player_alias(sess, steamid, player_name):
    name = sess.query(PlayerName).filter(
        PlayerName.name == player_name,
        PlayerName.steamid == steamid).one_or_none()

    if not name:
        name = PlayerName(name=player_name, steamid=steamid)
        sess.add(name)
        logger.info("Adding player %s with new name %s", steamid.steam_id_64,
                    player_name)
        sess.commit()

    return name