def testPlugin(p):
        joe.connects(1)

        joe.gear = None
        joe.team = b3.TEAM_SPEC
        joe.changesGear('GLAOWRA')

        joe.gear = None
        joe.team = b3.TEAM_BLUE
        joe.changesGear('GLAOWRA')

        print "\nJoe takes smoke grenades"
        joe.changesGear('GLAQWRA')
        time.sleep(1)

        print "\nJoe goes to red team"
        joe.team = b3.TEAM_RED
        time.sleep(1)

        print "\nJoe takes HE grenades and goes to RED"
        joe.changesGear('GLAOWRA')
        joe.team = b3.TEAM_RED

        superadmin.connects(0)
        superadmin.says('!wpctrl -he')

        time.sleep(2)
        joe.disconnects()
        superadmin.disconnects()
Esempio n. 2
0
    def test_forgive(self, timer_patch):
        from b3.fake import superadmin
        superadmin.connects(99)

        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole,
                         name="Joe",
                         exactName="Joe",
                         guid="joeguid",
                         groupBits=1,
                         team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole,
                          name="Mike",
                          exactName="Mike",
                          guid="mikeguid",
                          groupBits=1,
                          team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)

        joe.kills(mike)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 200 TK points", superadmin.message_history[0])

        mike.says("!forgive")

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 0 TK points", superadmin.message_history[0])
Esempio n. 3
0
    def test_no_player(self):
        # count minimum channels
        initial_num_channels = len(Test_shutdown.ts3.get_channellist())

        ## create an instance of the plugin to test
        p = TeamspeakbfPlugin(fakeConsole, conf)
        p.onLoadConfig()
        p.onStartup()

        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterinit_num_channels = len(clist)
        self.assertLess(initial_num_channels, afterinit_num_channels)

        superadmin.connects('superadmin')
        superadmin.says('!die')
        timeout = time.time() + 20
        while p.connected and time.time() < timeout:
            time.sleep(.5)
        if p.connected:
            self.fail("Could not disconnect from TeamSpeak server")

        time.sleep(.5)
        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterdeath_num_channels = len(clist)
        self.assertGreaterEqual(initial_num_channels, afterdeath_num_channels)
    def test_no_player(self):
        # count minimum channels
        initial_num_channels = len(Test_shutdown.ts3.get_channellist())

        ## create an instance of the plugin to test
        p = TeamspeakPlugin(fakeConsole, conf)
        p.onLoadConfig()
        p.onStartup()

        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterinit_num_channels = len(clist)
        self.assertLess(initial_num_channels, afterinit_num_channels)

        superadmin.connects('superadmin')
        superadmin.says('!die')
        timeout = time.time() + 20
        while p.connected and time.time() < timeout:
            time.sleep(.5)
        if p.connected:
            self.fail("Could not disconnect from TeamSpeak server")

        time.sleep(.5)
        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterdeath_num_channels = len(clist)
        self.assertGreaterEqual(initial_num_channels, afterdeath_num_channels)
    def test_with_player(self):
        # count minimum channels
        initial_num_channels = len(Test_shutdown.ts3.get_channellist())

        ## create an instance of the plugin to test
        p = TeamspeakPlugin(fakeConsole, conf)
        p.onLoadConfig()
        p.onStartup()

        superadmin.connects('superadmin')

        if not p.tsGetClient(superadmin):
            raise unittest.SkipTest("please connect to the test Teamspeak server first and make sure your ip is %s as set in config.ini" % config.get("me", "ip"))


        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterinit_num_channels = len(clist)
        self.assertLess(initial_num_channels, afterinit_num_channels)

        superadmin.says('!ts join')
        time.sleep(.5)

        superadmin.says('!die')
        timeout = time.time() + 20
        while p.connected and time.time() < timeout:
            time.sleep(.5)
        if p.connected:
            self.fail("Could not disconnect from TeamSpeak server")

        time.sleep(.5)
        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterdeath_num_channels = len(clist)
        self.assertGreaterEqual(initial_num_channels, afterdeath_num_channels)
Esempio n. 6
0
 def test_ban_event():
     superadmin.connects(0)
     time.sleep(1)
     joe.connects(1)
     time.sleep(1)
     superadmin.says('!permban joe test_perm_ban')
     time.sleep(3)
     joe.connects(2)
Esempio n. 7
0
 def test_tempban_event():
     joe.connects(1)
     time.sleep(2)
     superadmin.connects(0)
     superadmin.says('!unban @%s' % joe.id)
     time.sleep(1)
     joe.connects(1)
     time.sleep(1)
     superadmin.says('!tempban joe 1w racism')
     time.sleep(3)
     joe.connects(2)
