示例#1
0
def loadDefaultConfig():
    # Clear data
    QtBind.setText(gui, tbxChannels, "")
    QtBind.clear(gui, lstChannels)

    QtBind.setText(gui, tbxKey, JELLYDIX_KEY)
    QtBind.setText(gui, tbxUrl, JELLYDIX_URL)

    QtBind.setChecked(gui, cbxAddTimeStamp, False)

    # Reset triggers
    for name, cmbx in cmbxTriggers.items():
        QtBind.clear(gui, cmbx)
        QtBind.append(gui, cmbx, "")

    QtBind.setChecked(gui, cbxEvtMessage_global_filter, False)
    QtBind.setText(gui, tbxEvtMessage_global_filter, " Filter by message")

    QtBind.setChecked(gui, cbxEvtMessage_uniqueSpawn_filter, False)
    QtBind.setText(gui, tbxEvtMessage_uniqueSpawn_filter, " Filter by name")
    QtBind.setChecked(gui, cbxEvtMessage_uniqueKilled_filter, False)
    QtBind.setText(gui, tbxEvtMessage_uniqueKilled_filter, " Filter by name")

    for name, cmbx in cmbxTriggers_.items():
        QtBind.clear(gui_, cmbx)
        QtBind.append(gui_, cmbx, "")

    QtBind.setChecked(gui_, cbxEvtPick_name_filter, False)
    QtBind.setText(gui_, tbxEvtPick_name_filter, " Filter by name")
    QtBind.setChecked(gui_, cbxEvtPick_servername_filter, False)
    QtBind.setText(gui_, tbxEvtPick_servername_filter, " Filter by servername")
示例#2
0
def loadDefaultConfig():
	# Clear data
	QtBind.setText(gui,tbxChannels,"")
	QtBind.clear(gui,lstChannels)

	QtBind.setText(gui,tbxToken,'')
	QtBind.setText(gui,tbxWebsite,'https://jellydix.ddns.net')
	
	# Reset triggers
	for name,cmbx in cmbxTriggers.items():
		QtBind.clear(gui,cmbx)
		QtBind.append(gui,cmbx,"")

	QtBind.setChecked(gui,cbxEvtMessage_global_filter,False)
	QtBind.setText(gui,tbxEvtMessage_global_filter," Filter by message")

	QtBind.setChecked(gui,cbxEvtMessage_uniqueSpawn_filter,False)
	QtBind.setText(gui,tbxEvtMessage_uniqueSpawn_filter," Filter by name")
	QtBind.setChecked(gui,cbxEvtMessage_uniqueKilled_filter,False)
	QtBind.setText(gui,tbxEvtMessage_uniqueKilled_filter," Filter by name")

	for name,cmbx in cmbxTriggers_.items():
		QtBind.clear(gui_,cmbx)
		QtBind.append(gui_,cmbx,"")

	QtBind.setChecked(gui_,cbxEvtPick_name_filter,False)
	QtBind.setText(gui_,tbxEvtPick_name_filter," Filter by name")
	QtBind.setChecked(gui_,cbxEvtPick_servername_filter,False)
	QtBind.setText(gui_,tbxEvtPick_servername_filter," Filter by servername")

	QtBind.setChecked(gui_,cbxAddTimestamp,False)
	QtBind.setChecked(gui_,cbxDiscord_read_messages,False)
	QtBind.setText(gui_,tbxDiscord_guild_id," Discord Server ID...")
	QtBind.setChecked(gui_,cbxDiscord_read_all,False)
