Exemple #1
0
def chat_packet(context, data):
    player_id = struct.unpack_from('I', data, 0x8)[0]
    message = data[0x1C:].decode(
        'utf-16'
    )  # This is technically improper. Should use the xor byte to check string length (See packetReader)
    if player_id == 0:  # Probably the wrong way to check, but check if a PSO2 client sent this packet
        message = message.rstrip('\0')
        if len(message) > 2 and message.startswith(
                config.globalConfig.get_key('commandPrefix')):
            command = (message.split(' ')[0])[len(
                config.globalConfig.get_key('commandPrefix')
            ):]  # Get the first word (the command) and strip the prefix'
            if command in commands.commandList:
                try:
                    if commands.commandList[command][
                            2] and not config.is_admin(context.myUsername):
                        context.send_crypto_packet(
                            packetFactory.SystemMessagePacket(
                                "[Proxy] {red}You do not have permission to run this command.",
                                0x3).build())
                        return
                    cmd_class = commands.commandList[command][0]
                    cmd_class(message).call_from_client(context)  # Lazy...
                except Exception as e:
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[Proxy] {red}An error occured when trying to run this command.",
                            0x3).build())
                    e = traceback.format_exc()
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[{red}ERROR{def}] %s" % e, 0x3).build())
            elif command in plugin_manager.commands:
                try:
                    if plugin_manager.commands[command][
                            2] and not config.is_admin(context.myUsername):
                        context.send_crypto_packet(
                            packetFactory.SystemMessagePacket(
                                "[Proxy] {red}You do not have permission to run this command.",
                                0x3).build())
                        return
                    cmd_class = plugin_manager.commands[command][0]
                    cmd_class(message).call_from_client(context)
                except Exception as e:
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[Proxy] {red}An error occured when trying to run this command.",
                            0x3).build())
                    e = traceback.format_exc()
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[{red}ERROR{def}] %s" % e, 0x3).build())
            else:
                return data
            return None
        return data
    return data
Exemple #2
0
def chat_packet(context, data):
    player_id = struct.unpack_from('I', data, 0x8)[0]
    message = data[0x1C:].decode(
        'utf-16')  # This is technically improper. Should use the xor byte to check string length (See packetReader)
    if player_id == 0:  # Probably the wrong way to check, but check if a PSO2 client sent this packet
        message = message.rstrip('\0')
        if len(message) > 2 and message.startswith(config.globalConfig['commandPrefix']):
            command = (
                message.split(' ')[0]
            )[
                len(
                    config.globalConfig['commandPrefix']
                ):
            ]
            # Get the first word (the command) and strip the prefix'
            if command in commands.commandList:
                try:
                    if commands.commandList[command][2] and not config.is_admin(context.myUsername):
                        context.send_crypto_packet(packetFactory.SystemMessagePacket(
                            "[Proxy] {red}You do not have permission to run this command.", 0x3).build())
                        return
                    cmd_class = commands.commandList[command][0]
                    cmd_class(message).call_from_client(context)  # Lazy...
                except Exception as e:
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[Proxy] {red}An error occured when trying to run this command.",
                            0x3
                        ).build()
                    )
                    e = traceback.format_exc()
                    context.send_crypto_packet(packetFactory.SystemMessagePacket("[{red}ERROR{def}] %s" % e, 0x3).build())
            elif command in plugin_manager.commands:
                try:
                    if plugin_manager.commands[command][2] and not config.is_admin(context.myUsername):
                        context.send_crypto_packet(packetFactory.SystemMessagePacket(
                            "[Proxy] {red}You do not have permission to run this command.", 0x3).build())
                        return
                    cmd_class = plugin_manager.commands[command][0]
                    cmd_class(message).call_from_client(context)
                except Exception as e:
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[Proxy] {red}An error occured when trying to run this command.",
                            0x3
                        ).build()
                    )
                    e = traceback.format_exc()
                    context.send_crypto_packet(packetFactory.SystemMessagePacket("[{red}ERROR{def}] %s" % e, 0x3).build())
            else:
                return data
            return None
        return data
    return data
Exemple #3
0
 def call_from_console(self):
     if len(self.args.split(" ")) < 2:
         return "[ShipProxy] Invalid usage. (Usage: op <SegaID>)"
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig.get_key('admins')
         current_admins.append(player)
         config.globalConfig.set_key('admins', current_admins)
         return "[ShipProxy] %s is now an admin." % player
     else:
         return "[ShipProxy] %s is already an admin." % player