Esempio n. 8
0
 def test_getAllActiveBans(): 
     p.disable()
     superadmin.connects(0)
     for i in range(1, 50):
         tmp = FakeClient(fakeConsole, name="test_g%s" % i, guid="qsd654sqf_g%s" % i, ip='1.2.3.%d' % i)
         tmp.connects(i)
         superadmin.says('!tempban test_g%s %s test' % (i, random.choice(('15m', '1h', '2h', '3d', '1w'))))
     for i in range(50,60):
         tmp = FakeClient(fakeConsole, name="test_permban_g%s" % i, guid="qsd654sqf_g%s" % i)
         tmp.connects(i)
         superadmin.says('!permban test_permban_g%s test reason %s' % (i, i))
     p.enable()
     for i in p._getAllActiveBans():
         print i
Esempio n. 9
0
 def test_tempban_expiration():
     joe.connects(1)
     time.sleep(2)
     superadmin.connects(0)
     moderator.connects(2)
     superadmin.says('!unban @%s' % joe.id)
     time.sleep(1)
     joe.connects(1)
     time.sleep(1)
     superadmin.says('!tempban joe 1 test_1_minute')
     for i in range(8):
         time.sleep(10)
         print(" -"*20)
         joe.connects(3)
         joe.auth()
Esempio n. 10
0
 def testAutomation1():
     from b3.fake import superadmin
     superadmin.connects(0)
     superadmin.says('!makeroomauto')
     time.sleep(1)
     superadmin.says('!makeroomauto on')
     superadmin.says('!makeroomauto off')
Esempio n. 11
0
 def testAutomation1():
     from b3.fake import superadmin
     superadmin.connects(0)
     superadmin.says('!makeroomauto')
     time.sleep(1)
     superadmin.says('!makeroomauto on')
     superadmin.says('!makeroomauto off')
Esempio n. 12
0
    def test_forgive(self, timer_patch):
        from b3.fake import superadmin
        superadmin.connects(99)

        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)

        joe.kills(mike)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 200 TK points", superadmin.message_history[0])

        mike.says("!forgive")

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 0 TK points", superadmin.message_history[0])
Esempio n. 13
0
    def test_with_player(self):
        # count minimum channels
        initial_num_channels = len(Test_shutdown.ts3.get_channellist())

        ## create an instance of the plugin to test
        p = TeamspeakbfPlugin(fakeConsole, conf)
        p.onLoadConfig()
        p.onStartup()

        superadmin.connects('superadmin')

        if not p.tsGetClient(superadmin):
            raise unittest.SkipTest(
                "please connect to the test Teamspeak server first and make sure your ip is %s as set in config.ini"
                % config.get("me", "ip"))

        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterinit_num_channels = len(clist)
        self.assertLess(initial_num_channels, afterinit_num_channels)

        superadmin.says('!ts join')
        time.sleep(.5)

        superadmin.says('!die')
        timeout = time.time() + 20
        while p.connected and time.time() < timeout:
            time.sleep(.5)
        if p.connected:
            self.fail("Could not disconnect from TeamSpeak server")

        time.sleep(.5)
        Test_shutdown.ts3.print_channel_tree()
        clist = Test_shutdown.ts3.get_channellist()
        afterdeath_num_channels = len(clist)
        self.assertGreaterEqual(initial_num_channels, afterdeath_num_channels)
Esempio n. 14
0
    def test_forgiveinfo(self, timer_patch):
        from b3.fake import superadmin
        superadmin.connects(99)

        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole,
                         name="Joe",
                         exactName="Joe",
                         guid="joeguid",
                         groupBits=1,
                         team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole,
                          name="Mike",
                          exactName="Mike",
                          guid="mikeguid",
                          groupBits=1,
                          team=b3.TEAM_RED)
        bill = FakeClient(fakeConsole,
                          name="Bill",
                          exactName="Bill",
                          guid="billguid",
                          groupBits=1,
                          team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)
        bill.connects(2)

        joe.kills(mike)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 200 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200)", superadmin.message_history[0])
        self.assertNotIn("Attacked By:", superadmin.message_history[0])

        joe.damages(bill, points=6)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 206 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200), Bill (6)",
                      superadmin.message_history[0])
        self.assertNotIn("Attacked By:", superadmin.message_history[0])

        mike.damages(joe, points=27)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 206 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200), Bill (6)",
                      superadmin.message_history[0])
        self.assertIn("Attacked By: Mike [27]", superadmin.message_history[0])
Esempio n. 15
0
    def test_forgiveinfo(self, timer_patch):
        from b3.fake import superadmin
        superadmin.connects(99)

        Tk_functional_test.p._round_grace = 0
        joe = FakeClient(fakeConsole, name="Joe", exactName="Joe", guid="joeguid", groupBits=1, team=b3.TEAM_RED)
        mike = FakeClient(fakeConsole, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=b3.TEAM_RED)
        bill = FakeClient(fakeConsole, name="Bill", exactName="Bill", guid="billguid", groupBits=1, team=b3.TEAM_RED)

        joe.warn = Mock()
        joe.connects(0)
        mike.connects(1)
        bill.connects(2)

        joe.kills(mike)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 200 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200)", superadmin.message_history[0])
        self.assertNotIn("Attacked By:", superadmin.message_history[0])

        joe.damages(bill, points=6)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 206 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200), Bill (6)", superadmin.message_history[0])
        self.assertNotIn("Attacked By:", superadmin.message_history[0])


        mike.damages(joe, points=27)

        superadmin.message_history = []
        superadmin.says("!forgiveinfo joe")
        self.assertIn("Joe has 206 TK points", superadmin.message_history[0])
        self.assertIn("Attacked: Mike (200), Bill (6)", superadmin.message_history[0])
        self.assertIn("Attacked By: Mike [27]", superadmin.message_history[0])