def btnCheck_clicked():
    # List all files around
    files = os.listdir()
    for filename in files:
        # Check only python files
        if (re.search("[.]py", filename)):
            with open(filename, "r") as f:
                pyCode = str(f.read())
                # Read file and check his version
                if re.search("\npVersion = [0-9.'\"]*", pyCode):
                    pyVersion = re.search("\npVersion = ([0-9a-zA-Z.'\"]*)",
                                          pyCode)[1][1:-1]
                    pyName = re.search("\npName = ([0-9a-zA-Z'\"]*)",
                                       pyCode)[1][1:-1]
                    pyDesc = pyVersion
                    if pyName and pyName + ".py" != filename:
                        pyDesc = pyName + " " + pyDesc
                    # It's up to the plugin if the url is wrong :P
                    pyUrl = pyCode.find("\npUrl = ")
                    pyMsg = "Updated"
                    if pyUrl != -1:
                        pyUrl = pyCode[pyUrl + 9:].split('\n')[0][:-1]
                        pyNewVersion = getVersion(pyUrl)
                        if pyNewVersion and compareVersion(
                                pyVersion, pyNewVersion):
                            pyMsg = "Update available (v" + pyNewVersion + ") [" + pyUrl + "]"
                    else:
                        pyMsg = "Cannot be update: URL not found"
                    QtBind.append(gui, lstPlugins,
                                  filename + " (" + pyDesc + ") - " + pyMsg)
示例#4
0
def getMobCount():
    # Clear
    QtBind.clear(gui, lstMonsterCounter)
    QtBind.append(gui, lstMonsterCounter, 'Name (Type)')  # Header
    count = 0
    # Check all mob around
    monsters = get_monsters()
    if monsters:
        for key, mob in monsters.items():
            # Ignore if this mob type is found
            if ListContains(str(mob['type']), lstIgnore):
                continue
            # Only count setup
            if len(lstOnlyCount) > 0:
                # If is not in only count, skip it
                if not ListContains(str(mob['type']), lstOnlyCount):
                    continue
            # Ignore mob names
            elif QtBind_ItemsContains(mob['name'], lstMobs):
                continue
            # Adding GUI for a complete UX
            QtBind.append(gui, lstMonsterCounter,
                          mob['name'] + ' (' + str(mob['type']) + ')')
            count += 1
    return count
示例#5
0
def btnAddMob_clicked():
	text = QtBind.text(gui,tbxMobs)
	if text and not QtBind_ItemsContains(text,lstMobs):
		QtBind.append(gui,lstMobs,text)
		QtBind.setText(gui,tbxMobs,"")
		saveConfig("lstMobs",QtBind.getItems(gui,lstMobs))
		log('Plugin: Monster added ['+text+']')
def btnUpdate_clicked():
    py = QtBind.text(gui, lstPlugins)
    if py and "- Update available" in py:
        # Get url from GUI
        pyUrl = py[py.find('[') + 1:py.find(']')]
        try:
            req = urllib.request.Request(
                pyUrl,
                headers={
                    'User-Agent':
                    "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0"
                })
            with urllib.request.urlopen(req) as w:
                pyCode = str(w.read().decode("utf-8"))
                filename = py[:py.find(' ')]
                with open(filename + "a", "w+") as f:
                    f.write(pyCode)
                QtBind.remove(gui, lstPlugins, py)
                pyVersion = py[py.rfind('(') + 1:py.rfind(')')]
                QtBind.append(
                    gui, lstPlugins,
                    filename + " (" + pyVersion + ") - Updated recently")
                log('Plugin: Your plugin has been successfully updated')
        except:
            log("Plugin: Error updating your plugin. Try again later..")
示例#7
0
def getMobCount(radius):
    # Clear
    QtBind.clear(gui, lstMonsterCounter)
    QtBind.append(gui, lstMonsterCounter, 'Name (Type)')  # Header
    count = 0
    # Get my position to calc radius
    p = get_position() if radius != None else None
    # Check all mob around
    monsters = get_monsters()
    if monsters:
        for key, mob in monsters.items():
            # Ignore if this mob type is found
            if mob['type'] in lstIgnore:
                continue
            # Only count setup
            if len(lstOnlyCount) > 0:
                # If is not in only count, skip it
                if not mob['type'] in lstOnlyCount:
                    continue
            # Ignore mob names
            elif ListContains(mob['name'], lstMobsData):
                continue
            # Checking radius
            if radius != None:
                if round(GetDistance(p['x'], p['y'], mob['x'], mob['y']),
                         2) > radius:
                    continue
            # Adding GUI for a complete UX
            QtBind.append(gui, lstMonsterCounter,
                          mob['name'] + ' (' + str(mob['type']) + ')')
            count += 1
    return count
