def testAutomation1(): from b3.fake import superadmin superadmin.connects(0) superadmin.says('!makeroomauto') time.sleep(1) superadmin.says('!makeroomauto on') superadmin.says('!makeroomauto off')
def testAdmins(): conf = XmlConfigParser() conf.setXml(""" <configuration plugin="adv"> <settings name="settings"> <set name="rate">1s</set> </settings> <ads> <ad>^2Do you like B3? Consider donating to the project at www.BigBrotherBot.net</ad> <ad>@admins</ad> </ads> </configuration> """) p = AdvPlugin(fakeConsole, conf) p.onStartup() p.adv() print "-----------------------------" time.sleep(4) joe.connects(1) time.sleep(4) moderator.connects(2) time.sleep(4) superadmin.connects(3) time.sleep(60)
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)
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()
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_forgiveclear(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]) superadmin.says("!forgiveclear joe") superadmin.message_history = [] superadmin.says("!forgiveinfo joe") self.assertIn("Joe has 0 TK points", superadmin.message_history[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)
def testAutomation3(): from b3.fake import superadmin, joe p._automation_enabled = True p._delay = 3 p._total_slots = 2 p._min_free_slots = 1 joe.connects(1) time.sleep(.3) superadmin.connects(0) time.sleep(.3)
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)
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])
def testAutomation4(): from b3.fake import superadmin, joe p._automation_enabled = True p._delay = 0 p._total_slots = 3 p._min_free_slots = 1 joe.connects(0) time.sleep(.3) superadmin.connects(1) time.sleep(.3) jack = FakeClient(fakeConsole, name="Jack", guid="qsd654sqf", _maxLevel=2) jack.connects(2)
def test_Command_sync(): 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() superadmin.says('!metabanssync')
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()
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)
input = self._adminPlugin.parseUserCmd(data) if not input: client.message('^7Invalid data, try !help tell') return False clients = self.console.clients.getList() for c in clients: if c.maxLevel >= self._admin_level: c.message('^5%s^7: %s' % (client.name, input[0])) return True if __name__ == '__main__': from b3.fake import fakeConsole from b3.fake import joe, simon, moderator, superadmin import time p = MessengerPlugin(fakeConsole) p.onStartup() joe.connects(cid=1) simon.connects(cid=2) moderator.connects(cid=3) superadmin.connects(cid=4) joe.says('!tell 2 hola') print "-------------------------" joe.says('!telladmin ayuda') print "-------------------------"
def test_Command_check(): superadmin.connects(0) time.sleep(1) joe.connects(1) time.sleep(1) superadmin.says('!metabanscheck joe')
prepare_fakeparser_for_tests() from b3.fake import fakeConsole, FakeClient, superadmin from haxbusterurt import HaxbusterurtPlugin from b3.config import XmlConfigParser conf = XmlConfigParser() conf.loadFromString( """ <configuration plugin="haxbusterurt"> <settings name="settings"> <set name="allow_empty_guid">no</set> </settings> </configuration> """ ) p = HaxbusterurtPlugin(fakeConsole, conf) p.onLoadConfig() p.onStartup() set_clients_ports({"0": "321", "1": "654"}) superadmin._guid = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" superadmin.connects("0") maxime = FakeClient(fakeConsole, name="Maxime", exactName="Maxime", ip="123.123.123.123", guid="123.123.123.123") maxime.connects("1")
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)
# -*- encoding: utf-8 -*- from test import prepare_fakeparser_for_tests, set_clients_ports prepare_fakeparser_for_tests() from b3.fake import fakeConsole, FakeClient, superadmin from haxbusterurt import HaxbusterurtPlugin from b3.config import XmlConfigParser conf = XmlConfigParser() conf.loadFromString(""" <configuration plugin="haxbusterurt"> <settings name="settings"> </settings> </configuration> """) p = HaxbusterurtPlugin(fakeConsole, conf) p.onLoadConfig() p.onStartup() set_clients_ports({'0': '321', '1': '1337'}) superadmin._guid = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" superadmin.connects('0') maxime = FakeClient(fakeConsole, name="Maxime", exactName="Maxime", ip="123.123.123.123", guid="BAAAAAAD") maxime.connects('1')
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")
<set name="sendername">Your Name</set> <!-- Sender's e-mail address --> <set name="sendermail">[email protected]</set> <!-- Receivers' e-mail addresses (separate with comma (,)) --> <set name="receivers">[email protected], [email protected]</set> <!-- Your SMTP server Example: mail.example.com. For Google that is smtp.gmail.com:587 --> <set name="smtp">mail.example.com</set> <!-- E-mail login name --> <set name="login">login_name</set> <!-- E-mail password --> <set name="password">password</set> <!-- Your E-mail message body --> <set name="emailbody">Attention! A suspicious player detected, better get your ass into the server</set> </settings> </configuration> ''') p = AimbotdetectorPlugin(fakeConsole, conf) p.onStartup() print '------------------------------' joe.connects(cid=1) joe.ip = '111.222.333.444' superadmin.connects(cid=3) moderator.connects(cid=5) simon.connects(cid=7) joe.kills(superadmin) print '------------------------------' joe.kills(superadmin) print '------------------------------' joe.kills(superadmin)
api_key = d['key'] if api_username is None: api_username = raw_input('Enter your Metabans username : '******'Enter your Metabans API key : ') d['username'] = api_username d['key'] = api_key d.close() p._metabans.username = api_username p._metabans.apikey = api_key p.onStartup() superadmin.connects(0) time.sleep(1) joe._guid = "76561197976827962" def test_Command_check(): superadmin.connects(0) time.sleep(1) joe.connects(1) time.sleep(1) superadmin.says('!metabanscheck joe') def test_Command_clear(): superadmin.says('!metabansclear @%s' % joe.id)
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")
conf = XmlConfigParser() conf.loadFromString(""" <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"
self.console.write('forceteam %s %s' % (client.cid, 'spectator')) self.kick_client(client, 'welcome') if __name__ == '__main__': from b3.fake import fakeConsole from b3.fake import FakeClient, superadmin, joe, simon, moderator, admin import time user1 = FakeClient(fakeConsole, name="User1", exactName="User1", guid="sds34324", groupBits=0, team=b3.TEAM_UNKNOWN) p = ReservedslotPlugin(fakeConsole, 'conf/reservedslot.xml') p._max_clients = 4 p.onStartup() time.sleep(10) superadmin.connects(cid=0) joe.connects(cid=1) user1.connects(cid=3) simon.connects(cid=2) moderator.connects(cid=4) admin.connects(cid=5) while True: time.sleep(5)
def testCommand(): superadmin.connects(0) superadmin.says('!ggcstream')
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")
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")