Python SDK v23.1.b014 released

Bot SDK Update to version 23.1.0b14

Hello everyone, we have an exciting update for you. The bot SDK has been updated to version 23.1.0b14. As usual, you can install it using pip:

pip install highrise-bot-sdk==23.1.0b14

This version adds two major new features:

  1. Bots can now access the Highrise Public API along with helper functions.
  2. Bots can purchase and apply room boosts and voice tokens to their current room using either bot funds or owner funds.

Public API Access Using Bots SDK

It’s now possible to load data directly from the Highrise Public API into bots. The helper object is now available as self.webapi and helper data classes can be imported from the highrise.models_webapi file.

This is a traditional REST API that does not use the existing WebSocket, so these methods can be used even if the bot is not connected. This makes them ideal for use in the before_start hook.

For example, to get information about a user using the webapi, you can use:

from highrise.models_webapi import User as WebapiUser
user:WebapiUser = await self.webapi.get_user(user.id)

Full reference for the new webapi can be found in the following post:
[Link]

Below are the methods you can use:

  • self.webapi.get_user(): Fetches a specific user by id.
  • self.webapi.get_users(): Retrieves a list of users.
  • self.webapi.get_room(): Fetches a specific room by id.
  • self.webapi.get_rooms(): Retrieves a list of rooms.
  • self.webapi.get_post(): Fetches a specific post by id.
  • self.webapi.get_posts(): Retrieves a list of posts.

Bots Can Add Room Boost and Voice Time to Room

Bots can now use two methods to interact with the shop in order to buy room_boost_token or room_voice_token and apply them immediately to a room.

To purchase a token bot can select the payment method, either from the bot’s wallet or its owner’s wallet. Room boosts can also specify the number of boosts up to 10.

Here’s an example of adding voice time and room boosts:

res = await self.highrise.buy_voice_time("bot_wallet_priority")
res = await self.highrise.buy_room_boost("bot_wallet_priority", 1)

Both methods can take the following values for the first parameter (payment method):

  • “bot_wallet_only” - will only attempt to buy a token from the bot’s wallet and fail if there are not sufficient resources.
  • “bot_wallet_priority” - will first attempt to buy a token from the bot, and if the bot has insufficient resources it will attempt to buy from the owner afterwards.
  • “user_wallet_only” - will only attempt to buy a token from the owner’s wallet and fail if there are not sufficient resources.

Both methods return some strings that indicate if the method was completed. They are:

  • “success” - token bought and applied successfully.
  • “insufficient_funds” - the bot/user don’t have enough funds to afford a token.
  • “only_token_bought” - in rare cases, the bot may succeed in buying a token but fail to apply it. In this case, the token remains in the bot/user inventory and will be used next time. No token is lost this way.

Please note that the bot can now see the number of tokens it has by calling:
get_wallet(self).

This was a big update to the bot SDK, tailored towards making the bots more capable and interactive within the Highrise environment. The update allows the bots to do much more in terms of interactions by leveraging the Public API. Moreover, with the added ability to purchase boosts and apply them to rooms, bots can now enhance room features making them more engaging and dynamic.

Remember, if you run into any issues or have any questions regarding this update, we’re here to help! Contact us in Discord channel.

We hope you’ll find these improvements useful and we’re excited to see how you’ll make use of them!

Happy coding!

7 Likes

Hey guys, a hotfix for this version was released

pip install highrise-bot-sdk==23.1.0b15

Sorry for confusion, you should install this version.

Just a quick note. To apply boosts or extend voice time, the bot’s owner must have the necessary permissions to carry out these actions in a room. For instance, if you try to add voice time to a room where you are neither the owner nor a moderator, only a token will be purchased. The room will not receive the boost nor will the voice time be extended.

For the webapi.get_user request:

  • In the ‘User’ object the ‘last_online_in’ parameter must have the type ‘DateTime | None’ instead of ‘int | None’, which causes an error:

  • The ‘badge’ parameter does not come in the server response:

1 Like

Hey, thank you for reporting the issue, there has been an update to webapi just before SDK was released so there is some data miss-match. We will do another update to the SDK as soon as possible to address this issue.

1 Like

I have released hotfix version of SDK v23.1.0b16,
you can install it in a standard way using pip install highrise-bot-sdk==23.1.0b16 This fixes issue with user model for webapi, not a high priority upgrade.
Happy coding!

2 Likes