phBot Plugins
Search…
Example Plugins
Plugins must be saved inside the Plugins folder otherwise they will not be loaded.

Packet Processing Plugin

This simple plugin will display all packets going to/from Silkroad/Joymax.
1
from phBot import *
2
3
# Called when the bot successfully connects to the game server
4
def connected():
5
pass
6
7
# All packets received from Silkroad will be passed to this function
8
# Returning True will keep the packet and False will not forward it to the game server
9
def handle_silkroad(opcode, data):
10
log('Python: (Silkroad) 0x%02X' % opcode)
11
return True
12
13
# All packets received from Joymax will be passed to this function
14
# Returning True will keep the packet and False will not forward it to the client
15
def handle_joymax(opcode, data):
16
log('Python: (Joymax) 0x%02X' % opcode)
17
return True
18
19
# Called when the character enters the game world
20
def joined_game():
21
pass
22
23
# Called when the character teleports
24
# This function will also be called after the "joined_game" function
25
def teleported():
26
pass
27
28
log('[%s] Loaded' % __name__)
Copied!

GUI Plugin

This next plugin creates a basic GUI on the Plugins tab inside the bot.
1
from phBot import *
2
import QtBind
3
4
gui = QtBind.init(__name__, 'GUI Example')
5
6
QtBind.createLabel(gui, 'Welcome to the GUI example Python script! From here you\'ll be able to add your own GUI to the \'Plugins\' tab inside phBot. Being able to create a UI\nopens up far more possibilies.\n\n- Do not replace the __name__ var in the QtBind.init() call. It is used for passing events to the correct module.\n- Only call QtBind.init() during module load\n- Labels are auto resized after text is set', 10, 10)
7
8
button1 = QtBind.createButton(gui, 'button_clicked', 'Button', 10, 125)
9
checkbox1 = QtBind.createCheckBox(gui, 'checkbox_clicked', 'Check Box', 10, 150)
10
label1 = QtBind.createLabel(gui, 'Label', 10, 175)
11
lineedit1 = QtBind.createLineEdit(gui, 'Text in box', 10, 200, 32, 16)
12
13
QtBind.createLabel(gui, 'The only downside is that you must create the UI by hand.', 10, 250)
14
15
def button_clicked():
16
log('Button clicked')
17
18
def checkbox_clicked(checked):
19
log('Check Box: %s' % checked)
20
21
log('[%s] Loaded' % __name__)
Copied!

Socket Plugin

Sockets are now supported as of v2.0.0. Some "pyd" files were missing (aka DLLs) which caused it to not work previously.
1
from phBot import *
2
import socket
3
4
log('[%s] Loaded' % __name__)
5
6
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
7
s.connect(('www.example.com', 80))
8
s.send('GET / HTTP/1.0\r\nHost: www.example.com\r\n\r\n'.encode('utf-8'))
9
data = s.recv(1024)
10
s.close()
11
12
log('%s' % data)
Copied!
1
[01:21:03] [socket_test] Loaded
2
[01:21:03] b'HTTP/1.0 200 OK\r\nCache-Control: max-age=604800\r\nContent-Type: text/html\r\nDate: Sun, 01 Apr 2018 05:21:01 GMT\r\nEtag: "1541025663+gzip+ident"\r\nExpires: Sun, 08 Apr 2018 05:21:01 GMT\r\nLast-Modified: Fri, 09 Aug 2013 23:54:35 GMT\r\nServer: ECS (phl/9D2C)\r\nVary: Accept-Encoding\r\nX-Cache: HIT\r\nContent-Length: 1270\r\nConnection: close\r\n\r\n<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset="utf-8" />\n <meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style type="text/css">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @med'
Copied!