Skip to main content

G-Earth extension interface for Python.

Project description

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

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)id is required, a name or hash can 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 in tests/user_profile.py
  • htools: tests/room_stuff.py & tests/inventory_items.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

g-python-0.1.4.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

g_python-0.1.4-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file g-python-0.1.4.tar.gz.

File metadata

  • Download URL: g-python-0.1.4.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.5

File hashes

Hashes for g-python-0.1.4.tar.gz
Algorithm Hash digest
SHA256 69bc6f30e8af276e03855a14014e309e680a022ae3370453497309a16bbd3d6c
MD5 560428c7125a3296b7ad05e72a1ee6c0
BLAKE2b-256 2d5e3b1138da034e164c11db53c91299b4121b1f68e9b22903c7bb42df6e0c5b

See more details on using hashes here.

File details

Details for the file g_python-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: g_python-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.5

File hashes

Hashes for g_python-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a94d2e1dcc1ba476097981f76ec7f0dbc93a004a5647ab8c75889f4fdbb2ad45
MD5 309cd1baf25417c833a5c66afb98432c
BLAKE2b-256 ca3d5e6cb2f4560b5ff41a5086e1d9593ecdc13f012c326109a9622f4e59cd6a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page