[DuckTools] DuckAPI - A phBot-like Python plugins system
Discussion on [DuckTools] DuckAPI - A phBot-like Python plugins system within the SRO Hacks, Bots, Cheats & Exploits forum part of the Silkroad Online category.
[DuckTools] DuckAPI - A phBot-like Python plugins system
[DuckTools] DuckAPI - By Abdo Proff
Hey guys, hope you're all chillin'. I'm Abdo Proff, from Cairo, Egypt, and I'm here to present something that I hope will be useful and interesting for the community.
I’ve created a DLL that works directly with the client — it's not a bot and doesn't require any bot to function.
It provides the same Python plugins system that phBot offers.
This is not a Silkroad Proxy or a game bot that you need to connect to so it can handle client/server packets. What does that mean? It means you can use it to do things you dream of — even in protected environments like Maxiguard or VsroPlus macro servers.
That also means we can use it standalone, whether launching the game via its original launcher or something like EDX Loader. And we can still use it alongside sBot or mBot — but now with a phBot-like Python plugin system.
The great thing about the APIs I built is that they're almost identical to phBot's. As you’ll see in the first video, I took the xPacketTool plugin from phBot and just changed the library names as follows...
Instead of
Code:
from phbot import *
I used
Code:
from duckapi import *
And instead of
Code:
import qtbind
I used
Code:
import duckui
And the rest of the code literally stays the same.
This first video explains the required files to run the API, and shows how similar the function names and signatures are to phBot’s.
Not all phBot APIs are available in this version of DuckAPI. If you want to reuse a phBot plugin like I did in the video, make sure all used APIs exist in DuckAPI.
I'll list all currently available DuckAPI APIs below the videos.
First Video
What is DuckAPI, required files, API similarity with phBot, and how to adapt existing phBot plugins.
First, here are the files you’ll need to put inside your game folder:
1. `DuckAPI.dll` — this is my DLL that you'll inject into `sro_client.exe`.
2. `python38.dll` — the Python runtime DLL required to run the interpreter.
3. The Python environment directories inside the `python38` folder located in the `plugins` folder.
I'll post download links for the files and the injector after the tutorial section.
Second Video
Duck Smart Trace Plugin — A better phBot trace plugin
In this video, I show how to use the Duck Smart Trace plugin for caravans or other purposes:
1. You must enable the “Show Unique ID” checkbox in the plugin.
2. The CMD must send `duckcmd` in All Chat to fetch the CMD’s Unique ID so it appears in the plugin (as shown in the video).
3. Click “Add CMD” to select the Unique ID of the CMD after the message is sent.
4. Then click Start or Stop Trace as needed.
The cool part — something even phBot plugins can’t handle — is that if the CMD presses in the sky or moves using keyboard arrows, phBot goes nuts and traces incorrectly. But here, the plugin uses game trace to continue tracing the CMD, until they press somewhere on ground again.
Note: The Unique ID changes every time the player logs out and back in.
So if the CMD disconnects or closes the game, he must send `duckcmd` again, and you must recheck the box to get the new ID.
This plugin is encrypted, as shown in the video.
This is another feature that makes DuckAPI different from phBot — you can encrypt plugin code if you want to sell or share it without exposing your Python source or allowing edits.
Third Video
DuckControl (aka xControl Plugin) — Extend command handling and add new actions
In this video, we discuss the DuckControl plugin, which is similar to phBot’s xControl plugin.
The idea is to designate certain players as “Leaders.” When those players send certain chat messages in-game, specific actions are automatically performed.
Q1 Command — Auto-teleport from ferry when “Q1” is typed
You’ve probably seen people spam “Q1” or “Q2” during caravans — those are chat commands used with plugins like phBot’s xControl to auto-teleport.
Here I show how to replicate the same behavior using a DuckAPI plugin.
handle_chat:
1- `t` = chat type (private, party, all chat, etc)
2- `player` = sender’s name (string)
3- `msg` = received message (string)
inject_joymax:
1- `opcode` = the action's hex opcode (e.g. 0x7074, 0x7021)
2- `data` = Python bytes object containing packet data
3- `encrypted` = whether the packet is encrypted (True/False)
Since we don’t have access to media.pk2 data or helper APIs like phBot, we need to use xPacketTool and enable “Show Client Packets” to observe opcodes and data sent by the game client for the actions we want to replicate via chat command.
1- To implement the `q1` teleport command — like teleporting from Jangan to Donwhang — I capture the opcode and data the client sends to the server when I manually teleport.
2- Then, in the plugin code under `handle_chat`, I add a condition that checks if the message came from a leader and whether the message equals "q1".
3- Here’s the current code:
Code:
def handle_chat(t, player, msg):
if t in [2, 4, 5, 7]:
if is_leader(player):
info(f"Message from leader {player}: {msg}")
I add the condition for `q1`, and it becomes:
Code:
def handle_chat(t, player, msg):
if t in [2, 4, 5, 7]:
if is_leader(player):
if msg == "q1":
inject_joymax(0x705A, b"\x1A\x01\x00\x00\x02\x04\x00\x00\x00", False)
info(f"Message from leader {player}: {msg}")
This tells the plugin: if a message from a leader equals "Q1", send the same opcode and packet the client would use when manually teleporting.
Same goes for any other command you wish to add to replicate a specific client action.
To edit a plugin, you’ll need an IDE like VSCode or Visual Studio 2019/2022.
You *could* use something like Notepad++ or even basic Notepad — but that would be painful
To use this, you can register a new account to use this on
Discord registration has been disabled to comply with the forum's rules.
I literally made this entire project in a few days without enough testing, so I am expecting errors to come up, and hopefully get reported and solved ASAP.
duckui.init(plugin_name, tab_name) - Creates a new tab for your plugin and returns tab ID
duckui.createButton(tab_id, callback_name, text, x, y) - Creates a clickable button with specified callback function
duckui.createCheckBox(tab_id, callback_name, text, x, y) - Creates a checkbox with optional callback function
duckui.createLabel(tab_id, text, x, y) - Creates a static text label for display
duckui.createLineEdit(tab_id, text, x, y, width, height) - Creates a text input field
duckui.createList(tab_id, x, y, width, height) - Creates a list widget for displaying multiple items
duckui.createCombobox(tab_id, x, y, width, height) - Creates a dropdown selection widget
Widget Manipulation
duckui.setText(tab_id, widget_id, text) - Sets the text content of labels, line edits, or comboboxes
duckui.text(tab_id, widget_id) - Gets the current text content from widgets
duckui.setChecked(tab_id, widget_id, state) - Sets the checked state of checkboxes
duckui.isChecked(tab_id, widget_id) - Returns whether a checkbox is currently checked
duckui.move(tab_id, widget_id, x, y) - Moves a widget to new coordinates
duckui.destroy(tab_id, widget_id) - Permanently removes a widget from the interface
List & Combobox Operations
duckui.clear(tab_id, widget_id) - Removes all items from lists, comboboxes, or clears text fields
duckui.append(tab_id, widget_id, text) - Adds a new item to the end of lists or comboboxes
duckui.remove(tab_id, widget_id, text) - Removes the first occurrence of specified text from lists/comboboxes
duckui.removeAt(tab_id, widget_id, index) - Removes item at specific index from lists/comboboxes
duckui.currentIndex(tab_id, widget_id) - Returns the currently selected index in lists/comboboxes
duckui.getItems(tab_id, widget_id) - Returns all items from lists or comboboxes as a Python list
duckapi.log(message) - Logs an informational message to the application log
duckapi.debug(message) - Logs a debug-level message for development purposes
duckapi.info(message) - Logs an informational message (same as log)
duckapi.warning(message) - Logs a warning message for non-critical issues
duckapi.error(message) - Logs an error message for critical problems
Packet Injection
duckapi.inject_silkroad(opcode, data, encrypted) - Sends a packet to the Silkroad client
duckapi.inject_joymax(opcode, data, encrypted) - Sends a packet to the Joymax server
Utility Functions
duckapi.get_config_dir() - Returns the path to the plugin configuration directory
Plugin Event Handlers
Required Functions (implement in your plugin)
handle_joymax(opcode, data) - Called when receiving packets from server (return True to pass through, False to block)
handle_silkroad(opcode, data) - Called when sending packets to server (return True to pass through, False to block)
handle_chat(chat_type, player, message) - Called when chat messages are received
event_loop() - Called automatically every 500ms for continuous background tasks
This can be quite useless without the game database.
I recommend you to use just to generate such database in sqlite3 format, easy to use in python.
Jellyyyy, dude your xbot code already helped me a lot and I am already using it as a reference in my C++ media contents extraction. I am just using a different method since it's a DLL, I am calling the gfxfilemanager's IFileManager's functions to read from the media at runtime and extract the needed data.
I am just using a different method since it's a DLL, I am calling the gfxfilemanager's IFileManager's functions to read from the media at runtime and extract the needed data.
Yeh, it's a way but not recommended, in such case it's better to retrieve the data from the .
Parsing/analyze all the files can take a while on start and I know it can be annoying reading all those files from C++ (I did it before). I'm just giving as option xBot to people here start making some advance addons, xBot already extracts a pretty good database in sqlite3.
the tool is good but that guy is childish af I asked him 2 questions on the discord server then for no reason he kicked me from it
1- the tool is not working with me on windows 10 lite host is virtual machine
he said it's because of vmprotect
2- are you willing to add get_monsters() later to the tool?
after a respectful response from me on both mints after I found myself banned
the tool is good but that guy is childish af I asked him 2 questions on the discord server then for no reason he kicked me from it
1- the tool is not working with me on windows 10 lite host is virtual machine
he said it's because of vmprotect
2- are you willing to add get_monsters() later to the tool?
after a respectful response from me on both mints after I found myself banned
It's literally my server, my code, and my thread. I don't see a reason you should feel that I am childish if I decide that I don't like how our interaction went and that I don't want you in my server. It's pretty simple really.
I am glad you enjoyed the tool for the few minutes you were allowed to use it, though.
It's literally my server, my code, and my thread. I don't see a reason you should feel that I am childish if I decide that I don't like how our interaction went and that I don't want you in my server. It's pretty simple really.
I am glad you enjoyed the tool for the few minutes you were allowed to use it, though.
I only now see that you have to create an account on your Discord to use the program. Unfortunately I see an indirect advertisement for your Discord server and the section “SRO Hacks, Bots, Cheats & Exploits” would not be the right one. Would you like to change that, alternatively I would close your thread.
I only now see that you have to create an account on your Discord to use the program. Unfortunately I see an indirect advertisement for your Discord server and the section “SRO Hacks, Bots, Cheats & Exploits” would not be the right one. Would you like to change that, alternatively I would close your thread.
I am okay with that. I have to link this to my server since I need to disable certain packets in specific editions to prevent creating plugins that could ruin gameplay uncontrollably, such as plugins that automatically attack other players and so on. So, it can be moved to whichever other section it belongs to, closed, or completely removed.
I created it and wanted to share it with people but in a way that still allows me to control its use, in case it ruins servers, especially with it being as powerful as it is, handling packets in macro vsroplus and maxiguard servers, which server owners pay well enough to have, especially that I am working on adding more APIs that people at some point can use to create a working bot in non-bot servers.
But if it's against the rules, then it is what it is.
phBot Manager , fully managing for phBot 08/26/2023 - SRO Hacks, Bots, Cheats & Exploits - 89 Replies phBot Manager never connect to internet
supports iSRO and rSRO
download it only from here or
Official Site www.phbot-manager.com
phBot Manager 2.8 for phBot v10.4.3
* Updated for phBot v10.4.3
Help For phBot Plugins 08/01/2021 - Silkroad Online - 1 Replies Hello everyone,
Today i want help with plugins from you . I follow most plugins on phbot forums. Especially JellyBlitz's. I noticed that they are attacking with bot characters in the arena and fgw recently. I also noticed that some characters attack when certain characters are attacked, and some attack as soon as a character attacks. So I think they are doing this using Jelly Bitz's xTargetSupport plugin. Because xTargetSupport can do exactly that, but I know it only targets. They must be...
Help For phBot Plugins 09/28/2020 - SRO Coding Corner - 0 Replies Hello everyone,
Today i want help with plugins from you :). I follow most plugins on phbot forums. Especially JellyBlitz's. I noticed that they are attacking with bot characters in the arena and fgw recently. I also noticed that some characters attack when certain characters are attacked, and some attack as soon as a character attacks. So I think they are doing this using Jelly Bitz's xTargetSupport plugin. Because xTargetSupport can do exactly that, but I know it only targets. They must be...
PhBot, server issues like sbot? cause they both dont work 10/04/2010 - Silkroad Online - 4 Replies PhBot website doesn't load either just like sbot, and no clue why it doesnt work.
Anyone else has this issue with phbot? or any news when it gets back online, post here please.