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:
- Bots can now access the Highrise Public API along with helper functions.
- 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!