Beispiel #1
0
    def on_get_profile(self, hmessage: HMessage) -> None:
        if hmessage.packet.read_int() == self._bot_settings.id:
            bot = self._bot_settings

            packet = HPacket(
                "ExtendedProfile",
                bot.id,
                bot.username,
                bot.figure,
                bot.motto,
                bot.creation_date,
                bot.achievement_score,
                bot.friend_count,
                bot.is_friend,
                bot.is_requested_friend,
                bot.is_online,
                0,
                -255,
                True,
            )

            self._extension.send_to_client(packet)

            self._extension.send_to_client(
                HPacket("HabboUserBadges", bot.id, 1, 1, "BOT")
            )
Beispiel #2
0
    def send(self, message: str, as_invite: bool = False) -> None:
        if as_invite:
            self._extension.send_to_client(
                HPacket("RoomInvite", self._bot_settings.id, message)
            )

            return None

        self._extension.send_to_client(
            HPacket("NewConsole", self._bot_settings.id, message, 0, "")
        )
Beispiel #3
0
    def create_chat(self) -> None:
        bot = self._bot_settings

        packet = HPacket(
            "FriendListUpdate",
            0,
            1,
            False,
            False,
            "",
            bot.id,
            bot.username,
            bot.gender,
            bot.is_online,
            bot.is_following_allowed,
            bot.figure,
            bot.category_id,
            bot.motto,
            0,
            bot.is_persisted_message_user,
            bot.is_vip_member,
            bot.is_pocket_habbo_user,
            65537,
        )

        self._extension.send_to_client(packet)
Beispiel #4
0
        def __init__(self, packet: HPacket):
            self.search_code, self.text, self.action_allowed, self.is_force_closed, self.view_mode = packet.read(
                'ssiBi')

            self.rooms = [
                self.HNavigatorRoom(packet) for _ in range(packet.read_int())
            ]
Beispiel #5
0
def on_walk(message):
    # packet = message.packet
    # x = packet.read_int()
    # y = packet.read_int()
    (x, y) = message.packet.read('ii')
    print("Walking to x:{}, y={}".format(x, y))

    # send packet to server from HPacket() object
    # ext.send_to_server(HPacket(1843, 1)) # wave
    ext.send_to_server(HPacket('RoomUserAction', 1))  # wave

    # 2 ways of sending packets from string representations
    ext.send_to_client('{l}{u:1411}{i:0}{s:"hi"}{i:0}{i:23}{i:0}{i:2}')
    ext.send_to_client(
        HPacket.from_string(
            '[0][0][0][26][5][131][0][0][0][0][0][2]ho[0][0][0][0][0][0][0][3][0][0][0][0][0][0][0][2]',
            ext))
Beispiel #6
0
def on_walk(message):
    # packet = message.packet
    # x = packet.read_int()
    # y = packet.read_int()
    (x, y) = message.packet.read('ii')
    print("Walking to x:{}, y={}".format(x, y))

    # send packet to server from HPacket() object
    # ext.send_to_server(HPacket(1843, 1)) # wave
    ext.send_to_server(HPacket('AvatarExpression', 1))  # wave
Beispiel #7
0
    def walk(self, x, y):
        d = self.doubleSpinBox.value()
        sleep(d)
        self.extension.send_to_server(HPacket(self.RoomUserWalk, x, y))
        self.Message(f"Walk to : {x} ; {y} with {d} delay")

        if self.autoStop:
            self.FallingFurni = False
            self.checkBox_1.setChecked(False)
            self.isWired = False
            self.checkBox_2.setChecked(False)
Beispiel #8
0
            def __init__(self, packet: HPacket):
                self.flat_id, self.room_name, self.owner_id, self.owner_name, door_mode_id, self.user_count,\
                self.max_user_count, self.description, self.trade_mode, self.score, self.ranking, self.category_id\
                = packet.read('isisiiisiiii')

                self.door_mode = HDoorMode(door_mode_id)

                self.tags = [
                    packet.read_string() for _ in range(packet.read_int())
                ]

                multiUse = packet.read_int()

                if (multiUse & 1) > 0:
                    self.official_room_pic_ref = packet.read_string()

                if (multiUse & 2) > 0:
                    self.group_id, self.group_name, self.group_badge_code = packet.read(
                        'iss')

                if (multiUse & 4) > 0:
                    self.room_ad_name, self.room_ad_description, self.room_ad_expires_in_min = packet.read(
                        'ssi')

                self.show_owner = (multiUse & 8) > 0
                self.allow_pets = (multiUse & 16) > 0
                self.display_room_entry_ad = (multiUse & 32) > 0