示例#8
0
def loadConfigs():
	if os.path.exists(getConfig()):
		data = {}
		with open(getConfig(),"r") as f:
			data = json.load(f)
		# Check to load config
		if "lstMobs" in data:
			for d in data["lstMobs"]:
				QtBind.append(gui,lstMobs,d)
		if "lstIgnore" in data:
			global lstIgnore
			lstIgnore = data["lstIgnore"]
			for i in range(len(lstIgnore)):
				if lstIgnore[i] == '8':
					QtBind.setChecked(gui,cbxIgnoreUnique,True)
				elif lstIgnore[i] == '7':
					QtBind.setChecked(gui,cbxIgnoreElite,True)
				elif lstIgnore[i] == '6':
					QtBind.setChecked(gui,cbxIgnoreStrong,True)
				elif lstIgnore[i] == '5':
					QtBind.setChecked(gui,cbxIgnoreTitan,True)
				elif lstIgnore[i] == '4':
					QtBind.setChecked(gui,cbxIgnoreGiant,True)
				elif lstIgnore[i] == '1':
					QtBind.setChecked(gui,cbxIgnoreChampion,True)
				elif lstIgnore[i] == '0':
					QtBind.setChecked(gui,cbxIgnoreGeneral,True)
				elif lstIgnore[i] == '16':
					QtBind.setChecked(gui,cbxIgnoreParty,True)
				elif lstIgnore[i] == '17':
					QtBind.setChecked(gui,cbxIgnoreChampionParty,True)
				elif lstIgnore[i] == '20':
					QtBind.setChecked(gui,cbxIgnoreGiantParty,True)
		if "lstOnlyCount" in data:
			global lstOnlyCount
			lstOnlyCount = data["lstOnlyCount"]
			for i in range(len(lstOnlyCount)):
				if lstOnlyCount[i] == '8':
					QtBind.setChecked(gui,cbxOnlyCountUnique,True)
				elif lstOnlyCount[i] == '7':
					QtBind.setChecked(gui,cbxOnlyCountElite,True)
				elif lstOnlyCount[i] == '6':
					QtBind.setChecked(gui,cbxOnlyCountStrong,True)
				elif lstOnlyCount[i] == '5':
					QtBind.setChecked(gui,cbxOnlyCountTitan,True)
				elif lstOnlyCount[i] == '4':
					QtBind.setChecked(gui,cbxOnlyCountGiant,True)
				elif lstOnlyCount[i] == '1':
					QtBind.setChecked(gui,cbxOnlyCountChampion,True)
				elif lstOnlyCount[i] == '0':
					QtBind.setChecked(gui,cbxOnlyCountGeneral,True)
				elif lstOnlyCount[i] == '16':
					QtBind.setChecked(gui,cbxOnlyCountParty,True)
				elif lstOnlyCount[i] == '17':
					QtBind.setChecked(gui,cbxOnlyCountChampionParty,True)
				elif lstOnlyCount[i] == '20':
					QtBind.setChecked(gui,cbxOnlyCountGiantParty,True)
示例#9
0
def loadConfig():
    loadDefaultConfig()
    if os.path.exists(getConfig()):
        data = {}
        with open(getConfig(), "r") as f:
            data = json.load(f)
        # Check to load config
        if "lstMobs" in data:
            for d in data["lstMobs"]:
                QtBind.append(gui, lstMobs, d)
        if "lstAvoid" in data:
            lstAvoid = data["lstAvoid"]
            for i in range(len(lstAvoid)):
                if lstAvoid[i] == '8':
                    QtBind.setChecked(gui, cbxAvoidUnique, True)
                elif lstAvoid[i] == '7':
                    QtBind.setChecked(gui, cbxAvoidElite, True)
                elif lstAvoid[i] == '6':
                    QtBind.setChecked(gui, cbxAvoidStrong, True)
                elif lstAvoid[i] == '5':
                    QtBind.setChecked(gui, cbxAvoidTitan, True)
                elif lstAvoid[i] == '4':
                    QtBind.setChecked(gui, cbxAvoidGiant, True)
                elif lstAvoid[i] == '1':
                    QtBind.setChecked(gui, cbxAvoidChampion, True)
                elif lstAvoid[i] == '0':
                    QtBind.setChecked(gui, cbxAvoidGeneral, True)
                elif lstAvoid[i] == '16':
                    QtBind.setChecked(gui, cbxAvoidParty, True)
                elif lstAvoid[i] == '17':
                    QtBind.setChecked(gui, cbxAvoidChampionParty, True)
                elif lstAvoid[i] == '20':
                    QtBind.setChecked(gui, cbxAvoidGiantParty, True)
        if "lstOnly" in data:
            lstOnly = data["lstOnly"]
            for i in range(len(lstOnly)):
                if lstOnly[i] == '8':
                    QtBind.setChecked(gui, cbxOnlyUnique, True)
                elif lstOnly[i] == '7':
                    QtBind.setChecked(gui, cbxOnlyElite, True)
                elif lstOnly[i] == '6':
                    QtBind.setChecked(gui, cbxOnlyStrong, True)
                elif lstOnly[i] == '5':
                    QtBind.setChecked(gui, cbxOnlyTitan, True)
                elif lstOnly[i] == '4':
                    QtBind.setChecked(gui, cbxOnlyGiant, True)
                elif lstOnly[i] == '1':
                    QtBind.setChecked(gui, cbxOnlyChampion, True)
                elif lstOnly[i] == '0':
                    QtBind.setChecked(gui, cbxOnlyGeneral, True)
                elif lstOnly[i] == '16':
                    QtBind.setChecked(gui, cbxOnlyParty, True)
                elif lstOnly[i] == '17':
                    QtBind.setChecked(gui, cbxOnlyChampionParty, True)
                elif lstOnly[i] == '20':
                    QtBind.setChecked(gui, cbxOnlyGiantParty, True)
示例#10
0
def loadConfigs():
	loadDefaultConfig()
	# Check config exists to load
	if os.path.exists(getConfig()):
		data = {}
		with open(getConfig(),"r") as f:
			data = json.load(f)
		if "Leaders" in data:
			for nickname in data["Leaders"]:
				QtBind.append(gui,lstLeaders,nickname)
示例#11
0
		def translate_thread():
			lang = get_lang(QtBind.text(gui,cmbxTranslateOutgoingLang))
			newMsg = translate_text(msg,lang)
			# Encoding message
			newPacket = p + struct.pack('<H',len(newMsg))
			newPacket += newMsg.encode(encoding) if encoding == 'cp1252' else newMsg.encode(encoding)[2:]
			inject_joymax(opcode,newPacket,False)
			# Log translation
			text = '> ['+datetime.now().strftime('%H:%M:%S')+'] '+get_chat_type(chatType)+':'+newMsg
			QtBind.append(gui,lstTranslatedMessages,text)
示例#12
0
def gui_qlist():
	a = 0
	while True:
		if a == get_qa('l',0):
			break
		b = get_qa("q",a)
		if not gui_check_qlist(b):
			QtBind.append(gui,qlist,b)
		a += 1
	return False
