コード例 #1
0
ファイル: limelight.py プロジェクト: Subject38/bemaniutils
    def handle_event_w_add_comment_request(self, request: Node) -> Node:
        extid = request.child_value('uid')
        userid = self.data.remote.user.from_extid(self.game, self.version,
                                                  extid)
        if userid is None:
            # Anonymous comment
            userid = UserID(0)

        customize = request.child_value('customize')
        lid = request.child_value('lid')
        teamid = request.child_value('tid')
        teamname = request.child_value('t_name')
        prefecture = request.child_value('pref')
        comment = request.child_value('comment')
        is_tweet = request.child_value('is_tweet')

        # Link comment to user's profile
        self.data.local.user.put_time_based_achievement(
            self.game,
            self.version,
            userid,
            0,  # We never have an ID for this, since comments are add-only
            'puzzle_comment',
            {
                'customize': customize,
                'lid': lid,
                'teamid': teamid,
                'teamname': teamname,
                'prefecture': prefecture,
                'comment': comment,
                'tweet': is_tweet,
            },
        )

        return Node.void('event_w')
コード例 #2
0
ファイル: endpoints.py プロジェクト: wolskiCN/bemaniutils
def removerival() -> Dict[str, Any]:
    frontend = DDRFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    other_userid = UserID(int(request.get_json()['userid']))
    position = int(request.get_json()['position'])
    userid = g.userID

    # Remove this rival link
    g.data.local.user.destroy_link(
        GameConstants.DDR,
        version,
        userid,
        'friend_{}'.format(position),
        other_userid,
    )

    profile = g.data.local.user.get_profile(GameConstants.DDR, version, userid)
    if profile is None:
        raise Exception('Unable to find profile to update!')
    profile = frontend.deactivate_rival(profile, position)
    g.data.local.user.put_profile(GameConstants.DDR, version, userid, profile)

    # Now return updated rival info
    rivals, info = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': info,
    }
コード例 #3
0
ファイル: endpoints.py プロジェクト: Subject38/bemaniutils
def addrival() -> Dict[str, Any]:
    frontend = PopnMusicFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    other_userid = UserID(int(request.get_json()['userid']))
    userid = g.userID

    # Add this rival link
    profile = g.data.remote.user.get_profile(GameConstants.POPN_MUSIC, version,
                                             other_userid)
    if profile is None:
        raise Exception('Unable to find profile for rival!')

    g.data.local.user.put_link(
        GameConstants.POPN_MUSIC,
        version,
        userid,
        'rival',
        other_userid,
        {},
    )

    # Now return updated rival info
    rivals, playerinfo = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
コード例 #4
0
def removerival() -> Dict[str, Any]:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    rivaltype = request.get_json()['type']
    other_userid = UserID(int(request.get_json()['userid']))
    userid = g.userID

    # Remove this rival link
    if rivaltype != 'sp_rival' and rivaltype != 'dp_rival':
        raise Exception(f'Invalid rival type {rivaltype}!')

    g.data.local.user.destroy_link(
        GameConstants.IIDX,
        version,
        userid,
        rivaltype,
        other_userid,
    )

    # Now return updated rival info
    rivals, djinfo = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': djinfo,
    }
コード例 #5
0
def addrival() -> Dict[str, Any]:
    frontend = IIDXFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    rivaltype = request.get_json()['type']
    other_userid = UserID(int(request.get_json()['userid']))
    userid = g.userID

    # Add this rival link
    if rivaltype != 'sp_rival' and rivaltype != 'dp_rival':
        raise Exception(f'Invalid rival type {rivaltype}!')
    profile = g.data.remote.user.get_profile(GameConstants.IIDX, version,
                                             other_userid)
    if profile is None:
        raise Exception('Unable to find profile for rival!')

    g.data.local.user.put_link(
        GameConstants.IIDX,
        version,
        userid,
        rivaltype,
        other_userid,
        {},
    )

    # Now return updated rival info
    rivals, djinfo = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': djinfo,
    }
コード例 #6
0
def viewuser(userid: int) -> Response:
    # Cast the userID.
    userid = UserID(userid)
    user = g.data.local.user.get_user(userid)

    def __format_card(card: str) -> str:
        try:
            return CardCipher.encode(card)
        except CardCipherException:
            return '????????????????'

    cards = [
        __format_card(card) for card in g.data.local.user.get_cards(userid)
    ]
    arcades = g.data.local.machine.get_all_arcades()
    return render_react(
        'User',
        'admin/user.react.js',
        {
            'user': {
                'email': user.email,
                'username': user.username,
            },
            'cards':
            cards,
            'arcades': {arcade.id: arcade.name
                        for arcade in arcades},
            'balances': {
                arcade.id: g.data.local.user.get_balance(userid, arcade.id)
                for arcade in arcades
            },
            'events': [
                format_event(event)
                for event in g.data.local.network.get_events(
                    userid=userid, event='paseli_transaction')
            ],
        },
        {
            'refresh': url_for('admin_pages.listuser', userid=userid),
            'removeusercard': url_for('admin_pages.removeusercard',
                                      userid=userid),
            'addusercard': url_for('admin_pages.addusercard', userid=userid),
            'updatebalance': url_for('admin_pages.updatebalance',
                                     userid=userid),
            'updateusername': url_for('admin_pages.updateusername',
                                      userid=userid),
            'updateemail': url_for('admin_pages.updateemail', userid=userid),
            'updatepin': url_for('admin_pages.updatepin', userid=userid),
            'updatepassword': url_for('admin_pages.updatepassword',
                                      userid=userid),
        },
    )