Esempio n. 16
0
                    '^2%s ^3says: %s %s' % (client.name,
                    random.choice(self._p2p_cmddict[cmd.command]),
                    sclient.name))

        else:
            client.message(self._cmddict[cmd.command])
            
if __name__ == '__main__':

    from b3.fake import fakeConsole, joe, reg, superadmin
 
    myplugin = MorespamPlugin(fakeConsole, '@b3/extplugins/conf/morespam.xml')
    print("\n\n * * * * * * * * * * * *  Tests starting below * * * * * * * * * * * * \n\n")
 
    # we call onStartup() as the real B3 would do
    myplugin.onStartup()
 
    # make superadmin connect to the fake game server on slot 0
    superadmin.connects(cid=0)
 
    # make joe and reg connect to the fake game server on slot 1
    joe.connects(cid=1)
    reg.connects(cid=2)
 
    # superadmin put joe in group user
    superadmin.says('!putgroup reg admin')
 
    # make joe try our commands
    reg.says('!ns joe')
    reg.says('!lol joe')
Esempio n. 17
0
 def test_Command_check():
     superadmin.connects(0)
     time.sleep(1)
     joe.connects(1)
     time.sleep(1)
     superadmin.says('!metabanscheck joe')
Esempio n. 18
0
		elif data == "off":
			self.console.say(client.exactName + " has ^5deactivated ^7his/her ^1AIMBOT!")

	def cmd_wallhack(self, data, client, cmd = None):
		if data == "on":
			self.console.say(client.exactName + " has ^5activated ^7his/her ^1WALLHACKS!")
		elif data == "off":
			self.console.say(client.exactName + " has ^5deactivated ^7his/her ^1WALLHACKS!")

	def cmd_poop(self, data, client, cmd = None):
		if data:
			input = self._admin.parseUserCmd(data)
		if not data:
			self.console.write("bigtext \" {0} pooped!\"".format(client.exactName))
			return
		poopOn = self._admin.findClientPrompt(input[0], client)
		if poopOn:
			self.console.write("bigtext \" {0} pooped on {1}!\"".format(client.exactName, poopOn.exactName))


	def cmd_ragequit(self, data, client, cmd = None):
		client.kick()
		self.console.say(client.exactName + " ragequit like a baby!")

if __name__ == "__main__":
	from b3.fake import fakeConsole, superadmin
	plugin = HaxxPlugin(fakeConsole)
	plugin.onStartup()
	superadmin.connects(cid = 0)
	superadmin.says("!wh on")
Esempio n. 19
0
    p = StatsPlugin(fakeConsole, conf)
    p.onStartup()
    p.onLoadConfig()

    time.sleep(1)
    joe.connects(cid=3)
    joe.says("!mapstats")
    joe.says("!mystatalias")
    joe.says("!testscore")
    joe.says("!tscr")
    joe.says("!topstats")
    joe.says("!tops")
    joe.says("!topxp")
    joe.says("!txp")

    superadmin.connects(cid=2)
    joe.kills(superadmin)
    joe.kills(superadmin)
    joe.kills(superadmin)
    superadmin.kills(joe)

    superadmin.says("!mapstats")
    superadmin.says("!mystatalias")
    superadmin.says("!testscore")
    superadmin.says("!tscr")
    superadmin.says("!topstats")
    superadmin.says("!tops")
    superadmin.says("!topxp")
    superadmin.says("!txp")
Esempio n. 20
0
    def run(self):
        battlelog_user = self.__ipinfo_api.getUser(self.__clientname)

        if self.__callback:
            self.__callback(*self.__callback_args, data=battlelog_user)


if __name__ == '__main__':
    from b3.fake import fakeConsole, superadmin, joe, simon, fakeAdminPlugin
    import time

    myplugin = BattlelogPlugin(fakeConsole, 'conf/plugin_battlelog.ini')
    myplugin.console.game.gameName = 'bf3'
    myplugin.onStartup()
    time.sleep(2)

    myplugin.console.game.gameType = 'Domination0'
    myplugin.console.game._mapName = 'XP2_Skybar'
    superadmin.connects(cid=0)
    # make joe connect to the fake game server on slot 1
    joe.connects(cid=1)
    # make joe connect to the fake game server on slot 2
    simon.connects(cid=2)
    # superadmin put joe in group user
    superadmin.says('!putgroup joe user')
    superadmin.says('!putgroup simon user')

    joe.name = 'O2ON'

    superadmin.connects(cid=0)
p.onStartup()

simon.connects("simon")
simon.teamId = 1
simon.squad = 7
joe.connects('Joe')
joe.teamId = 1
joe.squad = 7
moderator.connects('moderator')
moderator.teamId = 2
moderator.squad = 5
superadmin.connects('superadmin')
superadmin.teamId = 2
superadmin.squad = 6
print "Joe's group is " +  joe.maxGroup.name
print "Simon's group is " + simon.maxGroup.name
print "Moderator's group is " + moderator.maxGroup.name
print "superadmin's group is " +  superadmin.maxGroup.name


assert p.no_level_check_level == 20

print "\n\n####################################### moderator should be able to swap God"
moderator.says("!swap God")

print "\n\n####################################### simon should not be able to swap Moderator"
simon.says("!swap Moderator")

print "\n\n####################################### God should be able to swap Moderator"
superadmin.says("!swap Moderator")
Esempio n. 22
0
    def register_commands(self):
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp

                func = self.getCmd(cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func,
                                                      alias)

if __name__ == '__main__':

    from b3.fake import fakeConsole, superadmin, joe
    import time

    myplugin = Weaponlimiterbf3Plugin(
        fakeConsole, '@b3/extplugins/conf/plugin_weaponlimiterbf3.xml')
    myplugin.onStartup()
    time.sleep(2)

    superadmin.connects(cid=0)
    superadmin.setvar('weaponlimiterbf3', 'test', 'blub')
    print(dir(superadmin))
    print(superadmin.var('weaponlimiterbf3', 'test'))
    superadmin.says('!weaponlimiter')
conf.loadFromString("""
<configuration plugin="poweradminbf3">
  <settings name="commands">
    <set name="setnextmap-snmap">20</set>
  </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

superadmin.connects('superadmin')

print "\n\n====================================== test !setnextmap nominal case"
superadmin.says('!setnextmap')


print "\n\n====================================== test case map name not recognised"
def my_getMapsSoundingLike_3_suggestions(mapname): return ['map #1', 'map #2', 'map #3']
fakeConsole.getMapsSoundingLike = my_getMapsSoundingLike_3_suggestions
superadmin.says('!snmap somemap')


def my_getMapsSoundingLike_map_found(mapname): return ['MAP_001']
fakeConsole.getMapsSoundingLike = my_getMapsSoundingLike_map_found

def my_getEasyName(mapId):
    return "MAP #1"
fakeConsole.getEasyName = my_getEasyName
Esempio n. 24
0
prepare_fakeparser_for_tests()

from b3.fake import fakeConsole, superadmin
from poweradminbf3 import Poweradminbf3Plugin
from b3.config import XmlConfigParser

conf = XmlConfigParser()
conf.loadFromString("""
<configuration plugin="poweradminbf3">
  <settings name="commands">
    <set name="punkbuster-pb">100</set>
    <set name="roundnext-rnext">40</set>
    <set name="roundrestart-rrestart">40</set>
  </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

superadmin.connects('superadmin')

print "\n\n####################################### test basic commands. They should all work"
superadmin.says("!roundnext")
superadmin.says("!rnext")
superadmin.says("!roundrestart")
superadmin.says("!rrestart")
superadmin.says("!punkbuster")
superadmin.says("!pb some command")
            p2 = team2players.pop()
            p2name = p2.name
            p2score = getattr(p2, 'score', 0)
        except IndexError:
            p2name = ''
            p2score = ''
        print("| {: >4} {:>15} | {:<15} {: >4} |".format(p1score, p1name, p2name, p2score))
    print("+" + ("-"*22) + "+" + ("-"*22) + "+")


superadmin.connects('superadmin')
superadmin.teamId = 2


print "\n\n####################################### test !scramble"
superadmin.says('!scramble')
assert p._scrambling_planned is True
superadmin.says('!scramble')
assert p._scrambling_planned is False
superadmin.says('!scramble')
assert p._scrambling_planned is True


print "\n\n####################################### test scrambleTeams()"
for i in range(12):
    fakeConsole.clients.newClient(cid='p%s'%i, guid='p%s'%i, name="Player %s"%i, teamId=1)
printTeams()
p._scrambler.scrambleTeams()
printTeams()
p._scrambler.scrambleTeams()
printTeams()
p.onLoadConfig()
p.onStartup()

simon.connects("simon")
simon.teamId = 1
simon.squad = 7
joe.connects('Joe')
joe.teamId = 1
joe.squad = 7
moderator.connects('moderator')
moderator.teamId = 2
moderator.squad = 5
superadmin.connects('superadmin')
superadmin.teamId = 2
superadmin.squad = 6
print "Joe's group is " + joe.maxGroup.name
print "Simon's group is " + simon.maxGroup.name
print "Moderator's group is " + moderator.maxGroup.name
print "superadmin's group is " + superadmin.maxGroup.name

assert p.no_level_check_level == 20

print "\n\n####################################### moderator should be able to swap God"
moderator.says("!swap God")

print "\n\n####################################### simon should not be able to swap Moderator"
simon.says("!swap Moderator")

print "\n\n####################################### God should be able to swap Moderator"
superadmin.says("!swap Moderator")
# make B3 think it has a config file on the filesystem
conf.fileName = os.path.join(os.path.dirname(__file__), '../extplugins/conf/weaponrestrict.ini')

p = Weaponrestrictbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

joe.connects(cid=1)
superadmin.connects(cid=2)

print "----------- Testing Privilege ------------"
joe.says('!weaponrestrict off')
time.sleep(5)

print "----------- Testing No data ------------"
superadmin.says('!weaponrestrict')
time.sleep(5)

print "----------- Testing wrong data ------------"
superadmin.says('!weaponrestrict ofk')
time.sleep(5)

print "----------- Testing Restriction Off ------------"
superadmin.says('!weaponrestrict off')
time.sleep(5)

print "----------- Testing Kill when Restriction Off ------------"
superadmin.kills(joe, 'M320')
time.sleep(5)

print "----------- Testing Restriction On ------------"
 
    def register_commands(self):
        if 'commands' in self.config.sections():
            for cmd in self.config.options('commands'):
                level = self.config.get('commands', cmd)
                sp = cmd.split('-')
                alias = None
                if len(sp) == 2:
                    cmd, alias = sp
            
                func = self.getCmd(cmd)
                if func:
                    self._adminPlugin.registerCommand(self, cmd, level, func, alias)

if __name__ == '__main__':

    from b3.fake import fakeConsole, superadmin, joe
    import time

    myplugin = Weaponlimiterbf3Plugin(fakeConsole, '@b3/extplugins/conf/plugin_weaponlimiterbf3.xml')
    myplugin.onStartup()
    time.sleep(2)


    superadmin.connects(cid=0)
    superadmin.setvar('weaponlimiterbf3', 'test','blub')
    print(dir(superadmin))
    print(superadmin.var('weaponlimiterbf3','test'))
    superadmin.says('!weaponlimiter')

        <set name="no_level_check_level">20</set>
    </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

simon.connects("simon")
simon.teamId = 1
moderator.connects('moderator')
moderator.teamId = 2
superadmin.connects('superadmin')
superadmin.teamId = 2
print "Simon's group is " + simon.maxGroup.name
print "Moderator's group is " + moderator.maxGroup.name
print "superadmin's group is " +  superadmin.maxGroup.name


assert p.no_level_check_level == 20

print "\n\n####################################### Simon should not be able to !changeteam Moderator"
simon.says("!changeteam Moderator")

print "\n\n####################################### moderator should be able to !changeteam God"
moderator.says("!changeteam God")

print "\n\n####################################### God should be able to !changeteam Moderator"
superadmin.says("!changeteam Moderator")
Esempio n. 30
0
<configuration plugin="poweradminbf3">
  <settings name="commands">
    <set name="unlockmode">40</set>
  </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

superadmin.connects('superadmin')


print "\n\n####################################### !unlockmode"
superadmin.says('!unlockmode')
superadmin.says('@unlockmode')

print "\n\n####################################### !unlockmode junk"
superadmin.says('!unlockmode junk')
superadmin.says('@unlockmode junk')

print "\n\n####################################### !unlockmode all"
superadmin.says('!unlockmode all')
superadmin.says('@unlockmode all')

print "\n\n####################################### !unlockmode common"
superadmin.says('!unlockmode common')

print "\n\n####################################### !unlockmode stats"
superadmin.says('!unlockmode stats')
Esempio n. 31
0
    p.onLoadConfig()
    
    time.sleep(1)
    joe.connects(cid=3)
    joe.says("!mapstats")
    joe.says("!mystatalias")
    joe.says("!testscore")
    joe.says("!tscr")
    joe.says("!topstats")
    joe.says("!tops")
    joe.says("!topxp")
    joe.says("!txp")
    
    
    superadmin.connects(cid=2)
    joe.kills(superadmin)
    joe.kills(superadmin)
    joe.kills(superadmin)
    superadmin.kills(joe)
    
    superadmin.says("!mapstats")
    superadmin.says("!mystatalias")
    superadmin.says("!testscore")
    superadmin.says("!tscr")
    superadmin.says("!topstats")
    superadmin.says("!tops")
    superadmin.says("!topxp")
    superadmin.says("!txp")
    
    
conf.loadFromString("""
<configuration plugin="poweradminbf3">
  <settings name="commands">
    <set name="setnextmap-snmap">20</set>
  </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

superadmin.connects('superadmin')

print "\n\n====================================== test !setnextmap nominal case"
superadmin.says('!setnextmap')

print "\n\n====================================== test case map name not recognised"


def my_getMapsSoundingLike_3_suggestions(mapname):
    return ['map #1', 'map #2', 'map #3']


fakeConsole.getMapsSoundingLike = my_getMapsSoundingLike_3_suggestions
superadmin.says('!snmap somemap')


def my_getMapsSoundingLike_map_found(mapname):
    return ['MAP_001']
Esempio n. 33
0
        if self._victim.connected:
            self._parent.bot("^1MUTE ^3%s" % self._victim.exactName)
            self.console.say("^1MUTE ^3%s" % self._victim.exactName)
            self.console.write('mute %s %s' % (self._victim.cid, ''))
            self._victim = None

    def end_vote_no(self,  yes,  no):
        self.console.say(self._parent.getMessage('failed_vote'))
        self._victim = None

if __name__ == '__main__':
    from b3.fake import fakeConsole
    from b3.fake import superadmin, reg, admin
 
    fakeConsole.setCvar('g_mapcycle','mapcycle.txt')
    setattr(fakeConsole.game,'fs_basepath','/home/gabriel/.q3a')
    setattr(fakeConsole.game,'fs_game','q3ut4')

    p = Voting2GPlugin(fakeConsole, '@b3/extplugins/conf/voting2g.xml')
    p.onStartup()
    
    superadmin.connects(cid=1)
    reg.connects(cid=2)
    admin.connects(cid=3)
    time.sleep(2)
    superadmin.says("!maplist")
    time.sleep(2)
    admin.says("!votemap ut4_turnpike")
    time.sleep(1)
    reg.says("!vy")
Esempio n. 34
0
        <name> - remove user from the autoslap list
        """
        m = self._adminPlugin.parseUserCmd(data)
        if not m:
            client.message('^7Invalid parameters')
            return False

        sclient = self._adminPlugin.findClientPrompt(m[0], client)
        cursor = self.console.storage.query(self._DEL_QUERY % sclient.id)

        if not sclient:
            return

        self.debug("User removed from autoslap list")
        client.message("^7%s removed from autoslap list." % sclient.name)


if __name__ == '__main__':
    from b3.fake import fakeConsole
    from b3.fake import superadmin as user

    p = AutoslapPlugin(fakeConsole,
                       '/local/codwar/bot/b3/extplugins/conf/autoslap.xml')
    p.onStartup()

    user.authed = True
    user.says('!listslap')
    time.sleep(2)

    p._slap_client(user)
Esempio n. 35
0
			else:
				client.message("^7The Chat Spy is [^1OFF^7]")
		if data == "on":
			if client not in self._listeners:
				self._listeners.append(client)
				client.message("^7Spy: [^2ON^7]")
			else:
				client.message("You are already spying on chats!")
		if data == "off":
			if client in self._listeners:
				self._listeners.remove(client)
				client.message("^7Spy: [^1OFF^7]")
			else:
				client.message("You are not spying on chats!")

if __name__ == "__main__":
	from b3.fake import fakeConsole, joe, moderator, superadmin
	plugin = ChatspyPlugin(fakeConsole)
	plugin.onStartup()
	superadmin.connects(cid = 0)
	superadmin.team = 1
	joe.connects(cid = 1)
	joe.team = 2
	moderator.connects(cid = 2)
	moderator.team = 3
	superadmin.says("!spy on")
	joe.says2team("haha")
	superadmin.says("!spy on")
	superadmin.says("!help spy")
	joe.says2team("admin is a big fat noob")
	superadmin.disconnects()
conf = XmlConfigParser()
conf.loadFromString("""
<configuration plugin="poweradminbf3">
  <settings name="commands">
    <set name="kill">0</set>
  </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

simon.connects("simon")
simon.teamId = 1
simon.squad = 7
joe.connects('Joe')
joe.teamId = 1
joe.squad = 7
superadmin.connects('superadmin')
superadmin.teamId = 2
superadmin.squad = 6
print "Joe's group is " + joe.maxGroup.name
print "Simon's group is " + simon.maxGroup.name
print "superadmin's group is " + superadmin.maxGroup.name

print "\n\n####################################### test !kill"
superadmin.says("!kill joe")
joe.says("!kill god")
joe.says("!kill simon")
simon.teamId = 1
joe.connects('Joe')
joe.teamId = 1
jack = FakeClient(fakeConsole, name="Jack", exactName="Jack", guid="azerazerzarazrzae", groupBits=1)
jack.connects('Jack')
jack.teamId = 1
superadmin.connects('superadmin')
superadmin.teamId = 2
print "Joe's group is " +  joe.maxGroup.name
print "Jack's group is " +  jack.maxGroup.name
print "Simon's group is " + simon.maxGroup.name
print "superadmin's group is " +  superadmin.maxGroup.name


print "\n\n####################################### test !changeteam"
superadmin.says("!changeteam joe")


print "\n\n####################################### Joe should not be able to !changeteam a higher level player"
assert joe.maxLevel < superadmin.maxLevel
joe.says("!ct god")

print "\n\n####################################### Joe should be able to !changeteam a lower level player"
assert joe.maxLevel > simon.maxLevel
joe.says("!changeteam simon")

print "\n\n####################################### Jack should be able to !changeteam an equal level player"
assert joe.maxLevel == jack.maxLevel
jack.says("!changeteam joe")

Esempio n. 38
0
joe.connects('Joe')
joe.teamId = 1
jack = FakeClient(fakeConsole,
                  name="Jack",
                  exactName="Jack",
                  guid="azerazerzarazrzae",
                  groupBits=1)
jack.connects('Jack')
jack.teamId = 1
superadmin.connects('superadmin')
superadmin.teamId = 2
print "Joe's group is " + joe.maxGroup.name
print "Jack's group is " + jack.maxGroup.name
print "Simon's group is " + simon.maxGroup.name
print "superadmin's group is " + superadmin.maxGroup.name

print "\n\n####################################### test !changeteam"
superadmin.says("!changeteam joe")

print "\n\n####################################### Joe should not be able to !changeteam a higher level player"
assert joe.maxLevel < superadmin.maxLevel
joe.says("!ct god")

print "\n\n####################################### Joe should be able to !changeteam a lower level player"
assert joe.maxLevel > simon.maxLevel
joe.says("!changeteam simon")

print "\n\n####################################### Jack should be able to !changeteam an equal level player"
assert joe.maxLevel == jack.maxLevel
jack.says("!changeteam joe")
Esempio n. 39
0
        if cursor.rowcount > 0:
            r = cursor.getRow()
            admin = self._adminPlugin.findClientPrompt("@%s" % r['admin_id'],
                                                       client)
            if admin:
                admin_name = admin.name
            else:
                admin_name = 'B3'
            if r['reason'] and r['reason'] != '' and r['reason'] != 'None':
                reason = r['reason']
            else:
                reason = self._DEFAULT_REASON
            client.message('%s was added by %s for %s' %
                           (sclient.name, admin_name, reason))
        else:
            client.message('No follow info for %s' % sclient.name)


if __name__ == '__main__':
    from b3.fake import fakeConsole
    from b3.fake import superadmin

    p = FollowPlugin(fakeConsole, 'conf/follow.xml')
    p.onStartup()

    superadmin.connects(cid=1)
    time.sleep(1)
    superadmin.says('!listfollow')
    time.sleep(2)
superadmin.squad = 6
print "Joe's group is " +  joe.maxGroup.name
print "Simon's group is " + simon.maxGroup.name
print "Moderator's group is " + moderator.maxGroup.name
print "superadmin's group is " +  superadmin.maxGroup.name



print "\n\n####################################### test superadmin says !swap joe"
superadmin.teamId = 2
superadmin.squad = 6
print "superadmin.teamId: %s, squad: %s" % (superadmin.teamId, superadmin.squad)
joe.teamId = 1
joe.squad = 7
print "joe.teamId: %s, squad: %s" % (joe.teamId, joe.squad)
superadmin.says('!swap joe')



print "\n\n####################################### test !swap joe simon"
simon.teamId = 1
simon.squad = 6
print "simon.teamId: %s, squad: %s" % (simon.teamId, simon.squad)
joe.teamId = 1
joe.squad = 6
print "joe.teamId: %s, squad: %s" % (joe.teamId, joe.squad)
superadmin.says("!swap joe simon")



print "\n\n####################################### test !swap joe simon"
Esempio n. 41
0
 def test_Command_clear():
     superadmin.says('!metabansclear @%s' % joe.id)
Esempio n. 42
0
            self._parent.bot("^1MUTE ^3%s" % self._victim.exactName)
            self.console.say("^1MUTE ^3%s" % self._victim.exactName)
            self.console.write('mute %s %s' % (self._victim.cid, ''))
            self._victim = None

    def end_vote_no(self, yes, no):
        self.console.say(self._parent.getMessage('failed_vote'))
        self._victim = None


if __name__ == '__main__':
    from b3.fake import fakeConsole
    from b3.fake import superadmin, reg, admin

    fakeConsole.setCvar('g_mapcycle', 'mapcycle.txt')
    setattr(fakeConsole.game, 'fs_basepath', '/home/gabriel/.q3a')
    setattr(fakeConsole.game, 'fs_game', 'q3ut4')

    p = Voting2GPlugin(fakeConsole, '@b3/extplugins/conf/voting2g.xml')
    p.onStartup()

    superadmin.connects(cid=1)
    reg.connects(cid=2)
    admin.connects(cid=3)
    time.sleep(2)
    superadmin.says("!maplist")
    time.sleep(2)
    admin.says("!votemap ut4_turnpike")
    time.sleep(1)
    reg.says("!vy")
from b3.fake import fakeConsole, superadmin
from poweradminbf3 import Poweradminbf3Plugin
from b3.config import XmlConfigParser



conf = XmlConfigParser()
conf.loadFromString("""
<configuration plugin="poweradminbf3">
  <settings name="commands">
    <set name="punkbuster-pb">100</set>
    <set name="roundnext-rnext">40</set>
    <set name="roundrestart-rrestart">40</set>
  </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

superadmin.connects('superadmin')

print "\n\n####################################### test basic commands. They should all work"
superadmin.says("!roundnext")
superadmin.says("!rnext")
superadmin.says("!roundrestart")
superadmin.says("!rrestart")
superadmin.says("!punkbuster")
superadmin.says("!pb some command")
Esempio n. 44
0
 def testCommand():
     superadmin.connects(0)
     superadmin.says('!ggcstream')
Esempio n. 45
0
    <settings name="preferences">
        <set name="no_level_check_level">20</set>
    </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

simon.connects("simon")
simon.teamId = 1
moderator.connects('moderator')
moderator.teamId = 2
superadmin.connects('superadmin')
superadmin.teamId = 2
print "Simon's group is " + simon.maxGroup.name
print "Moderator's group is " + moderator.maxGroup.name
print "superadmin's group is " + superadmin.maxGroup.name

assert p.no_level_check_level == 20

print "\n\n####################################### Simon should not be able to !changeteam Moderator"
simon.says("!changeteam Moderator")

print "\n\n####################################### moderator should be able to !changeteam God"
moderator.says("!changeteam God")

print "\n\n####################################### God should be able to !changeteam Moderator"
superadmin.says("!changeteam Moderator")
Esempio n. 46
0
        if self.__callback:
            self.__callback(*self.__callback_args, data=battlelog_user)



if __name__ == '__main__':
    from b3.fake import fakeConsole, superadmin, joe, simon, fakeAdminPlugin
    import time

    myplugin = BattlelogPlugin(fakeConsole, 'conf/plugin_battlelog.ini')
    myplugin.console.game.gameName = 'bf3'
    myplugin.onStartup()
    time.sleep(2)

    myplugin.console.game.gameType = 'Domination0'
    myplugin.console.game._mapName = 'XP2_Skybar'
    superadmin.connects(cid=0)
    # make joe connect to the fake game server on slot 1
    joe.connects(cid=1)
    # make joe connect to the fake game server on slot 2
    simon.connects(cid=2)
    # superadmin put joe in group user
    superadmin.says('!putgroup joe user')
    superadmin.says('!putgroup simon user')

    joe.name = 'O2ON'

    superadmin.connects(cid=0)

conf.loadFromString("""
<configuration plugin="poweradminbf3">
  <settings name="commands">
    <set name="kill">0</set>
  </settings>
</configuration>
""")

p = Poweradminbf3Plugin(fakeConsole, conf)
p.onLoadConfig()
p.onStartup()

simon.connects("simon")
simon.teamId = 1
simon.squad = 7
joe.connects('Joe')
joe.teamId = 1
joe.squad = 7
superadmin.connects('superadmin')
superadmin.teamId = 2
superadmin.squad = 6
print "Joe's group is " +  joe.maxGroup.name
print "Simon's group is " + simon.maxGroup.name
print "superadmin's group is " +  superadmin.maxGroup.name


print "\n\n####################################### test !kill"
superadmin.says("!kill joe")
joe.says("!kill god")
joe.says("!kill simon")
Esempio n. 48
0
            else:
                sclient.setGroup(group)
                sclient.save()

                cmd.sayLoudOrPM(
                    client,
                    self._adminPlugin.getMessage('groups_put',
                                                 sclient.exactName,
                                                 group.name))
                return True

if __name__ == '__main__':
    from b3.fake import fakeConsole
    from b3.fake import superadmin, joe

    fakeConsole.setCvar('g_mapcycle', 'mapcycle.txt')
    setattr(fakeConsole.game, 'fs_basepath', '/home/gabriel/urbanterror')
    setattr(fakeConsole.game, 'fs_game', 'q3ut4')

    p = ExtraadminPlugin(fakeConsole, '@b3/extplugins/conf/extraadmin.xml')
    p.onStartup()

    #print p._nextMap
    #print p._currentMap
    #p.find_next_map_rotation('ut4_tejen_beta3')
    #print p._nextMap
    superadmin.connects(cid=1)
    joe.connects(cid=2)
    time.sleep(2)
    superadmin.says("!cinfo 2")
                <set name="paident-id">40</set>
                <set name="paset">100</set>
                <set name="paget">100</set>
                <set name="pasetdlc-setdlc">100</set>
                <set name="paload-load">100</set>
                <set name="palistcfg-listcfg">100</set>
                <!--
                Following commands work on UNRANKED servers only
                -->
               <set name="pafastrestart-fastrestart">40</set>
               <set name="pamaprestart-maprestart">40</set>
               <set name="pagametype-gametype">40</set>
            </settings>
        </configuration>
    ''')

    p = Poweradmincod7Plugin(fakeConsole, conf)
    p.onStartup()
    p._isranked = True

    superadmin.connects(cid=1)

    superadmin.says("!listcfg")
    print "-------------------------"

    superadmin.says("!load test.cfg")
    print "-------------------------"

    superadmin.says("!setdlc 2 off")
    print "-------------------------"