示例#13
0
def loadConfigs():
    loadDefaultConfig()
    if isJoined():
        # Check config exists to load
        if os.path.exists(getConfig()):
            data = {}
            with open(getConfig(), "r") as f:
                data = json.load(f)
            if "Leaders" in data:
                for charName in data["Leaders"]:
                    QtBind.append(gui, lvwLeaders, charName)
示例#14
0
def btnAddMob_clicked():
    global lstMobsData
    # Check name
    text = QtBind.text(gui, tbxMobs)
    if text and not ListContains(text, lstMobsData):
        lstMobsData.append(text)
        # Add visually
        QtBind.append(gui, lstMobs, text)
        QtBind.setText(gui, tbxMobs, "")
        saveConfigs()
        log('Plugin: Monster added [' + text + ']')
示例#15
0
def btnAddMob_clicked():
	# Selecting mob from the scan list
	selectedIndex = QtBind.currentIndex(gui,lstMobs)
	if selectedIndex >= 0:
		selectedMob = lstMobsData[selectedIndex]

		if not ListAutoSelectMob_Contains(selectedMob):
			QtBind.append(gui,lstAutoSelectMobs,selectedMob['name']+" ("+getMobType(selectedMob['type'])+")")

			global lstAutoSelectMobsData
			lstAutoSelectMobsData.append(selectedMob)
			saveConfigs()
示例#16
0
def btnAddExchanger_clicked():
    # Check in game data
    if character_data:
        player = QtBind.text(gui, tbxExchangerName)
        # Player nickname it's not empty and not added
        if player and not string_in_list(player,
                                         QtBind.getItems(gui, lvwExchangers)):
            QtBind.append(gui, lvwExchangers, player)
            save_configs()
            # saved successfully
            QtBind.setText(gui, tbxExchangerName, "")
            log('Plugin: Exchanger added [' + player + ']')
示例#17
0
def btnCheck_clicked():
    QtBind.clear(gui, lvwPlugins)
    # List all files from Plugins folder
    pyFolder = GetPluginsFolder()
    files = os.listdir(pyFolder)
    # Load plugins data
    global lstPluginsData
    for filename in files:
        # Check only python files
        if filename.endswith(".py"):
            pyFile = pyFolder + "\\" + filename
            with open(pyFile, "r") as f:
                pyCode = str(f.read())
                # Read file and check his version
                if re.search("\npVersion = [0-9a-zA-Z.'\"]*", pyCode):
                    # Extract version
                    pyVersion = re.search("\npVersion = ([0-9a-zA-Z.'\"]*)",
                                          pyCode).group(0)[13:-1]
                    # Extract name if has one
                    pyName = filename[:-3]
                    if re.search("\npName = ([0-9a-zA-Z'\"]*)", pyCode):
                        pyName = re.search("\npName = ([0-9a-zA-Z'\"]*)",
                                           pyCode).group(0)[10:-1]
                    # Check if has url
                    pyUrl = pyCode.find("\npUrl = ")
                    # Show basic plugin info
                    pyInfo = filename + " (" + pyName + " v" + pyVersion + ") - "

                    # Getting all required to update the plugin
                    pData = {}
                    pData['canUpdate'] = False
                    # Save all data if has url
                    if pyUrl != -1:
                        # Extract the rest url, it's up to the plugin if the url is wrong :P
                        pyUrl = pyCode[pyUrl + 9:].split('\n')[0][:-1]
                        pyNewVersion = getVersion(pyUrl)
                        # Check if version is found and can be updated
                        if pyNewVersion and compareVersion(
                                pyVersion, pyNewVersion):
                            # Save data to update
                            pData['canUpdate'] = True
                            pData['url'] = pyUrl
                            pData['filename'] = filename
                            pData['pName'] = pyName
                            # Notify update
                            pyInfo += "Update available (v" + pyNewVersion + ")"
                        else:
                            pyInfo += "Updated"
                    else:
                        pyInfo += "Cannot be updated: URL not found"
                    # Add info to GUi
                    QtBind.append(gui, lvwPlugins, pyInfo)
                    lstPluginsData.append(pData)
