Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't client.accept_trade_offer() #352

Closed
NecroBoy opened this issue Jan 28, 2024 · 9 comments
Closed

Can't client.accept_trade_offer() #352

NecroBoy opened this issue Jan 28, 2024 · 9 comments

Comments

@NecroBoy
Copy link

NecroBoy commented Jan 28, 2024

Traceback (most recent call last):
  File "storehouse.py", line 177, in <module>
    main()
  File "storehouse.py", line 117, in main
    client.accept_trade_offer(offer_id)
  File "/usr/local/lib/python3.8/dist-packages/steampy/utils.py", line 23, in func_wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/steampy/client.py", line 256, in accept_trade_offer
    partner = self._fetch_trade_partner_id(trade_offer_id)
  File "/usr/local/lib/python3.8/dist-packages/steampy/client.py", line 281, in _fetch_trade_partner_id
    return text_between(offer_response_text, "var g_ulTradePartnerSteamID = '", "';")
  File "/usr/local/lib/python3.8/dist-packages/steampy/utils.py", line 29, in text_between
    start = text.index(begin) + len(begin)
ValueError: substring not found

offer_id = 6713163374
it's real trade offer id

@NecroBoy NecroBoy reopened this Jan 28, 2024
@NecroBoy
Copy link
Author

For about 2 months I had a bot working that accepted donations with skins, and now it cannot accept trades on its own, although I literally did not change anything in the code, the account authorization data is correct, I can accept trades myself through SDA

@HappyWaffle566
Copy link

HappyWaffle566 commented Jan 28, 2024

That's because valve made an update for steam. Check out other issues and you'll see you're not alone
Use the fix at #351, and then you would probably need to replace the session_id in accept_trade_offer method
Try to replace self._get_session_id() in accept_trade_offer method with self._session.cookies.get_dict()['sessionid']. That's how I fixed buy_item for me

@kivinblue1
Copy link

That's because valve made an update for steam. Check out other issues and you'll see you're not alone Use the fix at #351, and then you would probably need to replace the session_id in accept_trade_offer method Try to replace self._get_session_id() in accept_trade_offer method with self._session.cookies.get_dict()['sessionid']. That's how I fixed buy_item for me

    @login_required
    def make_offer_with_url(
        self,
        items_from_me: List[Asset],
        items_from_them: List[Asset],
        trade_offer_url: str,
        message: str = '',
        case_sensitive: bool = True,
    ) -> dict:
        token = get_key_value_from_url(trade_offer_url, 'token', case_sensitive)
        partner_account_id = get_key_value_from_url(trade_offer_url, 'partner', case_sensitive)
        partner_steam_id = account_id_to_steam_id(partner_account_id)
        offer = self._create_offer_dict(items_from_me, items_from_them)
        session_id = self._session.cookies.get_dict()['sessionid']
        url = f'{SteamUrl.COMMUNITY_URL}/tradeoffer/new/send'
        server_id = 1
        trade_offer_create_params = {'trade_offer_access_token': token}
        params = {
            'sessionid': session_id,
            'serverid': server_id,
            'partner': partner_steam_id,
            'tradeoffermessage': message,
            'json_tradeoffer': json.dumps(offer),
            'captcha': '',
            'trade_offer_create_params': json.dumps(trade_offer_create_params),
        }

        headers = {
            'Referer': f'{SteamUrl.COMMUNITY_URL}{urlparse.urlparse(trade_offer_url).path}',
            'Origin': SteamUrl.COMMUNITY_URL,
        }

        response = self._session.post(url, data=params, headers=headers).json()
        if response.get('needs_mobile_confirmation'):
            response.update(self._confirm_transaction(response['tradeofferid']))

        return response

It doesn't help for make_offer_with_url

@Slava-stack
Copy link

That's because valve made an update for steam. Check out other issues and you'll see you're not alone Use the fix at #351, and then you would probably need to replace the session_id in accept_trade_offer method Try to replace self._get_session_id() in accept_trade_offer method with self._session.cookies.get_dict()['sessionid']. That's how I fixed buy_item for me

But it's literally the same what _get_session_id() has.

@HappyWaffle566
Copy link

HappyWaffle566 commented Jan 28, 2024

I'm not sure then... I remember someone saying that get_dict must be like this "self._session.cookies.get_dict("steamcommunity.com")['sessionid']"
It did not work for me this way (error with 'sessionid'), but you may try it

@kivinblue1
Copy link

I'm not sure then... I remember someone saying that get_dict must be like this "self._session.cookies.get_dict("steamcommunity.com")['sessionid']" It did not work for me this way (error with 'sessionid')

thx god!╰(°▽°)╯╰(°▽°)╯

@Greelzin
Copy link

today I downloaded this module but I can’t automatically confirm exchanges for skins that I sell

Traceback (most recent call last):
  File "C:\Users\veex\PycharmProjects\marketAlerter\main.py", line 64, in <module>
    s._confirm_transaction(6713459635)
  File "C:\Users\veex\PycharmProjects\marketAlerter\.venv\Lib\site-packages\steampy\client.py", line 287, in _confirm_transaction
    return confirmation_executor.send_trade_allow_request(trade_offer_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\veex\PycharmProjects\marketAlerter\.venv\Lib\site-packages\steampy\confirmation.py", line 37, in send_trade_allow_request
    confirmations = self._get_confirmations()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\veex\PycharmProjects\marketAlerter\.venv\Lib\site-packages\steampy\confirmation.py", line 62, in _get_confirmations
    for conf in confirmations_json['conf']:
                ~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'conf'

confirmations_json = {'success': False, 'needauth': True}

@Aarab228
Copy link

today I downloaded this module but I can’t automatically confirm exchanges for skins that I sell


Traceback (most recent call last):

  File "C:\Users\veex\PycharmProjects\marketAlerter\main.py", line 64, in <module>

    s._confirm_transaction(6713459635)

  File "C:\Users\veex\PycharmProjects\marketAlerter\.venv\Lib\site-packages\steampy\client.py", line 287, in _confirm_transaction

    return confirmation_executor.send_trade_allow_request(trade_offer_id)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\veex\PycharmProjects\marketAlerter\.venv\Lib\site-packages\steampy\confirmation.py", line 37, in send_trade_allow_request

    confirmations = self._get_confirmations()

                    ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\veex\PycharmProjects\marketAlerter\.venv\Lib\site-packages\steampy\confirmation.py", line 62, in _get_confirmations

    for conf in confirmations_json['conf']:

                ~~~~~~~~~~~~~~~~~~^^^^^^^^

KeyError: 'conf'

confirmations_json = {'success': False, 'needauth': True}

use login method first

@NecroBoy
Copy link
Author

Fix - #343 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants