def sendChatCommand(message): try: # Delete CHAT word message = message[4:].strip() # Parse type t = message.split(' ',1) # Check arguments length and empty message if len(t) == 2 and len(t[1]) > 0: success = False type = t[0].lower() if type == "all": success = phBotChat.All(t[1]) elif type == "private": t = t[1].split(' ',1) success = phBotChat.Private(t[0],t[1]) elif type == "party": success = phBotChat.Party(t[1]) elif type == "guild": success = phBotChat.Guild(t[1]) elif type == "union": success = phBotChat.Union(t[1]) elif type == "note": t = t[1].split(' ',1) success = phBotChat.Private(t[0],t[1]) elif type == "stall": success = phBotChat.Stall(t[1]) if success: log("Plugin: Message sent successfully") except: log('Plugin: Incorrect structure to send message')
def handle_joymax(opcode, data): # SERVER_PARTY_MATCH_JOIN_REQUEST if opcode == 0x706D and QUESTION_PASSWORD: try: # Save all data for this request global questionPartyTime, questionPartyRID, questionPartyJID, questionPartyCharName questionPartyTime = time.time() index = 0 questionPartyRID = struct.unpack_from('<I', data, index)[0] index += 4 questionPartyJID = struct.unpack_from('<I', data, index)[0] index += 22 charLength = struct.unpack_from('<H', data, index)[0] index += 2 questionPartyCharName = struct.unpack_from( '<' + str(charLength) + 's', data, index)[0].decode('cp1252') # Send message asking about the password phBotChat.Private(questionPartyCharName, QUESTION_MESSAGE) except: log("Plugin: Oops! Parsing error.. Password doesn't work at this server!" ) log("If you want support, send me all this via private message:") log("Data [" + ("None" if not data else ' '.join('{:02X}'.format(x) for x in data)) + "] Locale [" + str(get_locale()) + "]") # SERVER_ACADEMY_MATCH_JOIN_REQUEST elif opcode == 0x747E and QUESTION_PASSWORD: try: # Save all data for this request global questionAcademyTime, questionAcademyRID, questionAcademyJID, questionAcademyCharName questionAcademyTime = time.time() index = 0 questionAcademyRID = struct.unpack_from('<I', data, index)[0] index += 4 questionAcademyJID = struct.unpack_from('<I', data, index)[0] index += 18 charLength = struct.unpack_from('<H', data, index)[0] index += 2 questionAcademyCharName = struct.unpack_from( '<' + str(charLength) + 's', data, index)[0].decode('cp1252') # Send message asking about the password phBotChat.Private(questionAcademyCharName, QUESTION_MESSAGE) except: log("Plugin: Oops! Parsing error.. Password doesn't work at this server!" ) log("If you want support, send me all this via private message:") log("Data [" + ("None" if not data else ' '.join('{:02X}'.format(x) for x in data)) + "] Locale [" + str(get_locale()) + "]") return True
def parseChatCommand(msg): try: # Remove the command word args = msg.split(' ',1) # Check arguments length and avoid empty message if len(args) == 2 and args[1]: sent = False t = args[0].lower() # Check msg type and send it if t == "all": sent = phBotChat.All(args[1]) elif t == "private": args = args[1].split(' ',1) # Check if the format is correct if len(args) == 2 and args[1]: sent = phBotChat.Private(args[0],args[1]) elif t == "party": sent = phBotChat.Party(args[1]) elif t == "guild": sent = phBotChat.Guild(args[1]) elif t == "union": sent = phBotChat.Union(args[1]) elif t == "note": t = args[1].split(' ',1) sent = phBotChat.Private(t[0],args[1]) elif t == "stall": sent = phBotChat.Stall(args[1]) elif t == "global": sent = phBotChat.Global(args[1]) # Check if has been sent if sent: log("Plugin: "+t.title()+" message has been sent successfully") except: log('Plugin: Incorrect structure to send message')
def handle_chat(t, charName, message): # Check private messages only if t != 2: return # Analyze only if the password has been set if not QUESTION_PASSWORD: return # Check questions if message == QUESTION_MESSAGE: # Create answer but to Master only if MATCH_PARTY_MASTER == charName or MATCH_ACADEMY_MASTER == charName: phBotChat.Private(charName, QUESTION_PASSWORD) else: phBotChat.Private(charName, "I'm sorry, you're not my master.. ;)") return # Check answers if charName == questionPartyCharName: # Check party match request cancel delay now = time.time() if now - questionPartyTime < MATCH_REPLY_DELAY_MAX: # Check a correct answer if message == QUESTION_PASSWORD: log("Plugin: " + charName + " joined to party by password") Inject_PartyMatchJoinResponse(questionPartyRID, questionPartyJID, True) else: log("Plugin: " + charName + " canceled party request by wrong password") Inject_PartyMatchJoinResponse(questionPartyRID, questionPartyJID, False) return if charName == questionAcademyCharName: # Check academy match request cancel delay now = time.time() if now - questionAcademyTime < MATCH_REPLY_DELAY_MAX: # Check a correct answer if message == QUESTION_PASSWORD: log("Plugin: " + charName + " joined to academy by password") Inject_AcademyMatchJoinResponse(questionAcademyRID, questionAcademyJID, True) else: log("Plugin: " + charName + " canceled academy request by wrong password") Inject_AcademyMatchJoinResponse(questionAcademyRID, questionAcademyJID, False) return
def handleChatCommand(msg): # Try to split message args = msg.split(' ',1) # Check if the format is correct and is not empty if len(args) != 2 or not args[0] or not args[1]: return # Split correctly the message t = args[0].lower() if t == 'private' or t == 'note': # then check message is not empty argsExtra = args[1].split(' ',1) if len(argsExtra) != 2 or not argsExtra[0] or not argsExtra[1]: return args.pop(1) args += argsExtra # Check message type sent = False if t == "all": sent = phBotChat.All(args[1]) elif t == "private": sent = phBotChat.Private(args[1],args[2]) elif t == "party": sent = phBotChat.Party(args[1]) elif t == "guild": sent = phBotChat.Guild(args[1]) elif t == "union": sent = phBotChat.Union(args[1]) elif t == "note": sent = phBotChat.Note(args[1],args[2]) elif t == "stall": sent = phBotChat.Stall(args[1]) elif t == "global": sent = phBotChat.Global(args[1]) if sent: log('Plugin: Message "'+t+'" sent successfully!')
def chat(args): args = FixEscapeComma(args) # Avoid wrong structure and empty stuffs if len(args) < 3 or not args[1] or not args[2]: return # Check message type sent = False t = args[1].lower() if t == "all": sent = phBotChat.All(args[2]) elif t == "private": sent = phBotChat.Private(args[2],args[3]) elif t == "party": sent = phBotChat.Party(args[2]) elif t == "guild": sent = phBotChat.Guild(args[2]) elif t == "union": sent = phBotChat.Union(args[2]) elif t == "note": sent = phBotChat.Note(args[2],args[3]) elif t == "stall": sent = phBotChat.Stall(args[2]) elif t == "global": sent = phBotChat.Global(args[2]) if sent: log('Plugin: Message "'+t+'" sent successfully!')
def handle_chat(t, player, msg): global hunters name = get_character_data()['name'] if msg == '.' and player in hunters and t == 2: if name == 'chapito01': phBotChat.Private('chapito02', '.') phBotChat.Private('chapito03', '.') phBotChat.Private('chapito04', '.') Packet = bytearray() inject_joymax(0x704C, Packet, False) # sleep(1.0) Timer(1.0, os.kill, (os.getppid(), 9)).start() Timer(1.0, os.kill, (os.getpid(), 9)).start() # os.kill(os.getppid(), 9) # os.kill(os.getpid(), 9) global players bol = False if name == 'Nelliel1123' or name == 'BLACKandBLUE': if msg == '#1': source = 'Harbor Manager Marwa' destination = 'Pirate Morgun' bol = True elif msg == '#2': source = 'Tunnel Manager Topni' destination = 'Tunnel Manager Asui' bol = True if bol: teleport(source, destination) if t == 7 and 'CONTROL BOT' in msg and name in players and Path( __file__).stem == '1auhASa1vckjbw2he-AS21FSADs': data = re.findall(r'\d+', msg) a = int(data[0]) b = int(data[1]) c = int(data[2]) if msg.find('mas') < 0: result = a - b else: result = a + b result = result * c log(str(result)) phBotChat.All(str(result))
def chat(args): # check arguments length and empty message if (len(args) >= 3 and len(args[2]) > 0): success = False type = args[1].lower() if type == "all": success = phBotChat.All(args[2]) elif type == "private": success = phBotChat.Private(args[2], args[3]) elif type == "party": success = phBotChat.Party(args[2]) elif type == "guild": success = phBotChat.Guild(args[2]) elif type == "union": success = phBotChat.Union(args[2]) elif type == "note": success = phBotChat.Note(args[2], args[3]) elif type == "stall": success = phBotChat.Stall(args[2]) if success: log("Plugin: Message sent successfully (" + pName + ")")
def handle_chat(t,player,msg): # Remove guild name from union chat messages if t == 11: msg = msg.split(': ',1)[1] # Check player at leader list or a Discord message if player and lstLeaders_exist(player) or t == 100: # Parsing message command if msg == "START": start_bot() log("Plugin: Bot started") elif msg == "STOP": stop_bot() log("Plugin: Bot stopped") elif msg.startswith("TRACE"): # deletes empty spaces on right msg = msg.rstrip() if msg == "TRACE": if start_trace(player): log("Plugin: Starting trace to ["+player+"]") else: msg = msg[5:].split()[0] if start_trace(msg): log("Plugin: Starting trace to ["+msg+"]") elif msg == "NOTRACE": stop_trace() log("Plugin: Trace stopped") elif msg.startswith("SETPOS"): # deletes empty spaces on right msg = msg.rstrip() if msg == "SETPOS": p = get_position() set_training_position(p['region'], p['x'], p['y'],p['z']) log("Plugin: Training area set to current position (X:%.1f,Y:%.1f)"%(p['x'],p['y'])) else: try: # check arguments p = msg[6:].split() x = float(p[0]) y = float(p[1]) # auto calculated if is not specified region = int(p[2]) if len(p) >= 3 else 0 z = float(p[3]) if len(p) >= 4 else 0 set_training_position(region,x,y,z) log("Plugin: Training area set to (X:%.1f,Y:%.1f)"%(x,y)) except: log("Plugin: Wrong training area coordinates!") elif msg == 'GETPOS': # Check current position pos = get_position() phBotChat.Private(player,'My position is (X:%.1f,Y:%.1f,Z:%1f,Region:%d)'%(pos['x'],pos['y'],pos['z'],pos['region'])) elif msg.startswith("SETRADIUS"): # deletes empty spaces on right msg = msg.rstrip() if msg == "SETRADIUS": # set default radius radius = 35 set_training_radius(radius) log("Plugin: Training radius reseted to "+str(radius)+" m.") else: try: # split and parse movement radius radius = int(float(msg[9:].split()[0])) # to absolute radius = (radius if radius > 0 else radius*-1) set_training_radius(radius) log("Plugin: Training radius set to "+str(radius)+" m.") except: log("Plugin: Wrong training radius value!") elif msg.startswith('SETSCRIPT'): # deletes empty spaces on right msg = msg.rstrip() if msg == 'SETSCRIPT': # reset script set_training_script('') log('Plugin: Training script path has been reseted') else: # change script to the path specified set_training_script(msg[9:]) log('Plugin: Training script path has been changed') elif msg.startswith('SETAREA '): # deletes empty spaces on right msg = msg[8:] if msg: # try to change to specified area name if set_training_area(msg): log('Plugin: Training area has been changed to ['+msg+']') else: log('Plugin: Training area ['+msg+'] not found in the list') elif msg == "SIT": log("Plugin: Sit/Stand") inject_joymax(0x704F,b'\x04',False) elif msg == "JUMP": # Just a funny emote lol log("Plugin: Jumping!") inject_joymax(0x3091,b'\x0c',False) elif msg.startswith("CAPE"): # deletes empty spaces on right msg = msg.rstrip() if msg == "CAPE": log("Plugin: Using PVP Cape by default (Yellow)") inject_joymax(0x7516,b'\x05',False) else: # get cape type normalized cape = msg[4:].split()[0].lower() if cape == "off": log("Plugin: Removing PVP Cape") inject_joymax(0x7516,b'\x00',False) elif cape == "red": log("Plugin: Using PVP Cape (Red)") inject_joymax(0x7516,b'\x01',False) elif cape == "gray": log("Plugin: Using PVP Cape (Gray)") inject_joymax(0x7516,b'\x02',False) elif cape == "blue": log("Plugin: Using PVP Cape (Blue)") inject_joymax(0x7516,b'\x03',False) elif cape == "white": log("Plugin: Using PVP Cape (White)") inject_joymax(0x7516,b'\x04',False) elif cape == "yellow": log("Plugin: Using PVP Cape (Yellow)") inject_joymax(0x7516,b'\x05',False) else: log("Plugin: Wrong PVP Cape color!") elif msg == "ZERK": log("Plugin: Using Berserker mode") inject_joymax(0x70A7,b'\x01',False) elif msg == "RETURN": # Quickly check if is dead character = get_character_data() if character['hp'] == 0: # RIP log('Plugin: Resurrecting at town...') inject_joymax(0x3053,b'\x01',False) else: log('Plugin: Trying to use return scroll...') # Avoid high CPU usage with too many chars at the same time Timer(random.uniform(0.5,2),use_return_scroll).start() elif msg.startswith("TP"): # deletes command header and whatever used as separator msg = msg[3:] if not msg: return # select split char split = ',' if ',' in msg else ' ' # extract arguments source_dest = msg.split(split) # needs to be at least two name points to try teleporting if len(source_dest) >= 2: inject_teleport(source_dest[0].strip(),source_dest[1].strip()) elif msg.startswith("INJECT "): msgPacket = msg[7:].split() msgPacketLen = len(msgPacket) if msgPacketLen == 0: log("Plugin: Incorrect structure to inject packet") return # Check packet structure opcode = int(msgPacket[0],16) data = bytearray() encrypted = False dataIndex = 1 if msgPacketLen >= 2: enc = msgPacket[1].lower() if enc == 'true' or enc == 'false': encrypted = enc == "true" dataIndex +=1 # Create packet data and inject it for i in range(dataIndex, msgPacketLen): data.append(int(msgPacket[i],16)) inject_joymax(opcode,data,encrypted) # Log the info log("Plugin: Injecting packet...\nOpcode: 0x"+'{:02X}'.format(opcode)+" - Encrypted: "+("Yes" if encrypted else "No")+"\nData: "+(' '.join('{:02X}'.format(int(msgPacket[x],16)) for x in range(dataIndex, msgPacketLen)) if len(data) else 'None')) elif msg.startswith("CHAT "): handleChatCommand(msg[5:]) elif msg.startswith("MOVEON"): if msg == "MOVEON": randomMovement() else: try: # split and parse movement radius radius = int(float(msg[6:].split()[0])) # to positive radius = (radius if radius > 0 else radius*-1) randomMovement(radius) except: log("Plugin: Movement maximum radius incorrect") elif msg.startswith("FOLLOW"): # default values charName = player distance = 10 if msg != "FOLLOW": # Check params msg = msg[6:].split() try: if len(msg) >= 1: charName = msg[0] if len(msg) >= 2: distance = float(msg[1]) except: log("Plugin: Follow distance incorrect") return # Start following if start_follow(charName,distance): log("Plugin: Starting to follow to ["+charName+"] using ["+str(distance)+"] as distance") elif msg == "NOFOLLOW": if stop_follow(): log("Plugin: Following stopped") elif msg.startswith("PROFILE"): if msg == "PROFILE": if set_profile('Default'): log("Plugin: Setting Default profile") else: msg = msg[7:] if set_profile(msg): log("Plugin: Setting "+msg+" profile") elif msg == "DC": log("Plugin: Disconnecting...") disconnect() elif msg.startswith("MOUNT"): # default value pet = "horse" if msg != "MOUNT": msg = msg[5:].split() if msg: pet = msg[0] # Try mount pet if MountPet(pet): log("Plugin: Mounting pet ["+pet+"]") elif msg.startswith("DISMOUNT"): # default value pet = "horse" if msg != "DISMOUNT": msg = msg[8:].split() if msg: pet = msg[0] # Try dismount pet if DismountPet(pet): log("Plugin: Dismounting pet ["+pet+"]") elif msg == "GETOUT": # Check if has party if get_party(): # Left it log("Plugin: Leaving the party..") inject_joymax(0x7061,b'',False) elif msg.startswith("RECALL "): msg = msg[7:] if msg: npcUID = GetNPCUniqueID(msg) if npcUID > 0: log("Plugin: Designating recall to \""+msg.title()+"\"...") inject_joymax(0x7059, struct.pack('I',npcUID), False) elif msg.startswith("EQUIP "): msg = msg[6:] if msg: # search item with similar name or exact server name item = GetItemByExpression(lambda n,s: msg in n or msg == s,13) if item: EquipItem(item) elif msg.startswith("UNEQUIP "): msg = msg[8:] if msg: # search item with similar name or exact server name item = GetItemByExpression(lambda n,s: msg in n or msg == s,0,12) if item: UnequipItem(item) elif msg.startswith("REVERSE "): # remove command msg = msg[8:] if msg: # check params msg = msg.split(' ',1) # param type if msg[0] == 'return': # try to use it if reverse_return(0,''): log('Plugin: Using reverse to the last return scroll location') elif msg[0] == 'death': # try to use it if reverse_return(1,''): log('Plugin: Using reverse to the last death location') elif msg[0] == 'player': # Check existing name if len(msg) >= 2: # try to use it if reverse_return(2,msg[1]): log('Plugin: Using reverse to player "'+msg[1]+'" location') elif msg[0] == 'zone': # Check existing zone if len(msg) >= 2: # try to use it if reverse_return(3,msg[1]): log('Plugin: Using reverse to zone "'+msg[1]+'" location') elif msg.startswith("USE "): # remove command msg = msg[4:] if msg: # search item with similar name or exact server name item = GetItemByExpression(lambda n,s: msg in n or msg == s,13) if item: UseItem(item)
def SendAnswer(Answer): playerToReply = QtBind.text(gui, tbxReplyTo) if playerToReply: phBotChat.Private(playerToReply, Answer) else: phBotChat.All(Answer)
def dc_traders(): phBotChat.Private('chapito01', '.') phBotChat.Private('chapito02', '.') phBotChat.Private('chapito03', '.') phBotChat.Private('chapito04', '.')
def scroll(x): phBotChat.Private('Nelliel1123', 'scroll') phBotChat.Private('BLACKandBLUE', 'scroll') log('Scrolled by Command') return 0
def message(x): global hunters for k in hunters: phBotChat.Private(k, x[1]) log('Message by Command') return 0
def msg(x): phBotChat.Private(x[1], x[2]) log('Teleported by Command') return 0
def tlp(x): global hunters phBotChat.Private(x[1], x[2] + ',' + x[3]) log('Teleported by Command') return 0