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") )
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, "") )
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)
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
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)
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))
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}')
# 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)