Get Started - Learn How To Make Your Bot!GuidesCode SnippetsGet methodsPost methodsWeb APIUseful linksList of all currently Free ItemsList of EmotesHighrise Bot SDK Changelog
Β
Β
Β
π Introduction
This is a full guide made by an user on how to start your own Highrise Bot using the Highrise Bot SDK for Python.
Β
Please read these messages!
Make sure to check the Pocket Worlds tutorial on this same matter, there are examples on how to setup the bot on MacOS: Introduction
If youβre not familiar with python or programming in general and wishes to create your own Highrise Bot, I suggest that you first take a few weeks to study programing logics and how Python works. This youtube playlist might help you:
Β
These are all the links for the offical Pocket Worlds guides:
π© Setup
If you are a Replit user feel free to jump to β Setting up the bot
π§ Installing Python 3.11
Go to the Python Downloadβs webpage and select your operating system:
Download Python
The official home of the Python Programming Language
https://www.python.org/downloads/
Click on the link and scroll all the way down of the screen, there you will find the files to install python. If you have no experience installing compilers, use the recommended version:
Download the .exe file, run it and install it. If you are in doubt about the configurations when intalling it, you can search for videos or tutorials detailing a bit more.
If you are using VS Code as coding IDLE also download the Python Extension.
Now you have Python setted up!
πΎ Setting up a Virtual Environment (optional)
This is not mandatory but itβs a good practice and helps to avoid a lot of errors since the highrise-bot-sdk is still on beta testing and every week a new version of it is released.
Itβs not dificult to setup a Vitual Enviroment and this video teaches you how to do it and explains how it works:
Now that you know how to setup a Virtual Enviroment letβs move on.
β Setting up the bot
π½ Downloading the Highrise-Bot-SDK
Now we have an essencial part, the software development kit. This is being created and maintened by the Pocket Words staff and developers of Highrise. You can check the project webpage at:
To install the SDK all you need to do is to open your terminal (if youβre using a Virtual Environment make sure to activate it first)* and use the followind command:
On Replit you will find your terminal as Sheel*
pip install highrise-bot-sdk
This will install the latestes version of the SDK available on PIP.
π€ Creating a bot
To setup a Highrise bot you need to create you bot account and grab his token. Go toΒ https://create.highrise.game/dashboard/credentials/api-keys and log in with the user you intend to be owner of your bot. At the bottom of this page you'll find a New Bot button and from here you're able to create a new bot and retrieve its API access token.
π Retrieving the Room ID
Bots can only be deployed in rooms created by the botβs owner or rooms where the bot has designer and moderator privileges. To retrieve the ID of the room that you want to deploy your bot in, you can visit the room in the Highrise App, navigate to the room info panel on the top right and select "Share this Room". This will generate a link that contains the ID of the room. You'll be able to use this ID in your API/SDK calls to send the bot to that room.
π©βπ» Coding
βΆ Starting the bot
First of all, letβs create a python file to store our bot code. This will be our bot.py file:
Now we need to import the BaseBot class from the SDK module:
from highrise import BaseBot
Create a new class for your bot, inside of it you will be able to declare all the methods you need.
class MyBot(BaseBot): pass
Ok, but for the bot to be able to stablish a session in game we will need to declare a on_start method inside our bot class. To do that we will need to import some more attributes from our SDK.
from highrise.models import SessionMetadata
Now we can start a session for our bot, remember that all methods in the bot have to be asyncronous:
async def on_start(self, session_metadata: SessionMetadata) -> None: pass
Your code should end up like this:
from highrise import BaseBot from highrise.models import SessionMetadata class Mybot(BaseBot): async def on_start(self, session_metadata: SessionMetadata) -> None: pass
All you need to do now is run the script in your terminal by parsing the name of your bot file the name of your bot class, the room_id that you wish the bot to join and the bot token key. Your script will look with something like this:
highrise mybot:MyBot 561a511d56sdf1b6f5716 66s65dd1150f51a66a5c15d580e658qa651da066
Congratulations! Now your bot is on your room!
π Accessing the SDK methods
If you hold the key βctrlβ and click on the imported module using VS Code or Replit, you will be able to see the file where the module was created. There you have access to all the methods that can be used to create your Highrise bot:
β Post and Get methods
Inside the Highrise Module you will be able to see all pre-made methods that you can use in your bot. Those can be divided in Post and Get methods.
Get methods
Get methodsThese are the methods are from the BaseBot class and are used to retrieve information from the game, you need to subclass this class and implement the handlers you want to use. Here is a brief explanation of which everyone of these methods do as itβs said in the module:
Post methods
Post methodsThose are the pre-made methods used to send informations to the Highrise game using your bot.
π Bot example
Now that we learned how to setup our bot, letβs create an example. We are gonna to make a bot that greets everyone that joins the room.
To do that we need to know who joined the room at the time it happens, for that we can use the on_user_join method from our Get methods, donβt forget to import the User, Position and AnchorPosition classes from highrise.models (you can also use a
star import
to make it import automatically all needed classes from the file, it can be used as from highrise.models import *
):async def on_user_join(self, user: User, position: Position | AnchorPosition) -> None: pass
Now we can use the chat method to make the bot to send a greeting message to the user that joined the room, the code will look like this:
from highrise import * from highrise.models import * class Mybot(BaseBot): async def on_start(self, session_metadata: SessionMetadata) -> None: pass async def on_user_join(self, user: User, position: Position | AnchorPosition) -> None: await self.highrise.chat(f"Welcome {user.username}!")
Β
Now all you need to do is to run your code and all users that join the room will receive a welcome message!
To run the code you can use the following command on your terminal (Shell for Replit users) inside of the folder that contains your bot file.py:
highrise <bot file name>:<bot class name> <room id> <bot token>
If youβre looking for a template to remove the need of using your terminal command line each time you want to start your bot, make sure to check:
βΆοΈ Run.py Template