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 chatReceive(): global oldMessageCount global chatSetState global qrId sendPath = "http://www.mechayazilim.com/chatReceive.php" character_data = get_character_data() sendingData = {"accountId": character_data["account_id"], "qrId": qrId} try: resp = http.request('GET', sendPath, fields=sendingData, timeout=5) except: log('Chat data could not be received.') pass try: bottingRequestText = json.loads(resp.data.decode('utf-8')) for p in bottingRequestText['androidToPcData']: receiveMessage = p['sendMessage'] whichChat = p['whichChat'] messageCount = p['sendMessageCount'] if (oldMessageCount != messageCount) and (chatSetState == True): if whichChat == "0": phBotChat.Party(receiveMessage) if whichChat == "1": phBotChat.Guild(receiveMessage) oldMessageCount = messageCount chatSetState = True except: pass
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 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 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 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 + ")")