Skip to content

Conversation

@Day4Date
Copy link

@Day4Date Day4Date commented Dec 17, 2025

Added Python-Plugins Support.
Added an API to use with Python.
Added Python.Runtime.dll and \Python\PyRuntime to Dependencies folder.
Python.Runtime.dll needs to be copied to \Build\Data\Plugins.
\Python\PyRuntime needs to be copied to \Build\Data

To create Plugins, import the RSBot Module ("from rsbot import *")
A .pyi file will always be created so your ide supports autocomplete

Small Example

from RSBot import *

NAME = "Example Plugin"
DESCRIPTION = "Simple RSBot Plugin as an example"
AUTHOR = "DayDate"
VERSION = "1.0.0"

gui = GUI(NAME)
x = 40
y = 20

gui.TextBox("This is a simple RSBot plugin template.", x, y,100,20)
y += 30
a = gui.CheckBox("This is a checkbox", x, y,50,30)
y += 40
gui.ComboBox("This is a combo box", x, y,100,30)
y += 40
lv = gui.ListBox("listview",x+100, y,100,200)
lv.add_item("Item 1")
lv.add_item("Item 2")
lv.add_item("Item 3")
y += 40
gui.Label("This is a label", x, y,100,20)
y += 30
def on_click():
log(get_inventory())

def on_click_2():
log(get_character())

gui.Button("Start Bot", x, y,100,30,handler=on_click)
y += 40
gui.Button("Data", x, y,100,30,handler=on_click_2)

RSBot Python API Documentation

This document outlines the available modules and functions exposed to the Python scripting engine within RSBot.


1. Core Module (core)

General bot control, logging, and networking functions.

Functions

  • log(*args): Logs messages to the bot's main console. Accepts multiple arguments.
  • start_bot(): Starts the bot logic. Returns True if successful.
  • stop_bot(): Stops the bot logic. Returns True if successful.
  • send_server(opcode, data): Injects a raw packet to be sent to the server.

2. Entity Module (entity)

Provides access to game objects like the player, monsters, NPCs, and skills.

Functions

  • get_character(): Returns a dictionary with player data (Name, HP, MP, Level, EXP, etc.).
  • get_position(): Returns a dictionary with x, y, z, and region.
  • get_monsters(): Returns a list of dictionaries for all monsters in range.
  • get_npcs(): Returns a list of dictionaries for all NPCs in range.
  • get_skills(): Returns a list of all learned skills.
  • get_active_skills(): Returns a list of currently active buffs/skills.
  • get_mastery(): Returns the player's mastery levels.

3. Inventory Module (inventory)

Manages items, inventory, storage, and gold.

Functions

  • get_inventory(): Returns current gold and lists of items (Inventory, Equipped, Avatar).
  • get_storage(): Returns items in the personal storage.
  • get_guild_storage(): Returns items in the guild storage.
  • get_pet_storage(): Returns items in the active pet's inventory.

4. Training Module (training)

Manages the bot's training area and script settings.

Functions

  • set_training_area(name): Loads a saved training area by its name.
  • set_training_position(x, y, region, radius): Manually defines the training spot.
  • get_training_position(): Returns the currently active training coordinates.

5. Quest Module (quest)

Provides access to the quest log.

Functions

  • get_quests(): Returns a list of active quests, including status, NPCs, and objectives.

6. GUI Module (gui)

Allows the creation of custom tabs and visual controls within the RSBot interface.

Initialization

  • GUI(plugin_name): Initializes a new tab page. Returns a GUI instance.

Common Control Methods

  • set_visible(bool): Shows or hides the control.
  • set_enabled(bool): Enables or disables the control.
  • set_text(string): Sets the display text.
  • move_position(x, y): Moves the control.

Controls

  • Label(text, x, y, width, height): Simple text display.
  • Button(text, x, y, width, height, handler): Clickable button.
  • CheckBox(text, x, y, width, height, handler): Checkbox with get_checked() and set_checked().
  • TextBox(text, x, y, width, height, handler): Input field with get_text() and set_text_value().
  • ComboBox(text, x, y, width, height, handler): Dropdown menu.
  • ListBox(text, x, y, width, height, handler): Scrollable list.

7. Config Module (config)

Helper functions for file paths.

Functions

  • get_config_dir(): Returns the path to the User directory.
  • get_config_path(): Returns the path to the character-specific config.
  • get_log_dir(): Returns the path to the log directory.

@kis1yi
Copy link
Contributor

kis1yi commented Dec 17, 2025