コード例 #7
0
ファイル: endpoints.py プロジェクト: Subject38/bemaniutils
def addrival() -> Dict[str, Any]:
    frontend = DDRFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    other_userid = UserID(int(request.get_json()['userid']))
    userid = g.userID

    # Find a slot to put the rival into
    occupied: List[Optional[Link]] = [None] * 10
    for link in g.data.local.user.get_links(GameConstants.DDR, version,
                                            userid):
        if link.type[:7] != 'friend_':
            continue

        pos = int(link.type[7:])
        if pos >= 0 and pos < 10:
            occupied[pos] = link

    # Put rival in the first slot
    newrivalpos = -1
    for i in range(len(occupied)):
        if occupied[i] is None:
            newrivalpos = i
            break

    if newrivalpos == -1:
        raise Exception('No room for another rival!')

    # Add this rival link
    profile = g.data.remote.user.get_profile(GameConstants.DDR, version,
                                             other_userid)
    if profile is None:
        raise Exception('Unable to find profile for rival!')

    g.data.local.user.put_link(
        GameConstants.DDR,
        version,
        userid,
        f'friend_{newrivalpos}',
        other_userid,
        {},
    )

    # Now return updated rival info
    rivals, info = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': info,
    }
コード例 #8
0
def updatepin(userid: int) -> Dict[str, Any]:
    # Cast the userID.
    userid = UserID(userid)

    pin = request.get_json()['pin']
    user = g.data.local.user.get_user(userid)
    # Make sure the user ID is valid
    if user is None:
        raise Exception('Cannot find user to update!')

    if not valid_pin(pin, 'card'):
        raise Exception('Invalid pin, must be exactly 4 digits!')

    # Update the user
    g.data.local.user.update_pin(userid, pin)

    return {}
コード例 #9
0
def updateemail(userid: int) -> Dict[str, Any]:
    # Cast the userID.
    userid = UserID(userid)

    email = request.get_json()['email']
    user = g.data.local.user.get_user(userid)
    # Make sure the user ID is valid
    if user is None:
        raise Exception('Cannot find user to update!')

    if not valid_email(email):
        raise Exception('Invalid email!')

    # Update the user
    user.email = email
    g.data.local.user.put_user(user)

    return {
        'email': email,
    }
コード例 #10
0
def updatebalance(userid: int) -> Dict[str, Any]:
    # Cast the userID.
    userid = UserID(userid)

    credits = request.get_json()['credits']
    user = g.data.local.user.get_user(userid)
    arcades = g.data.local.machine.get_all_arcades()

    # Make sure the user ID is valid
    if user is None:
        raise Exception('Cannot find user to update!')

    # Update balances
    for arcadeid in credits:
        balance = g.data.local.user.update_balance(userid, arcadeid,
                                                   credits[arcadeid])
        if balance is not None:
            g.data.local.network.put_event(
                'paseli_transaction',
                {
                    'delta': credits[arcadeid],
                    'balance': balance,
                    'reason': 'admin adjustment',
                },
                userid=userid,
                arcadeid=arcadeid,
            )

    return {
        'arcades': {arcade.id: arcade.name
                    for arcade in arcades},
        'balances': {
            arcade.id: g.data.local.user.get_balance(userid, arcade.id)
            for arcade in arcades
        },
        'events': [
            format_event(event) for event in g.data.local.network.get_events(
                userid=userid, event='paseli_transaction')
        ],
    }
コード例 #11
0
ファイル: endpoints.py プロジェクト: vangar/bemaniutils
def removerival() -> Dict[str, Any]:
    frontend = SoundVoltexFrontend(g.data, g.config, g.cache)
    version = int(request.get_json()['version'])
    other_userid = UserID(int(request.get_json()['userid']))
    userid = g.userID

    # Remove this rival link
    g.data.local.user.destroy_link(
        GameConstants.SDVX,
        version,
        userid,
        'rival',
        other_userid,
    )

    # Now return updated rival info
    rivals, playerinfo = frontend.get_rivals(userid)

    return {
        'rivals': rivals,
        'players': playerinfo,
    }
コード例 #12
0
def updatepassword(userid: int) -> Dict[str, Any]:
    # Cast the userID.
    userid = UserID(userid)

    new1 = request.get_json()['new1']
    new2 = request.get_json()['new2']
    user = g.data.local.user.get_user(userid)
    # Make sure the user ID is valid
    if user is None:
        raise Exception('Cannot find user to update!')

    # Now, make sure that the passwords match
    if new1 != new2:
        raise Exception('Passwords do not match each other!')

    # Now, make sure passwords are long enough
    if len(new1) < 6:
        raise Exception('Password is not long enough!')

    # Update the user
    g.data.local.user.update_password(userid, new1)

    return {}