示例#18
0
def loadConfigs():
	loadDefaultConfig()
	# Check config exists to load
	if os.path.exists(getConfig()):
		data = {}
		with open(getConfig(),"r") as f:
			data = json.load(f)
		# Load mob list
		if "Mobs" in data:
			global lstAutoSelectMobsData
			lstAutoSelectMobsData = data["Mobs"]
			for mob in data["Mobs"]:
				QtBind.append(gui,lstAutoSelectMobs,mob['name']+" ("+getMobType(mob['type'])+")")
示例#19
0
def UpdateTriviaData():
    # Clean it
    global trivia_data
    trivia_data = []
    QtBind.clear(gui, lstTriviaData)
    # Check the trivia data
    if os.path.exists(getTriviaPath()):
        # Try to Load trivia file
        with open(getTriviaPath(), "r") as f:
            trivia_data = json.load(f)
        # Load the listview
        for trivia in trivia_data:
            QtBind.append(gui, lstTriviaData,
                          'Q: "' + trivia['q'] + '" A: "' + trivia['a'] + '"')
示例#20
0
def btnRefreshMobs_clicked():
	# Clear the list
	QtBind.clear(gui,lstMobs)
	global lstMobsData
	lstMobsData = []

	# Get all mobs near to you
	mobs = get_monsters()
	if mobs:
		# add all kind of mobs actually found
		for uid, mob in mobs.items():
			# Add mob
			QtBind.append(gui,lstMobs,mob['name']+" ("+getMobType(mob['type'])+") "+(' - HP ('+str(mob['hp'])+'/'+str(mob['max_hp'])+')' if showHP else '')+" - UID ["+str(uid)+']')
			lstMobsData.append(mob)
示例#21
0
def loadConfigs():
    loadDefaultConfig()
    if os.path.exists(getConfig()):
        data = {}
        with open(getConfig(), "r") as f:
            data = json.load(f)
        # load the opcodes list
        if "Opcodes" in data:
            for opcode in data["Opcodes"]:
                QtBind.append(gui, lstOpcodes, opcode)
        # config radiobutton if is saved
        if "DontShow" in data:
            global cbxDontShow_checked
            cbxDontShow_checked = data["DontShow"]
            QtBind.setChecked(gui, cbxDontShow, data["DontShow"])
            QtBind.setChecked(gui, cbxOnlyShow, not data["DontShow"])
示例#22
0
def load_configs():
    load_default_config()
    if is_joined():
        # Check config exists to load
        if os.path.exists(get_config()):
            data = {}
            with open(get_config(), "r") as f:
                data = json.load(f)
            # Load data
            if "AcceptAll" in data and data['AcceptAll']:
                QtBind.setChecked(gui, cbxAcceptAll, True)
            if "ReplyAccept" in data and not data['ReplyAccept']:
                QtBind.setChecked(gui, cbxReplyAccept, False)
            if "ReplyApprove" in data and not data['ReplyApprove']:
                QtBind.setChecked(gui, cbxReplyApprove, False)
            if "Exchangers" in data:
                for charName in data["Exchangers"]:
                    QtBind.append(gui, lvwExchangers, charName)