Beispiel #9
0
    def __init__(self, packet: HPacket):
        self.id, self.name, self.motto, self.figure_id, self.index, x, y, z, facing_id, entity_type_id = \
            packet.read('isssiiisii')
        self.tile = HPoint(x, y, float(z))
        self.headFacing = HDirection(facing_id)
        self.bodyFacing = HDirection(facing_id)
        self.entity_type = HEntityType(entity_type_id)

        self.stuff = []
        if self.entity_type == HEntityType.HABBO:
            self.gender = packet.read_string()
            self.stuff.extend(packet.read('ii'))
            self.favorite_group = packet.read_string()
            self.stuff.extend(packet.read('siB'))
        elif self.entity_type == HEntityType.PET:
            self.stuff.extend(packet.read('iisiBBBBBBis'))
        elif self.entity_type == HEntityType.BOT:
            self.stuff.extend(packet.read('sis'))
            self.stuff.append(
                [packet.read_short() for _ in range(packet.read_int())])
Beispiel #10
0
from time import sleep

from g_python.gextension import Extension
from g_python.hmessage import Direction, HMessage
from g_python.hpacket import HPacket

extension_info = {
    "title": "Packets example",
    "description": "g_python test",
    "version": "1.0",
    "author": "sirjonasxx"
}

ext = Extension(extension_info, sys.argv)
ext.start()
ext.send_to_server(HPacket("Chat", "hi", 1, 1))


def on_walk(message):
    # packet = message.packet
    # x = packet.read_int()
    # y = packet.read_int()
    (x, y) = message.packet.read('ii')
    print("Walking to x:{}, y={}".format(x, y))

    # send packet to server from HPacket() object
    # ext.send_to_server(HPacket(1843, 1)) # wave
    ext.send_to_server(HPacket('AvatarExpression', 1))  # wave

    # # 2 ways of sending packets from string representations
    # ext.send_to_client('{l}{u:1411}{i:0}{s:"hi"}{i:0}{i:23}{i:0}{i:2}')
Beispiel #11
0

# intercepted async, you can't modify it
def on_speech(message):
    sleep(4)
    (text, color, index) = message.packet.read('sii')
    print("User said: {}, 4 seconds ago".format(text))


# intercepted async, but you can modify it
def on_shout(message: HMessage):
    sleep(2)
    (text, color) = message.packet.read('si')
    message.is_blocked = (text == 'blocked'
                          )  # block packet if speech equals "blocked"
    print("User shouted: {}, 2 seconds ago".format(text))
    message.packet.replace_string(6, "G - " + text)


ext.intercept(Direction.TO_SERVER, on_walk, 'RoomUserWalk')
ext.intercept(Direction.TO_SERVER, on_speech, 'RoomUserTalk', mode='async')
ext.intercept(Direction.TO_SERVER,
              on_shout,
              'RoomUserShout',
              mode='async_modify')

packet = HPacket(1231, "hi", 5, "old", False, True, "lol")
result = packet.g_expression(
    ext)  # get G-Earth's predicted expression for the packet above
print(result)
Beispiel #12
0
    def __init__(self, packet: HPacket):
        self.search_code, self.filtering_data = packet.read('ss')

        self.blocks = [
            self.HNavigatorBlock(packet) for _ in range(packet.read_int())
        ]
Beispiel #13
0
 def __init__(self, packet: HPacket):
     self.index, x, y, z, head, body, self.action = packet.read('iiisiis')
     self.tile = get_tile_from_coords(x, y, z)
     self.headFacing = HDirection(head)
     self.bodyFacing = HDirection(body)
     self.nextTile = self.predict_next_tile()