Great. Needed following functions to make useful plugins:
handle_server(opcode, data) — All packets received from the server are passed to this function.
handle_client(opcode, data) — All packets received from the game client are passed to this function.

And in addition to send_server(opcode, data):
send_client(opcode, data, encrypted) — Sends a packet to client.

@Day4Date
Copy link
Author

Day4Date commented Dec 17, 2025

I have that already implemented but forgot to mention them!
Will do an better Documentation soon and change the send function to have also an encrypt parameter.
Also something like scriptcommand is on the todo. Would be nice to call functions from scripts.

Handle Packets

  • on_packet_from_client(opcode,data): All packets received from the game client are passed to this function.
  • on_packet_from_server(opcode,data): All packets received from the server are passed to this function.

Send Packets

  • send_server(opcode,data): Sends a packet to server

Example to log all Packets

def on_packet_from_client(opcode,data):
log("Received packet from client: "+str(opcode)+" Data: "+str(data))

def on_packet_from_server(opcode,data):
log("Received packet from server: "+str(opcode)+" Data: "+str(data))

Example Plugin

packet_control.py

@Egezenn
Copy link
Contributor

Egezenn commented Dec 17, 2025

It'd be better to pull the necessary embeddable Python runtime at build time. This PR currently introduces ~40MB of binary files that we don't need source controlled via git.

@Day4Date
Copy link
Author

You are right. Would be better to change that!

Day4Date and others added 4 commits December 22, 2025 14:46
Added Python download during build;
Updated Python to 3.13.11
Added Pythonnet to RSBot Project
@Day4Date
Copy link
Author

The necessary embeddable Python runtime will now be pulled at build time.
Added Pythonnet to RSBot Project.
Added send_client API-Function.

I hope this now better :)

Directory.CreateDirectory(pluginDir);
}

string[] pythonFiles = Directory.GetFiles(pluginDir, "*.py", SearchOption.TopDirectoryOnly);
Copy link
Contributor

@Egezenn Egezenn Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is okay for simple one file plugins but to house more complex plugins a better structure could be:

Data/Python/Plugins
├── Example-Plugin-1
│   ├── lib/...
│   ├── file.py
│   └── __main__.py (where the main gui file goes)
└── Example-Plugin-2
    └── __main__.py

public string InternalName => "RSBot.Python";

/// <inheritdoc />
public string DisplayName => "Plugins";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to name this as "Python Plugins" or "PyPlugins" as we already have this

Image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name to PyPlugins

public string DisplayName => "Plugins";

/// <inheritdoc />
public bool DisplayAsTab => true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be toggleable from the Menubar > Plugins, similiar to how sidebar works but for this tab specifically.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to the same menu as the sidebar. You can now toggle it on and off and save the settings.


<Exec Command="powershell -Command &quot;Invoke-WebRequest -Uri '$(PythonZipUrl)' -OutFile '$(PythonRuntimeDir)python_temp.zip'&quot;" Condition="!Exists('$(PythonExePath)')" />

<Exec Command="powershell -Command &quot;Expand-Archive -Path '$(PythonRuntimeDir)python_temp.zip' -DestinationPath '$(PythonRuntimeDir)' -Force&quot;" Condition="!Exists('$(PythonExePath)')" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this was an issue on my end or a small misconfiguration but the archive was unable to extracted even though it was downloaded correctly. I extracted manually and it worked.

I took a build via the build script, maybe there's something going wrong with that ¯\_(ツ)_/¯

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it a few times and different machines and worked fine for me so far

@@ -0,0 +1,257 @@
using System.Drawing;
using System.Windows.Forms;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better if we at least had SDUI components used here, theming breaks.

For the plugins aswell but I think they can be hackily postponed if there is a way to push a global bg&fg color for those tabs so that it properly renders in light mode for the time being.

Image Image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the Windows Controls to the available SDUI Controls.
Somehow the SDUI ListView is somehow bugged for me?
Maybe someone else can change the DataGridView to the SDUI ListView for the Plugins

@Egezenn
Copy link
Contributor

Egezenn commented Dec 27, 2025

Looks good, just needs a few touch ups. Thanks for your work!

DayDate added 2 commits January 1, 2026 12:06
Changed UI-Controls to SDUI Controls where possible
PyPlugins can now be toggled on and off just like the sidebar
@Day4Date
Copy link
Author

Day4Date commented Jan 4, 2026

I think this should be fine for now? Anything else i should change?

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

Successfully merging this pull request may close these issues.

3 participants