示例#23
0
def btnAddItem_clicked():
    selectedIndex = QtBind.currentIndex(gui, lvwItems)
    # skip header
    if selectedIndex >= 1:
        item = lvwItemsData[selectedIndex - 1]

        # Check it's the same genre
        isMale = IsMale(character_data['model'])
        if '_M_' in item[1] or '_W_' in item[1]:
            if (isMale and not '_M_' in item[1]) or (not isMale
                                                     and not '_W_' in item[1]):
                log('Plugin: Selected item is not matching your character genre!'
                    )
                return
        else:
            # Special case - some servers using _F and _M instead
            if (item[1].endswith('_F') and isMale) or (item[1].endswith('_M')
                                                       and not isMale):
                log('Plugin: Selected item is not matching your character genre!'
                    )
                return

        # Select the list
        view = None
        glist = None
        t = item[3]
        if t == 1:
            view = lvwHatItems
            glist = 'lvwHatItemsData'
        elif t == 2:
            view = lvwDressItems
            glist = 'lvwDressItemsData'
        elif t == 3:
            view = lvwAccesoryItems
            glist = 'lvwAccesoryItemsData'
        elif t == 4:
            view = lvwFlagItems
            glist = 'lvwFlagItemsData'

        glist = globals()[glist]
        # Add if doesn't exist
        if not item[0] in glist:
            glist.append(item[0])
            QtBind.append(gui, view, item[2])
示例#24
0
def btnAddOpcode_clicked():
    # parse to HEX or fail trying
    opcode = int(QtBind.text(gui, tbxOpcodes), 16)
    if opcode and not lstOpcodes_exists(opcode):
        data = {}
        if os.path.exists(getConfig()):
            with open(getConfig(), "r") as f:
                data = json.load(f)
        # Add or Create opcode into the list
        if "Opcodes" in data:
            data["Opcodes"].append('0x{:02X}'.format(opcode))
        else:
            data["Opcodes"] = ['0x{:02X}'.format(opcode)]
        with open(getConfig(), "w") as f:
            f.write(json.dumps(data, indent=4, sort_keys=True))
        QtBind.append(gui, lstOpcodes, '0x{:02X}'.format(opcode))
        # saved successfully
        QtBind.setText(gui, tbxOpcodes, "")
        log("Plugin: Added opcode [0x" + '{:02X}'.format(opcode) + "]")
示例#25
0
def btnAddOpcode_clicked():
    # Avoid empty data
    opcode = QtBind.text(gui, tbxOpcodes)
    if not opcode:
        return
    # Try to normalize it
    try:
        opcode = int(opcode, 16)
    except Exception as ex:
        log("Plugin: Error [" + str(ex) + "]")
        return
    # Check if is already added
    global lstOpcodesData
    if not opcode in lstOpcodesData:
        lstOpcodesData.append(opcode)
        strOpcode = '0x{:02X}'.format(opcode)
        QtBind.append(gui, lstOpcodes, strOpcode)
        saveConfigs()
        # saved successfully
        QtBind.setText(gui, tbxOpcodes, "")
        log("Plugin: Added opcode [" + strOpcode + "]")
示例#26
0
def btnAddLeader_clicked():
	if inGame:
		player = QtBind.text(gui,tbxLeaders)
		# Player nickname it's not empty
		if player and not lstLeaders_exist(player):
			# Init dictionary
			data = {}
			# Load config if exist
			if os.path.exists(getConfig()):
				with open(getConfig(), 'r') as f:
					data = json.load(f)
			# Add new leader
			if not "Leaders" in data:
				data['Leaders'] = []
			data['Leaders'].append(player)
			# Replace configs
			with open(getConfig(),"w") as f:
				f.write(json.dumps(data, indent=4, sort_keys=True))
			QtBind.append(gui,lstLeaders,player)
			QtBind.setText(gui, tbxLeaders,"")
			log('Plugin: Leader added ['+player+']')
示例#27
0
def add_newq():
	a = 0
	b = 0
	while True:
		if get_qa("l",0,2) == a:
			if b == 0:
				log("triviaBot: Not found new question.")
			else:
				log("triviaBot: "+ str(b) + " question(s) automatically added.")
			break
		else:
			if get_qa("q",a,2) not in str(get_qa("all",0)):
				if get_qa("a",a,2) != "":
					file = open("Plugins/"+server+"_"+qafolder+"/"+qafile,"a")
					file.write('--\n'+get_qa("q",a,2)+'--'+get_qa("a",a,2))
					file.close()
					QtBind.append(gui,qlist,get_qa("q",a,2))
					log("triviaBot: "+ get_qa("q",a,2) + " automatically added to list.")
					QtBind.setText(gui, qnumber,str(int(QtBind.text(gui,qnumber)) + 1))
					b += 1		
		a += 1