Exemple #4
0
 def call_from_console(self):
     if len(self.args.split(" ")) < 2:
         return "[PCP Bot] Perintah salah!. (Contoh: op <SegaID>)"
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig['admins']
         current_admins.append(player)
         config.globalConfig.set_key('admins', current_admins)
         return "[PCP Bot] %s Ditambahkan sebagai Admin." % player
     else:
         return "[PCP Bot] %s Sudah menjadi Admin." % player
Exemple #5
0
 def call_from_console(self):
     if len(self.args.split(" ")) < 2:
         return "[PCP Bot] Perintah salah!. (Contoh: deop <SegaID>"
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig['admins']
         current_admins.remove(player)
         config.globalConfig.set_key('admins', current_admins)
         return "[PCP Bot] %s Berhasil dihapus dari admin." % player
     else:
         return "[PCP Bot] %s Bukan Admin." % player
Exemple #6
0
 def call_from_console(self):
     if len(self.args.split(" ")) < 2:
         return "[ShipProxy] Invalid usage. (Usage: op <SegaID>)"
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig.get_key('admins')
         current_admins.append(player)
         config.globalConfig.set_key('admins', current_admins)
         return "[ShipProxy] %s is now an admin." % player
     else:
         return "[ShipProxy] %s is already an admin." % player
Exemple #7
0
 def call_from_console(self):
     if len(self.args.split(" ")) < 2:
         return "[ShipProxy] Invalid usage. (Usage: deop <SegaID>"
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig['admins']
         current_admins.remove(player)
         config.globalConfig.set_key('admins', current_admins)
         return "[ShipProxy] %s is no longer an admin." % player
     else:
         return "[ShipProxy] %s is not an admin." % player
Exemple #8
0
 def call_from_console(self):
     if len(self.args.split(" ")) < 2:
         return "[ShipProxy] Invalid usage. (Usage: deop <SegaID>"
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig['admins']
         current_admins.remove(player)
         config.globalConfig.set_key('admins', current_admins)
         return "[ShipProxy] %s is no longer an admin." % player
     else:
         return "[ShipProxy] %s is not an admin." % player
Exemple #9
0
 def call_from_client(self, client):
     if len(self.args.split(" ")) < 2:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {red}Invalid usage.\n(Usage: %sdeop <SegaID>)" % config.globalConfig.get_key('commandPrefix'),
                                               0x3).build())
         return
     player = self.args.split(" ")[1]
     if config.is_admin(player):
         current_admins = config.globalConfig.get_key('admins')
         current_admins.remove(player)
         config.globalConfig.set_key('admins', current_admins)
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {gre}%s is no longer an admin." % player,
                                               0x3).build())
     else:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {red}%s is not an admin." % player, 0x3).build())
Exemple #10
0
 def call_from_client(self, client):
     if len(self.args.split(" ")) < 2:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {red}Invalid usage.\n(Usage: %sdeop <SegaID>)" % config.globalConfig.get_key('commandPrefix'),
                                               0x3).build())
         return
     player = self.args.split(" ")[1]
     if config.is_admin(player):
         current_admins = config.globalConfig.get_key('admins')
         current_admins.remove(player)
         config.globalConfig.set_key('admins', current_admins)
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {gre}%s is no longer an admin." % player,
                                               0x3).build())
     else:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {red}%s is not an admin." % player, 0x3).build())
Exemple #11
0
 def call_from_client(self, client):
     if len(self.args.split(" ")) < 2:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket(
                 "[Proxy] {red}Invalid usage.\n(Usage: %sop <SegaID>)".
                 format(config.globalConfig['commandPrefix']), 0x3).build())
         return
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig['admins']
         current_admins.append(player)
         config.globalConfig.set_key('admins', current_admins)
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket(
                 "[Proxy] {gre}%s is now an admin." % player, 0x3).build())
     else:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket(
                 "[Proxy] {red}%s is already an admin." % player,
                 0x3).build())
Exemple #12
0
 def call_from_client(self, client):
     if len(self.args.split(" ")) < 2:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket(
                 "[Proxy] {red}Invalid usage.\n(Usage: %sop <SegaID>)".format(
                     config.globalConfig['commandPrefix']
                 ),
                 0x3
             ).build()
         )
         return
     player = self.args.split(" ")[1]
     if not config.is_admin(player):
         current_admins = config.globalConfig['admins']
         current_admins.append(player)
         config.globalConfig.set_key('admins', current_admins)
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {gre}%s is now an admin." % player,
                                               0x3).build())
     else:
         client.send_crypto_packet(
             packetFactory.SystemMessagePacket("[Proxy] {red}%s is already an admin." % player, 0x3).build())
