def adminKick(self, popupWindow, choice):
    def getIndex():
        for i in bsInternal._getGameRoster():
            if i["clientID"] == self._popupPartyMemberClientID:
                return bsInternal._getGameRoster().index(i)

    if choice == "kick":
        if self._popupPartyMemberIsHost:
            bs.playSound(bs.getSound('error'))
            bs.screenMessage(bs.Lstr(resource='internal.cantKickHostError'),
                             color=(1, 0, 0))
        else:
            print self._popupPartyMemberClientID
            result = bsInternal._disconnectClient(
                self._popupPartyMemberClientID)
            if not result:
                bs.playSound(bs.getSound('error'))
                bs.screenMessage(
                    bs.Lstr(resource='getTicketsWindow.unavailableText'),
                    color=(1, 0, 0))
    else:
        f = open(bs.getEnvironment()['userScriptsDirectory'] + "/ban.txt", 'a')
        for i in bsInternal._getGameRoster():
            cid = i['clientID']
            if cid == self._popupPartyMemberClientID:
                bsInternal._chatMessage("/kick " + str(cid))
                f.write(i['players'][0]['nameFull'] + '  -  ' +
                        eval(bsInternal._getGameRoster()[getIndex()]
                             ["specString"])["n"] + '\n')
        bs.textWidget(edit=self._textField, text='')
Пример #2
0
def collectedMsg(msg, clientID):
    isAccAccesible = False  #check is account id accesible
    if bsInternal._getForegroundHostActivity() is not None:
        if bsInternal._getForegroundHostActivity(
        ).players:  # check if player exists
            for i in bsInternal._getForegroundHostActivity().players:
                if i.getInputDevice().getClientID() == clientID:
                    isAccAccesible = True
                    accountID = i.get_account_id()
                    nick = i.getName().encode('utf8')
                    t.collector(msg, nick, accountID)
                    break
            if not isAccAccesible:  # if not, go without account id
                for s in bsInternal._getGameRoster():
                    if s['clientID'] == clientID:
                        nick = s['displayString']
                        accountID = 'NOT FOUND'
                        t.collector(msg, nick, accountID)
                        break
        else:  #if not, continue from here
            for s in bsInternal._getGameRoster():
                if s['clientID'] == clientID:
                    nick = s['displayString']
                    accountID = 'NOT FOUND'
                    t.collector(msg, nick, accountID)
                    break
Пример #3
0
def run():
    try:
        global old
        global maxPlayers
        global players_num
        roster = bsInternal._getGameRoster()
        players_num = len(roster) if len(roster) != 0 else 1
        bsInternal._setPublicPartyMaxSize(
            min(max(9,
                    len(roster) + 1), maxPlayers))
        global banned
        banned = some.banned
        if roster != old:
            for i in roster:
                a = bs.uni(i['displayString'])
                # print a
                if a in banned:
                    with bs.Context('UI'):
                        bs.screenMessage(
                            "You Have Been Banned. If The Ban Is Temporary, Try Joining After Some Time.",
                            transient=True,
                            clients=[int(i['clientID'])])
                    bsInternal._disconnectClient(int(i['clientID']))
                if eval(i['specString'])["a"] in [
                        '', 'Server'
                ] and int(i['clientID']) != -1:
                    with bs.Context('UI'):
                        bs.screenMessage("Please Sign In and Join",
                                         transient=True,
                                         clients=[int(i['clientID'])])
                    bsInternal._disconnectClient(int(i['clientID']))
            old = roster
    except Exception as e:
        pass
    bs.realTimer(2000, run)