示例#28
0
def btnAddChannel_clicked():
	if isJoined():
		channel_id = QtBind.text(gui,tbxChannels)
		if channel_id and channel_id.isnumeric():
			# channel it's not empty and not added
			if not ListContains(QtBind.getItems(gui,lstChannels),channel_id):
				# init dict
				data = {}
				# Load config
				if os.path.exists(getConfig()):
					with open(getConfig(), 'r') as f:
						data = json.load(f)
				# Add new channel
				if not "Channels" in data:
					data['Channels'] = []
				data["Channels"].append(channel_id)
				# Replace configs
				with open(getConfig(),"w") as f:
					f.write(json.dumps(data, indent=4, sort_keys=True))
				
				# Add new channel on everything
				QtBind.append(gui,lstChannels,channel_id)
				for name,cmbx in cmbxTriggers.items():
					QtBind.append(gui,cmbx,channel_id)
				for name,cmbx in cmbxTriggers_.items():
					QtBind.append(gui_,cmbx,channel_id)

				QtBind.setText(gui,tbxChannels,"")
				log('Plugin: Channel added ['+channel_id+']')
		else:
			log('Plugin: Error, The channel must be an identifier number!')
示例#29
0
def btnUpdate_clicked():
    # Get plugin selected
    indexSelected = QtBind.currentIndex(gui, lvwPlugins)
    if indexSelected >= 0:
        pyData = lstPluginsData[indexSelected]
        # Update plugin if can
        if "canUpdate" in pyData and pyData['canUpdate']:
            # Get url
            pyUrl = pyData['url']
            try:
                req = urllib.request.Request(
                    pyUrl,
                    headers={
                        'User-Agent':
                        "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0"
                    })
                with urllib.request.urlopen(req) as w:
                    pyCode = str(w.read().decode("utf-8"))
                    pyVersion = re.search("\npVersion = ([0-9a-zA-Z.'\"]*)",
                                          pyCode).group(0)[13:-1]
                    # Create backup/copy
                    pyFolder = GetPluginsFolder() + '\\'
                    shutil.copyfile(pyFolder + pyData['filename'],
                                    pyFolder + pyData['pName'] + ".py.bkp")
                    os.remove(pyFolder + pyData['filename'])
                    # Create/Override file
                    with open(pyFolder + pyData['pName'] + ".py", "w+") as f:
                        f.write(pyCode)
                    # Update GUI
                    QtBind.removeAt(gui, lvwPlugins, indexSelected)
                    QtBind.append(
                        gui, lvwPlugins,
                        pyData['pName'] + ".py (" + pyData['pName'] + " v" +
                        pyVersion + ") - Updated recently")
                    log('Plugin: "' + pyData['pName'] +
                        '" plugin has been successfully updated')
            except:
                log("Plugin: Error updating your plugin. Try again later..")
示例#30
0
def SearchItem(itemName):
    # Creates a connection to database from vsro server
    conn = GetDatabaseConnection(character_data['server'])
    if conn:
        # set cursor
        c = conn.cursor()
        # find items with same name
        c.execute(
            'SELECT id,servername,name,tid3 FROM items WHERE tid1=1 AND tid2=13 AND name LIKE ?',
            ('%' + itemName + '%', ))
        global lvwItemsData
        lvwItemsData = c.fetchall()
        # Fill listview
        QtBind.append(gui, lvwItems, 'ID | ServerName | Name')  # Header
        for item in lvwItemsData:
            QtBind.append(gui, lvwItems,
                          str(item[0]) + ' | ' + item[1] + ' | ' + item[2])
        # query done
        conn.close()

    # Enable searching
    global isSearching
    isSearching = False