Ejemplo n.º 1
0
def user_login(dynamic_id, account_id, verify_key):
    if not account_id or not verify_key:
        send.system_notice(dynamic_id, content.ACCOUNT_NULL)
        return
    func.log_info('[user_login] account_id: {}, verify_key: {}'.format(account_id, verify_key))
    if not UserManager().check_verify_key(account_id, verify_key):
        send.system_notice(dynamic_id, content.LOGIN_VERIFY_FAILED)
        return
    sql = 'select * from {} where `account_id`={}'.format(dbname.DB_ACCOUNT, account_id)
    result = dbexecute.query_one(sql)
    if not result:
        send.system_notice(dynamic_id, content.ACCOUNT_REGISTER_FIRST)
        return
    user = User()
    if not user.init_user(result):
        send.system_notice(dynamic_id, content.LOGIN_USER_INIT_FAILED)
        return
    if user.is_lock():
        _user_lock_tips(user)
        return
    load_play_history(user)

    address = UserManager().get_user_address(account_id)
    user.record_address(address)
    user.dynamic_id = dynamic_id
    UserManager().add_user(user)
    send.login_success(dynamic_id, user)

    user.room_id, user.room_type = 0, 0
    user.record_room_id, user.record_room_type = 0, 0

    contact = i(informations.INFOMATION_TYPE_MARQUEE)
    if contact:
        send.marquee_to_user(dynamic_id, contact)
    else:
        send.marquee_to_user(dynamic_id, content.LOGIN_NOTICE)