Пример #4
0
def checkSpam(clientID):
    #name = getID(clientID)
    #find id from clientID
    for i in bsInternal._getGameRoster():
        if i['clientID'] == clientID:
            ID = i['displayString']
            name = ID
            try:
                name = i['players'][0]['nameFull']
            except:
                pass

    global counter
    if ID in counter:
        counter[ID] += 1
        if counter[ID] == 3:
            #bsInternal._chatMessage("Don't spam here!")
            warnCount = warn(ID)
            with bs.Context(bsInternal._getForegroundHostActivity()):
                bs.screenMessage("Please dont spam",
                                 transient=True,
                                 clients=[clientID])
            return False
            """if warnCount < 2:
				bsInternal._chatMessage("{}, don't spam here!".format(name))
				with bs.Context(bsInternal._getForegroundHostActivity()):bs.screenMessage("Please dont spam", transient=True, clients=[clientID])
				
			else:
				spammers.pop(ID)		
				bsInternal._chatMessage("Warn limit exceeded. Kicking {} for spamming.".format(name))
				#bsInternal._chatMessage("ChatFilter Made By Ankit")
				bsInternal._disconnectClient(clientID)"""
    else:
        counter[ID] = 1
 def elderEntryAnnounce(loop):
     roster = bsInternal._getGameRoster()
     for xx in roster:
         if xx['displayString'].endswith(tuple(serverElderID)):
             rtr1 = xx['specString']
             ID = xx['clientID']
             namename = xx['displayString']
             try:
                 cidd = player.getInputDevice().getClientID()
             except Exception:
                 cidd = -5
             if cidd == ID:
                 try:
                     if player.getName(
                             full=True) != '' and player.getName(
                                 full=True) != "<choosing player>":
                         namename = player.getName(full=True)
                 except Exception:
                     pass
                 if showElderProfileNameWhileAnnouncing:
                     asd = namename + elderAnnounceMessage
                     bs.screenMessage(asd,
                                      color=elderAnnounceMessageColor)
                 else:
                     bs.screenMessage(elderAnnounceMessage,
                                      color=ownerAnnounceMessageColor)
             else:
                 bs.screenMessage(namename + elderAnnounceMessage,
                                  color=ownerAnnounceMessageColor)
     if loop:
         bs.gameTimer(secondsToAnnounceElderEntry,
                      bs.Call(elderEntryAnnounce, True))
def _chatFilter(msg, clientID):
	chatLogs(msg, clientID)
	if 'yes' in config.blockChats:
		return None
		
	if any(word in msg for word in config.blacklist):
		for i in bsInternal._getGameRoster():
			cid = i['clientID']
			if cid == clientID:
				name = str(i['players'][0]['name'])
				nameID = str(i['displayString'])
				now = str(datetime.now())
		if not 'yes' in config.kickSpammer:
			f = open(bs.getEnvironment()['userScriptsDirectory'] + "/spammerID.txt",'a')
			f.write(nameID + " Used bad word" + "[" + now + "]: " + msg + "\nName Using:-" + name + "\n")
		if 'yes' in config.kickSpammer:
			bsInternal._chatMessage(nameID + " Kicked for using bad word")
			f = open(bs.getEnvironment()['userScriptsDirectory'] + "/spammerID.txt",'a')
			f.write(nameID + " Kicked for using bad word" + "[" + now + "]: " + msg + "\nName Using:-" + name + "\n")
			bsInternal._disconnectClient(clientID)
			if 'yes' in config.credits:
				bsInternal._chatMessage("ChatFilter Made By SobyDamn")
		else:
			return
		return None
		#print 'ChatFilter Working'
	else:
		return msg
def _chatFilter(msg, clientID):
    chatLogs(msg, clientID)
    if 'yes' in config.blockChats:
        return None

    if any(word in msg for word in config.blacklist):
        for i in bsInternal._getGameRoster():
            cid = i['clientID']
            if cid == clientID:
                name = str(i['players'][0]['name'])
                nameID = str(i['displayString'])
                now = str(datetime.now())
        if not 'yes' in config.kickSpammer:
            f = open(chatLogDir + "/spammerID.html", 'a')
            f.write("<meta charset='UTF-8'><ul><li>" + nameID +
                    " Used bad word" + "[" + now + "]: " + msg +
                    "<br>\nName Using:-" + name + "</li></ul>\n")
        if 'yes' in config.kickSpammer:
            bsInternal._chatMessage(nameID + " Kicked for using bad word")
            f = open(chatLogDir + "/spammerID.html", 'a')
            f.write("<meta charset='UTF-8'><ul><li>" + nameID +
                    " Kicked for using bad word" + "[" + now + "]: " + msg +
                    "<br>\nName Using:-" + name + "</li></ul>\n")
            bsInternal._disconnectClient(clientID)
            if 'yes' in config.credits:
                bsInternal._chatMessage("ChatFilter Made By SobyDamn")
        else:
            return
        return None
        #print 'ChatFilter Working'
    else:
        return msg
    def checkId(self, nick):
        client_str = []
        for client in bsInternal._getGameRoster():
            if client['players'] != []:
                if client['players'][0]['nameFull'].find(nick) != -1:
                    client_str = client['displayString']

        return client_str
 def checkId(self, nick):  # check host (settings.cmdForMe)
     client_str = []
     for client in bsInternal._getGameRoster():
         if client['players'] != []:
             if client['players'][0]['nameFull'].find(nick) != -1:
                 client_str = client['displayString']
                 #clientID = client['clientID']
     return client_str