Exemple #13
0
def chat_packet(context, data):
    player_id = struct.unpack_from('I', data, 0x8)[0]
    message = data[0x1C:].decode(
        'utf-16')  # This is technically improper. Should use the xor byte to check string length (See packetReader)
    if player_id == 0:  # Probably the wrong way to check, but check if a PSO2 client sent this packet
        message = message.rstrip('\0')
        if len(message) > 2 and message.startswith(config.globalConfig['commandPrefix']):
            command = (
                message.split(' ')[0]
            )[
                len(
                    config.globalConfig['commandPrefix']
                ):
            ]
            # Get the first word (the command) and strip the prefix'
            if command in commands.commandList:
                try:
                    if commands.commandList[command][2] and not config.is_admin(context.myUsername):
                        context.send_crypto_packet(packetFactory.SystemMessagePacket(
                            "{yel}[PCP Bot] {red}Anda bukan Admin!.", 0x3).build())
                        return
                    cmd_class = commands.commandList[command][0]
                    cmd_class(message).call_from_client(context)  # Lazy...
                except Exception as e:
Exemple #14
0
            client.send_crypto_packet(
<<<<<<< HEAD
                packetFactory.SystemMessagePacket("{yel}[PCP Bot] {red}Perintah salah!.\n{gre}(Contoh: %sop <SegaID>)" % config.globalConfig.get_key('commandPrefix'),
                                                  0x3).build())
=======
                packetFactory.SystemMessagePacket(
                    "[Proxy] {red}Invalid usage.\n(Usage: %sop <SegaID>)".format(
                        config.globalConfig['commandPrefix']
                    ),
                    0x3
                ).build()
            )
>>>>>>> d4a7bf2cacdd48a2cfb02935e664e0f093252d00
            return
        player = self.args.split(" ")[1]
        if not config.is_admin(player):
            current_admins = config.globalConfig['admins']
            current_admins.append(player)
            config.globalConfig.set_key('admins', current_admins)
            client.send_crypto_packet(
                packetFactory.SystemMessagePacket("{yel}[PCP Bot] {gre}%s Ditambahkan sebagai Admin." % player,
                                                  0x3).build())
        else:
            client.send_crypto_packet(
                packetFactory.SystemMessagePacket("{yel}[PCP Bot] {red}%s Sudah menjadi Admin." % player, 0x3).build())

    def call_from_console(self):
        if len(self.args.split(" ")) < 2:
            return "[PCP Bot] Perintah salah!. (Contoh: op <SegaID>)"
        player = self.args.split(" ")[1]
        if not config.is_admin(player):
 async def check(self, args, msg, test=False):
     return await super().check(args, msg, test) and config.is_admin(msg.author)
Exemple #16
0
                except Exception as e:
<<<<<<< HEAD
                    context.send_crypto_packet(packetFactory.SystemMessagePacket("[Proxy] {red}Error ketika mencoba menjalankan perintah ini!.", 0x3).build())
=======
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[Proxy] {red}An error occured when trying to run this command.",
                            0x3
                        ).build()
                    )
>>>>>>> d4a7bf2cacdd48a2cfb02935e664e0f093252d00
                    e = traceback.format_exc()
                    context.send_crypto_packet(packetFactory.SystemMessagePacket("[{red}ERROR{def}] %s" % e, 0x3).build())
            elif command in plugin_manager.commands:
                try:
                    if plugin_manager.commands[command][2] and not config.is_admin(context.myUsername):
                        context.send_crypto_packet(packetFactory.SystemMessagePacket(
                            "{yel}[PCP Bot] {red}Anda bukan Admin!.", 0x3).build())
                        return
                    cmd_class = plugin_manager.commands[command][0]
                    cmd_class(message).call_from_client(context)
                except Exception as e:
                    context.send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "[Proxy] {red}An error occured when trying to run this command.",
                            0x3
                        ).build()
                    )
                    e = traceback.format_exc()
                    context.send_crypto_packet(packetFactory.SystemMessagePacket("[{red}ERROR{def}] %s" % e, 0x3).build())
            else: