G-Python
G-Earth extension interface for Python.
G-Earth + G-Python allows you to create simple scripts for Habbo and run them on the fly!
Installation
Requires python >= 3.2: https://www.python.org/downloads/
Note: during Windows installation, make sure to select "Add python to PATH" if you want to install G-Python extensions in G-Earth
Then execute the following in a terminal:
python -m pip install g-python
Features
G-Python exports the following modules:
from g_python.gextension import Extension
from g_python.hmessage import Direction, HMessage
from g_python.hpacket import HPacket
from g_python import hparsers
from g_python import htools
- At any point where a
(header)idis required, anameorhashcan be used as well, if G-Earth is connected to Harble API - "hparsers" contains a load of useful parsers
- "htools" contains fully prepared environments for accessing your Inventory, Room Furniture, and Room Users
Usage
Examples are available in the tests/ folder. (highly recommended to check out, since it contains functionality not shown underneath)
This is a template extension with the minimal amount of code to connect with G-Earth:
import sys
from g_python.gextension import Extension
extension_info = {
"title": "Extension stuff",
"description": "g_python test",
"version": "1.0",
"author": "sirjonasxx"
}
ext = Extension(extension_info, sys.argv) # sys.argv are the commandline arguments, for example ['-p', '9092'] (G-Earth's extensions port)
ext.start()
It is possible to register for events:
ext.on_event('double_click', lambda: print('Extension has been clicked'))
ext.on_event('init', lambda: print('Initialized with g-earth'))
ext.on_event('connection_start', lambda: print('Connection started'))
ext.on_event('connection_end', lambda: print('Connection ended'))
Packet injection:
# sending packets to the server
ext.send_to_server(HPacket('RoomUserAction', 1)) # wave using harble api name
ext.send_to_server(HPacket(1843, 1)) # wave using header Id
ext.send_to_server(HPacket('623058bd68a68267114aa8d1ee15b597', 1)) # wave using harble api hash
# sending packets from raw text:
ext.send_to_client('{l}{u:1411}{i:0}{s:"hi"}{i:0}{i:23}{i:0}{i:2}')
ext.send_to_client('[0][0][0][6][5][131][0][0][0][0]')
ext.send_to_client(HPacket.from_string('[0][0][0][6][5][131][0][0][0][0]', ext))
# string methods:
packet = HPacket(1231, "hi", 5, "old", False, True, "lol")
expression = packet.g_expression(ext) # G-Earth's predicted expression
g_string = packet.g_string(ext) # G-Earth's string representation
Intercepting packets:
# intercept & print all packets
def all_packets(message):
packet = message.packet
print(packet.g_string(ext))
ext.intercept(Direction.TO_CLIENT, all_packets)
ext.intercept(Direction.TO_SERVER, all_packets)
# intercept & parse specific packets
def on_walk(message):
(x, y) = message.packet.read('ii')
print("Walking to x:{}, y={}".format(x, y))
def on_speech(message):
(text, color, index) = message.packet.read('sii')
message.is_blocked = (text == 'blocked') # block packet if speech equals "blocked"
print("User said: {}".format(text))
ext.intercept(Direction.TO_SERVER, on_walk, 'RoomUserWalk')
ext.intercept(Direction.TO_SERVER, on_speech, 'RoomUserTalk')
There is much more, such as:
- packet manipulation
- specific settings to be given to an Extension object
hparsers: example intests/user_profile.pyhtools:tests/room_stuff.py&tests/inventory_items.py
Metadata
Release files for g-python 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| g-python-0.1.6.tar.gz | 16.8 kB | Without provenance | Details for g-python-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| g_python-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for g_python-0.1.6-py3-none-any.whl |
Total release size: 35.6 kB
Release files / g-python-0.1.6.tar.gz
| Download URL | g-python-0.1.6.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef699644eb523a468ab308d2d894464c4e27b32dab9bc3b1a193c4a700ed39ae
|
|
BLAKE2b-256 checksum How to use checksums |
efad715e97a85b7292f49051baff569058ad087c5e1e4777dba684753b42ae0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
|
Release files / g_python-0.1.6-py3-none-any.whl
| Download URL | g_python-0.1.6-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
baf5a0a6769c71d8cb88c3979b8d5a8802080fa7dbe747070df8e52420bd48d6
|
|
BLAKE2b-256 checksum How to use checksums |
06ba23ac1c3b542adc1a76e196b0606e8c6f960d56511724581c2ae6a5fbb2f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
|
Security for g-python 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.