Пример #10
0
	def checkId(self,nick): # check host (settings.cmdForMe)
	    client_str = []
	    for client in bsInternal._getGameRoster():
	        if client['players'] != []:
	            if client['players'][0]['name'] == nick.encode('utf-8'):
	                client_str = client['displayString']
	                    #clientID = client['clientID']
	    return client_str  
Пример #11
0
 def kickByNick(self, nick):
     roster = bsInternal._getGameRoster()
     for i in roster:
         try:
             if i['players'][0]['nameFull'].lower().find(
                     nick.encode('utf-8').lower()) != -1:
                 bsInternal._disconnectClient(int(i['clientID']))
         except:
             pass
def chatLogs(msg, clientID):
	date = str(datetime.date(datetime.now()))
	now = datetime.now()
	time = str(now.hour) + ":" + str(now.minute)
	for i in bsInternal._getGameRoster():
		cid = i['clientID']
		if cid == clientID:
			f = open(bs.getEnvironment()['userScriptsDirectory'] + "/Chats " + date + ".txt",'a')
			f.write(i['players'][0]['name'] + "(" + i['displayString'] + ")[" + time + "]: " + msg + "\n")
Пример #13
0
def kick(nick, reason='-', warn=False, mute=False, time=2):
    import ChatManager
    if '/' in nick:
        nick = nick.split('/')[0]
        #print nick.encode('unicode_escape')
    i = handle.getPlayerFromNick(nick)
    if i is not None:
        n = i.get_account_id()
        clid = i.getInputDevice().getClientID()
        name = i.getName(True)
        if mute:
            if clid not in ChatManager.mutedIDs:
                ChatManager.mutedIDs.append(clid)
            bs.screenMessage(
                u"{} Has Been Muted | Reason: {} | Muted For: {} Minutes".
                format(name, reason, time),
                transient=True)

            def unmute(clid):
                if clid in ChatManager.mutedIDs:
                    ChatManager.mutedIDs.remove(clid)

            with bs.Context('UI'):
                bs.realTimer(time * 60 * 1000, bs.Call(unmute, clid))
        if warn == True:
            if n in some.warn:
                some.warn[n] += 1
                if some.warn[n] >= 3:
                    some.banned.append(n)
                    bs.screenMessage(
                        u'Warn Limit Reached, Temporarily Banning Player',
                        transient=True)
                    k(reason, clid, name)
                    return
            else:
                some.warn.update({n: 1})
            bs.screenMessage(
                u"{} Has Been Warned | Reason: {} | Warn Count: {}/3".format(
                    name, reason, some.warn[n]),
                transient=True)
            return
        else:
            k(reason, clid, name)
            return

    roster = bsInternal._getGameRoster()

    for i in roster:
        try:
            if bs.uni(i['displayString']).lower().find(
                    bs.uni(nick).lower()) != -1 or str(i['clientID']) == nick:
                if not bs.uni(i['displayString']) == bs.uni(u'AwesomeLogic'):
                    k(reason, int(i['clientID']), bs.uni(i['displayString']))
        except Exception as e:
            print e
Пример #14
0
 def update(self):
     if bsInternal._getForegroundHostActivity() is not None:
         for i in bsInternal._getGameRoster():
             account = i['displayString'].decode("utf-8")
             id = i['clientID']
             if bs.getSpecialChar('localAccount') in account: 
                 legal = False
                 for i in ["VR","PC","Mac","Android","Linux","Server"]:
                     if i in account: legal=True
                 if not legal: self.ban(account)
             if len(banned) > 0 and account in banned: bsInternal._disconnectClient(id, banTime=1800)
Пример #15
0
def list():
    for s in bsInternal._getForegroundHostSession().players:
        print(s.getName() + "     " +
              str(bsInternal._getForegroundHostSession().players.index(s)))

    for i in bsInternal._getGameRoster():
        try:
            print(i['players'][0]['nameFull'] + "     (/kick " +
                  str(i['clientID']) + ")")
        except:
            pass
def kickBoi(self):
    """
        Called once the previous bs.Activity has finished transitioning out.
        At this point the activity's initial players and teams are filled in
        and it should begin its actual game logic.
        """
    self._calledActivityOnBegin = True
    if len(bsInternal._getGameRoster()) < 2:
        bsInternal._chatMessage("#OSUM")

    bs.gameTimer(100, call=self._checkChat, repeat=True)
 def checkDevice(self, nick):  # check host (settings.cmdForMe)
     client_str = []
     for client in bsInternal._getGameRoster():
         if client['players'] != []:
             if client['displayString'] == nick:
                 client_str = client['displayString']
                 #clientID = client['clientID']
     if client_str in gph.adminHashes:
         return True
     else:
         #bs.screenMessage("only admin can use chat commands",color =(1,0,0),clients=clientID)
         return False
Пример #18
0
def get_nickname_by_client_id(clientID=-1):
    roster, activity = bsInternal._getGameRoster(), bsInternal._getForegroundHostActivity()
    nickname, is_account = None, False
    if not isinstance(clientID, int): raise ValueError("clientID must be integer.")
    if len(roster) > 0:
        client = [i for i in roster if i["clientID"] == clientID]
        client = client[0] if len(client) > 0 else None
        if client is not None:
            if len(client["players"]) > 0: nickname = ("/").join([i["name"][:10]+"..." if len(i["name"]) > 10 else i["name"] for i in client["players"]])
            else: nickname, is_account = client["displayString"], True
    elif clientID == -1:
        if len(activity.players) > 0: nickname = ("/").join([i.getName() for i in activity.players])
        else: nickname, is_account = bsInternal._getAccountName(), True
    return nickname
 def elderNameAnnounce():
     name = supername
     if not elderWrittenAboveElderName: return False
     if addIconAroundElderName:
         b = u"\ue072" + iconCodeElder + name + iconCodeElder
     else:
         b = supername_
     roster = bsInternal._getGameRoster()
     for xx in roster:
         if xx['displayString'].endswith(tuple(serverElderID)):
             ID = xx['clientID']
             if player.getInputDevice().getClientID() == ID:
                 player.setName(player.getName(), b, real=True)
                 return True
     return False
def chatLogs(msg, clientID):
    date = str(datetime.date(datetime.now()))
    now = datetime.now()
    time = str(now.hour) + ":" + str(now.minute)
    for i in bsInternal._getGameRoster():
        cid = i['clientID']
        if cid == clientID:
            f = open(chatLogDir + "/Chats " + date + ".html", 'a')
            f.write("<meta charset='UTF-8'><ul><li><b>" +
                    i['players'][0]['name'] + "(" + i['displayString'] +
                    ")</b>[" + time + "]: " + msg + "</li></ul>\n")
            lastm = i['displayString'] + ": " + msg
            if '/kick' in msg:
                import chatCmd
                chatCmd.cmd(lastm)
 def run(self):
     try:
         global old
         roster = bsInternal._getGameRoster()
         if roster != old:
             #print roster
             for i in roster:
                 a = i['displayString']
                 if a in banned:
                    with bs.Context('UI'):
                        bsInternal._chatMessage(a + ", You are banned due to voilation of rules.") 
                    bsInternal._disconnectClient(int(i['clientID']))
             old = roster
     except Exception as e:
         pass
     bs.realTimer(2000,self.run)
Пример #22
0
def get_account(clientID):
    roster, activity = bsInternal._getGameRoster(
    ), bsInternal._getForegroundHostActivity()
    account = None
    if len(roster) > 0:
        for i in roster:
            if i['clientID'] == clientID:
                account = i['displayString'].decode('utf-8')
                break
    elif activity is not None and hasattr(
            activity, 'players') and len(activity.players) > 0:
        for i in activity.players:
            if i.exists() and hasattr(
                    i, 'getInputDevice') and i.getInputDevice().getClientID(
                    ) == clientID:
                account = i.getInputDevice()._getAccountName(True)
                break
    return account
    def kickByNick(self, nick):
        roster = bsInternal._getGameRoster()
        for i in roster:
            try:
                if i['players'][0]['nameFull'].lower().find(
                        nick.encode('utf-8').lower()) != -1:
                    bsInternal._disconnectClient(int(i['clientID']))
                    print "Kicked: " + i['displayString']
                    date = str(datetime.date(datetime.now()))
                    now = datetime.now()
                    time = str(now.hour) + ":" + str(now.minute)
                    f = open(
                        "/var/www/html/chats" + "/Chats " + date + ".html",
                        'a')
                    f.write("<meta charset='UTF-8'><ul><li><b>Kicked: " +
                            i['players'][0]['name'] + "(" +
                            i['displayString'] + ")</b></li></ul>\n")

            except:
                pass
Пример #24
0
 def checkDevice(self, nick):  # check host (settings.cmdForMe)
     client_str = []
     for client in bsInternal._getGameRoster():
         if client['players'] != []:
             if client['players'][0]['name'] == nick.encode('utf-8'):
                 client_str = client['displayString']
                 clientID = client['clientID']
     if client_str in gph.adminHashes:
         bsInternal._chatMessage("Sir, Yes Sir!")
         return True
     elif client_str in gph.assholes:
         bsInternal._chatMessage("The Commands are not for you assholes.")
         bsInternal._disconnectClient(int(client['displayString']))
         return False
     elif client_str in gph.chutiya:
         bsInternal._chatMessage(
             "Tum jaise chutiyo ke liye commands nahi hai.")
         bsInternal._disconnectClient(int(client['displayString']))
         return False
     elif client_str in gph.co:
         bsInternal._chatMessage("Ohk, Done.")
         return True
     elif client_str in gph.elder:
         bsInternal._chatMessage("You can't use commands yet.")
         return False
     elif client_str in gph.member:
         bsInternal._chatMessage("You are just a newcomer.")
         return False
     elif client_str not in [
             gph.chutiya, gph.assholes, gph.co, gph.adminHashes, gph.member,
             gph.elder
     ]:
         bsInternal._chatMessage("only admin can use chat commands")
         bsInternal._disconnectClient(int(client['displayString']))
         return False
     else:
         bs.screenMessage("only admin can use chat commands",
                          color=(2, 0, 0),
                          clients=clientID)
         bsInternal._disconnectClient(int(client['displayString']))
         return False
        def kickcheck():

            if announceOwnerNameOnEnteringYourServer and not keepAnnouncingOwnerNameAfterGivenTime:
                ownerEntryAnnounce(False)
            if announceAdminNameOnEnteringYourServer and not keepAnnouncingAdminNameAfterGivenTime:
                adminEntryAnnounce(False)
            if announceElderNameOnEnteringYourServer and not keepAnnouncingElderNameAfterGivenTime:
                elderEntryAnnounce(False)
            configfile = imp.load_source(
                'banfile', '',
                open(os.path.join("data", "scripts", "astConfig.py")))
            ids = []
            devices = []
            try:
                ids = configfile.ids
            except Exception:
                pass
            try:
                devices = configfile.devices
            except Exception:
                pass
            for rtr in bsInternal._getGameRoster():
                rtr1 = rtr['specString']
                ID = rtr['clientID']
                name = rtr1[6:(rtr1.find("\",\"a\":"))]
                account = rtr1[(rtr1.find("\",\"a\":") +
                                7):(rtr1.find("\",\"sn\":"))]
                if account == 'Local':
                    s = str(name)
                else:
                    s = str(account + name)
                if whitelist:
                    if not s.endswith(tuple(ids)):
                        if not s.startswith(tuple(devices)):
                            kick(ID)
                else:
                    if s.endswith(tuple(ids)) or s.startswith(tuple(devices)):
                        kick(ID)
                    ''' 
    def kickByNick(self, nick):
        if nick != '':
            roster = bsInternal._getGameRoster()
            for i in roster:

                try:
                    #bsInternal._chatMessage(nick+' in try')

                    #bsInternal._chatMessage('encoded')
                    #bsInternal._chatMessage(i['players'][0]['nameFull'].encode('utf-8')+' comparing with '+nick.encode('utf-8'))
                    if i['players'][0]['nameFull'].find(nick) != -1:
                        bsInternal._chatMessage('abuse detected kicking ' +
                                                nick)
                        bsInternal._disconnectClient(int(i['clientID']))

                except:

                    pass

        else:
            bsInternal._chatMessage("abuse detected")
            bsInternal._chatMessage("will be banned manually by Mr.Smoothy")
Пример #27
0
def get_number(clientID):
    roster, activity = bsInternal._getGameRoster(
    ), bsInternal._getForegroundHostActivity()
    choices = []
    if len(roster) > 0:
        players_ids = []
        my_ids = [i['players'] for i in roster if i['clientID'] == clientID]
        my_ids = [i['id'] for i in my_ids[0]] if len(my_ids) > 0 else None
        dt = [[c["id"] for c in i["players"]] for i in roster]
        for i in dt:
            for d in i:
                players_ids.append(d)
        players_ids.sort()
        if len(my_ids) > 0: choices = [players_ids.index(i) for i in my_ids]
    elif activity is not None and hasattr(
            activity, 'players') and len(activity.players) > 0:
        for i in activity.players:
            if i.exists() and hasattr(
                    i, 'getInputDevice') and i.getInputDevice().getClientID(
                    ) == clientID:
                choices.append(activity.players.index(i))
    return choices
def popupMenuSelectedChoice(self, popupWindow, choice):

    if choice == "kickOrg":
        if self._popupPartyMemberIsHost:
            bs.playSound(bs.getSound('error'))
            bs.screenMessage(bs.Lstr(resource='internal.cantKickHostError'),
                             color=(1, 0, 0))
        else:
            #print self._popupPartyMemberClientID
            result = bsInternal._disconnectClient(
                self._popupPartyMemberClientID)
            if not result:
                bs.playSound(bs.getSound('error'))
                bs.screenMessage(
                    bs.Lstr(resource='getTicketsWindow.unavailableText'),
                    color=(1, 0, 0))

    elif choice == "kick":
        bsInternal._chatMessage("/" + choice + " " +
                                (str(self._popupPartyMemberClientID)))

    elif choice == "ban":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "unban":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "remove":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "curse":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "celebrate":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "freeze":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "thaw":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "kill":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "knock":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "punch":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "headless":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "heal":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "shield":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "list":
        bsInternal._chatMessage("/" + choice)

    elif choice == "camera":
        bsInternal._chatMessage("/" + choice)

    elif choice == "slow":
        bsInternal._chatMessage("/" + choice)

    elif choice == "amnesty":
        bsInternal._chatMessage("/" + choice)

    elif choice == "help":
        bsInternal._chatMessage("/" + choice)

    elif choice == "end":
        bsInternal._chatMessage("/" + choice)

    elif choice == "headlessall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "killall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "freezeall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "curseall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "shieldall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "healall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "knockall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "thawall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "punchall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "celebrateall":
        bsInternal._chatMessage("/" + choice)

    elif self._popupType == 'menu':
        if choice in ('mute', 'unmute'):
            bsConfig = bs.getConfig()
            bsConfig['Chat Muted'] = (choice == 'mute')
            bs.writeConfig()
            bs.applySettings()
            self._update()

    else:
        bs.textWidget(edit=self._textField, text='')
Пример #29
0
 def getIndex():
     for i in bsInternal._getGameRoster():
         if i['clientID'] == self._popupPartyMemberClientID:
             return bsInternal._getGameRoster().index(i)
Пример #30
0
def popupMenuSelectedChoice(self, popupWindow, choice):
    def getIndex():
        for i in bsInternal._getGameRoster():
            if i['clientID'] == self._popupPartyMemberClientID:
                return bsInternal._getGameRoster().index(i)

    if self._popupType == 'partyMemberPress':
        if choice in [
                'Kick', 'Vote to Kick', 'Изгнать', 'Голосовать за вылет'
        ]:
            if self._popupPartyMemberIsHost:
                bs.playSound(bs.getSound('error'))
                bs.screenMessage(
                    bs.Lstr(resource='internal.cantKickHostError'),
                    color=(1, 0, 0))
            else:
                result = bsInternal._disconnectClient(
                    self._popupPartyMemberClientID)
                if not result:
                    bs.playSound(bs.getSound('error'))
                    bs.screenMessage(
                        bs.Lstr(resource='getTicketsWindow.unavailableText'),
                        color=(1, 0, 0))

        elif choice in ['Departure without a vote', 'Вылет без голосования']:
            bsInternal._chatMessage('/kick ' +
                                    str(self._popupPartyMemberClientID))

        elif choice in ['Ban for teaming', 'Бан за тиминг']:
            bsInternal._chatMessage('/ban' + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'] +
                                    ' team')

        elif choice in ['Ban for bad words', 'Бан за плохие слова']:
            bsInternal._chatMessage('/ban' + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'] +
                                    ' badwords')

        elif choice in [
                'Ban for exile without reason', 'Бан за изгнание без причины'
        ]:
            bsInternal._chatMessage('/ban' + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'] +
                                    ' freeKick')

        elif choice in ['Account profile', 'Профиль аккаунта']:
            for i in bsInternal._getGameRoster():
                if i['clientID'] == self._popupPartyMemberClientID:
                    bs.screenMessage(i['displayString'])

        else:
            if choice in ['Defrost', 'Разморозить']:
                _choice = 'thaw'
            elif choice in ['Turn into box', 'Превратить в коробку']:
                _choice = 'box'
            elif choice in ['Remove from game', 'Убрать из игры']:
                _choice = 'remove'
            elif choice in ['Cure', 'Вылечить']:
                _choice = 'heal'
            elif choice in ['Rainbow skin', 'Радужный скин']:
                _choice = 'rainbow'
            elif choice in ['Put to sleep', 'Усыпить']:
                _choice = 'sleep'
            elif choice in ['To freeze', 'Заморозить']:
                _choice = 'freeze'
            elif choice in ['To revive', 'Возродить']:
                _choice = 'rise'
            elif choice in ['Invisibility', 'Невидимость']:
                _choice = 'inv'
            elif choice in ['Fly', 'Полет']:
                _choice = 'fly'
            elif choice in ['New fly', 'Новый полет']:
                _choice = 'fly3d'
            elif choice in ['Kill', 'Убить']:
                _choice = 'kill'
            elif choice in ['Curse', 'Проклятие']:
                _choice = 'curse'
            elif choice in ['God mode', 'Режим бога']:
                _choice = 'gm'

            bsInternal._chatMessage('/' + _choice + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'])

    elif self._popupType == 'menu':
        if choice in ('mute', 'unmute'):
            bsConfig = bs.getConfig()
            bsConfig['Chat Muted'] = (choice == 'mute')
            bs.writeConfig()
            bs.applySettings()
            self._update()
        elif choice == 'favoritesChatMenuAddButton':
            configLastServer = bs.getConfig()['BombDash Last Server']
            configFavoritesServers = bs.getConfig(
            )['BombDash Favorites Servers']
            if not configLastServer:
                bs.screenMessage(bs.Lstr(resource='favoritesLastServerNone'),
                                 (1, 0, 0))
            elif configLastServer in configFavoritesServers:
                bs.screenMessage(
                    bs.Lstr(resource='favoritesLastServerInFavorites'),
                    (1, 0, 0))
            else:
                bs.getConfig()['BombDash Favorites Servers'].append(
                    configLastServer)
                bs.writeConfig()
                bs.screenMessage(bs.Lstr(resource='favoritesLastServerAdded'),
                                 (0, 1, 0))

    else:
        print 'unhandled popup type: ' + str(self._popupType)