def test_joe_says_badword(self, timer_patch): from b3.fake import joe joe.warn = Mock() joe.connects(0) joe.says("qsfdl f0o!") self.assertEqual(1, joe.warn.call_count)
def test_teamMisc(self): joe.says('!ts join') joe.team = b3.TEAM_SPEC joe.setvar(self.p, 'switchtarget', 'team') fakeConsole.queueEvent(b3.events.Event(b3.events.EVT_CLIENT_SQUAD_CHANGE, (joe.team, joe.squad), joe)) time.sleep(.1) tsclient = self.p.tsGetClient(joe) self.assertNotEqual(tsclient, None) self.assertEqual(tsclient['cid'], self.p.tsChannelIdB3)
def test_team1(self): joe.says('!ts join') joe.team = b3.TEAM_BLUE joe.setvar(self.p, 'switchtarget', 'team') fakeConsole.queueEvent( b3.events.Event(b3.events.EVT_CLIENT_TEAM_CHANGE, joe.team, joe)) time.sleep(.1) tsclient = self.p.tsGetClient(joe) self.assertNotEqual(tsclient, None) self.assertEqual(tsclient['cid'], self.p.tsChannelIdTeam1)
def test_squadsTeam2(self): joe.says('!ts join') joe.team = b3.TEAM_RED joe.setvar(self.p, 'switchtarget', 'squad') for i in range(1, 9): joe.squad = i fakeConsole.queueEvent(b3.events.Event(b3.events.EVT_CLIENT_SQUAD_CHANGE, (joe.team, joe.squad), joe)) time.sleep(.1) tsclient = self.p.tsGetClient(joe) self.assertNotEqual(tsclient, None) self.assertEqual(tsclient['cid'], self.p.tsChannelIdSquadsTeam2[i])
def test_squadsTeam2(self): joe.says('!ts join') joe.team = b3.TEAM_RED joe.setvar(self.p, 'switchtarget', 'squad') for i in range(1, 9): joe.squad = i fakeConsole.queueEvent( b3.events.Event(b3.events.EVT_CLIENT_SQUAD_CHANGE, (joe.team, joe.squad), joe)) time.sleep(.1) tsclient = self.p.tsGetClient(joe) self.assertNotEqual(tsclient, None) self.assertEqual(tsclient['cid'], self.p.tsChannelIdSquadsTeam2[i])
def test_cmd_ts_join(self): joe.clearMessageHistory() joe.says('!ts join') self.assertNotEqual(0, len(joe.message_history)) time.sleep(.1) self.assertEqual(True, self.p.tsIsClientInB3Channel(self.p.tsGetClient(joe))) joe.clearMessageHistory() joe.says('!ts disjoin') self.assertNotEqual(0, len(joe.message_history)) time.sleep(.1) self.assertEqual(False, self.p.tsIsClientInB3Channel(self.p.tsGetClient(joe)))
def test_cmd_tsauto(self): joe.clearMessageHistory() joe.says('!tsauto') self.assertNotEqual(0, len(joe.message_history)) joe.clearMessageHistory() joe.says('!tsauto off') self.assertNotEqual(0, len(joe.message_history)) self.assertEqual('You will not be automatically switched on teamspeak', joe.getMessageHistoryLike('You will')) joe.clearMessageHistory() joe.says('!tsauto on') self.assertNotEqual(0, len(joe.message_history)) self.assertEqual('You will be automatically switched on your team channel', joe.getMessageHistoryLike('You will')) joe.clearMessageHistory() joe.says('!tsauto qsdfqsd f') self.assertNotEqual(0, len(joe.message_history)) self.assertNotEqual(None, joe.getMessageHistoryLike('Invalid parameter')) joe.clearMessageHistory() joe.says('!tsauto ') self.assertNotEqual(0, len(joe.message_history)) self.assertNotEqual(None, joe.getMessageHistoryLike('Invalid parameter'))
self._adminPlugin.warnClient(event.client, 'spam') spamins = int(spamins / 1.5) event.client.setvar(self, 'spamins', spamins) raise b3.events.VetoEvent elif event.client.var(self, 'ignore_till').value > self.console.time(): #ignore the user raise b3.events.VetoEvent if __name__ == '__main__': from b3.fake import fakeConsole from b3.fake import joe p = SpamcontrolPlugin(fakeConsole, '@b3/conf/plugin_spamcontrol.xml') p.onStartup() p.info("---------- start spamming") joe.says("i'm spammmmmmmmmming") time.sleep(1) joe.says2team("i'm spammmmmmmmmming") time.sleep(1) joe.says("i'm spammmmmmmmmming") time.sleep(1) joe.says2team("i'm spammmmmmmmmming") time.sleep(1) joe.says("i'm spammmmmmmmmming") time.sleep(1) joe.says("i'm spammmmmmmmmming") p.info("_________ end of test ____________") time.sleep(1) # give console thread a chance to end gracefully
t = threading.Timer(60, self.checkBadName, (client, )) t.start() return def clean(self, data): return re.sub(self._reClean, ' ', self.console.stripColors(data.lower())) if __name__ == '__main__': import time from b3.fake import fakeConsole from b3.fake import joe p = CensorPlugin(fakeConsole, '@b3/conf/plugin_censor.xml') p.onStartup() fakeConsole.noVerbose = True joe._maxLevel = 0 joe.connected = True #p.onEvent(b3.events.Event(b3.events.EVT_CLIENT_SAY, "f**k", joe)) joe.says('hello') joe.says('f**k') joe.says('nothing wrong') joe.says('ass') joe.says('shit') time.sleep(2)
</settings> <settings name="settings"> <set name="startPoints">100</set> <set name="resetscore">no</set> <set name="resetxp">no</set> </settings> </configuration> """) 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")
joe.team = b3.TEAM_BLUE simon.team = b3.TEAM_RED joe.console = fakeConsole simon.console = fakeConsole ############# END setup test environment ################## joe.connects(cid=1) simon.connects(cid=2) print "================= ROUND 1 ===================" time.sleep(1) fakeConsole.queueEvent(b3.events.Event(b3.events.EVT_GAME_WARMUP, None)) time.sleep(10) p._current = 4 joe.says('!ob') fakeConsole.setCvar("g_teamScores","1:0") simon.capturesFlag() time.sleep(0.5) print fakeConsole.getCvar("g_teamScores") fakeConsole.setCvar("g_teamScores","1:1") joe.capturesFlag() time.sleep(0.5) print fakeConsole.getCvar("g_teamScores") fakeConsole.setCvar("g_teamScores","2:1") simon.capturesFlag() time.sleep(0.5) print fakeConsole.getCvar("g_teamScores")
joe.kills(simon) moderator.kills(joe) print "-------------------------" fakeConsole.queueEvent(b3.events.Event(b3.events.EVT_GAME_ROUND_END, None, None)) time.sleep(5) print "-------------------------" joe.says('!duelcancel') moderator.kills(joe) moderator.kills(simon) print "-------------------------" joe.says('!duelreset') simon.kills(moderator) simon.kills(moderator) simon.kills(moderator) moderator.kills(joe) """ joe.connects(cid=1) simon.connects(cid=2) simon.groupBits = 1 joe.says('!duel simon') simon.says('!duel joe') time.sleep(1) joe.disconnects() while True: time.sleep(1)
def test1(): conf = XmlConfigParser() conf.setXml(""" <configuration plugin="adv"> <!-- Note: within ads, you can use the following variables : @nextmap @time or rules as defined in the admin plugin config file. ie: /spam#rule1 --> <settings name="settings"> <!-- rate in minutes--> <set name="rate">5</set> <!-- you can either set here a text file that will contain one ad per line or fill the <ads> section below --> <!-- <set name="ads">c:/somewhere/my_ads.txt</set> --> </settings> <settings name="newsfeed"> <!-- you can include newsitems in your adds by setting the section below you can add feeditems in the adds like this: @feed (will pick the next newsitem each time it is included in the rotation, rotating until 'items' is reached and then start over.) @feed 0 (will pick the latest newsitem available from the feed and add it in the rotation) @feed 1 (will pick the second latest item in line) etc. --> <set name="url">http://forum.bigbrotherbot.net/news-2/?type=rss;action=.xml</set> <set name="url.bak"></set> <set name="items">5</set> <set name="pretext">News: </set> </settings> <ads> <ad>^2Big Brother Bot is watching you... www.BigBrotherBot.net</ad> <ad>@topstats</ad> <ad>@feed</ad> <ad>/spam#rule1</ad> <ad>@time</ad> <ad>@feed</ad> <ad>^2Do you like B3? Consider donating to the project at www.BigBrotherBot.net</ad> <ad>@nextmap</ad> </ads> </configuration> """) p = AdvPlugin(fakeConsole, conf) p.onStartup() p.adv() print "-----------------------------" time.sleep(2) joe.connects(1) joe._maxLevel = 100 joe.says('!advlist') time.sleep(2) joe.says('!advrem 0') time.sleep(2) joe.says('!advrate 5s') time.sleep(5) time.sleep(60)
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")
def test_cmd_tsauto(self): joe.says('!ts join') joe.clearMessageHistory() joe.says('!tsauto') self.assertNotEqual(0, len(joe.message_history)) joe.clearMessageHistory() joe.says('!tsauto off') self.assertNotEqual(0, len(joe.message_history)) self.assertEqual('You will not be automatically switched on teamspeak', joe.getMessageHistoryLike('You will')) joe.clearMessageHistory() joe.says('!tsauto on') self.assertNotEqual(0, len(joe.message_history)) self.assertEqual( 'You will be automatically switched on your team channel', joe.getMessageHistoryLike('You will')) joe.clearMessageHistory() joe.says('!tsauto qsdfqsd f') self.assertNotEqual(0, len(joe.message_history)) self.assertNotEqual(None, joe.getMessageHistoryLike('Invalid parameter')) joe.clearMessageHistory() joe.says('!tsauto ') self.assertNotEqual(0, len(joe.message_history)) self.assertNotEqual(None, joe.getMessageHistoryLike('Invalid parameter'))
def test_cmd_ts(self): joe.clearMessageHistory() joe.says('!ts') self.assertNotEqual(0, len(joe.message_history))
[punish_method] punish_method: 2 [restricted_weapons] restricted_weapons: RPG-7, SMAW, M320, M26Mass [whitelist_gametypes] whitelist_gametypes: GunMaster0, ConquestLarge0, ConquestSmall0, RushLarge0, ConquestAssaultLarge0, ConquestAssaultSmall0, ConquestAssaultSmall1 """) # 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 command with restricted weapons specified ------------" joe.says('!rw') time.sleep(5) print "----------- Testing command when restriction is turned off ------------" p.restriction_status = False joe.says('!rw') time.sleep(5) print "----------- Testing command with no restricted weapons specified ------------" p.restriction_status = True p._restrictedweapons = [] joe.says('!rw')
t = threading.Timer(60, self.checkBadName, (client,)) t.start() return def clean(self, data): return re.sub(self._reClean, " ", self.console.stripColors(data.lower())) if __name__ == "__main__": import time from b3.fake import fakeConsole from b3.fake import joe p = CensorPlugin(fakeConsole, "@b3/conf/plugin_censor.xml") p.onStartup() fakeConsole.noVerbose = True joe._maxLevel = 0 joe.connected = True # p.onEvent(b3.events.Event(b3.events.EVT_CLIENT_SAY, "f**k", joe)) joe.says("hello") joe.says("f**k") joe.says("nothing wrong") joe.says("ass") joe.says("shit") time.sleep(2)
) print "Joe id : %s" % joe.id moderator.connects(1) fakeConsole.storage.query( QueryBuilder(fakeConsole.storage.db).UpdateQuery( {"password": md5("test").hexdigest()}, "clients", {"id": moderator.id} ) ) print "Moderator id : %s" % moderator.id superadmin.auth() fakeConsole.storage.query( QueryBuilder(fakeConsole.storage.db).UpdateQuery( {"password": md5("test").hexdigest(), "login": "******"}, "clients", {"id": superadmin.id} ) ) print "superadmin id : %s" % superadmin.id time.sleep(10) joe.says("what's up ?") time.sleep(5) moderator.says("having a beer and you ?") while True: time.sleep(3) joe.says(random.choice(("random stuff", "blabla", "one again", "hi", "bye", "see ya", "n1", "cheater!"))) pass except KeyboardInterrupt: p.telnetService.stop() print "*" * 30
if __name__ == "__main__": import time from b3.fake import fakeConsole from b3.fake import joe from b3.fake import simon from b3.fake import moderator p = TkPlugin(fakeConsole, "@b3/conf/plugin_tk.xml") p.onStartup() # register events, etc joe.team = b3.TEAM_BLUE simon.team = b3.TEAM_BLUE time.sleep(5) joe.kills(simon) time.sleep(6) simon.kills(joe) time.sleep(2) joe.says("!f 2") time.sleep(2) joe.damages(simon) moderator.says("!forgiveinfo joe") time.sleep(2) joe.damages(simon) joe.damages(simon) moderator.says("!forgiveinfo joe") time.sleep(2) joe.kills(simon) time.sleep(2)
name="Jack", exactName="Jack", guid="qsd654sqf", _maxLevel=1, authed=True, team=b3.TEAM_RED) ## initialize gametype fakeConsole.game.gameType = 'ctf' ############# END setup test environment ################## print "================= ROUND 1 ===================" joe.takesFlag() joe.says('!flag') simon.returnsFlag() simon.takesFlag() time.sleep(1.5) simon.capturesFlag() time.sleep(0.5) simon.says('!flag') jack.takesFlag() time.sleep(0.8) jack.capturesFlag() time.sleep(0.5) jack.says('!fs') simon.takesFlag()
if __name__ == '__main__': import time from b3.fake import fakeConsole from b3.fake import joe from b3.fake import simon from b3.fake import moderator p = TkPlugin(fakeConsole, "@b3/conf/plugin_tk.xml") p.onStartup() # register events, etc joe.team = b3.TEAM_BLUE simon.team = b3.TEAM_BLUE time.sleep(5) joe.kills(simon) time.sleep(6) simon.kills(joe) time.sleep(2) joe.says('!f 2') time.sleep(2) joe.damages(simon) moderator.says('!forgiveinfo joe') time.sleep(2) joe.damages(simon) joe.damages(simon) moderator.says('!forgiveinfo joe') time.sleep(2) joe.kills(simon) time.sleep(2)
print "\n%s PM to %s : \"%s\"" % (self.name, msg, target) self.console.queueEvent( b3.events.Event(b3.events.EVT_CLIENT_PRIVATE_SAY, msg, self, target)) FakeClient.sendsPM = sendsPM p = ChatloggerPlugin(fakeConsole) p.onStartup() time.sleep(2) joe.connects(1) simon.connects(3) joe.says("sql injec;tion ' test") joe.sendsPM("sql; injection ' test", simon) joe.says("!help sql injection ' test;") joe.name = "j'oe" simon.name = "s;m'n" joe.says("sql injection test2") joe.sendsPM("sql injection test2", simon) joe.says("!help sql injection test2") joe.says("holas \" como va") joe.name = "Joe" simon.name = "Simon" joe.says("hello")
joe.kills(simon) moderator.kills(joe) print "-------------------------" fakeConsole.queueEvent(b3.events.Event(b3.events.EVT_GAME_ROUND_END, None, None)) time.sleep(5) print "-------------------------" joe.says('!duelcancel') moderator.kills(joe) moderator.kills(simon) print "-------------------------" joe.says('!duelreset') simon.kills(moderator) simon.kills(moderator) simon.kills(moderator) moderator.kills(joe) """ joe.connects(cid=1) simon.connects(cid=2) simon.groupBits = 1 joe.says("!duel simon") simon.says("!duel joe") time.sleep(1) joe.disconnects() while True: time.sleep(1)
self.assertNotEqual(tsclient, None) self.assertEqual(tsclient['cid'], p.tsChannelIdB3) def test_team1(self): joe.team = b3.TEAM_BLUE tsclient = p.tsGetClient(joe) self.assertNotEqual(tsclient, None) self.assertEqual(tsclient['cid'], p.tsChannelIdTeam1) def test_team2(self): joe.team = b3.TEAM_RED tsclient = p.tsGetClient(joe) self.assertNotEqual(tsclient, None) self.assertEqual(tsclient['cid'], p.tsChannelIdTeam2) def donothing(*whatever): pass fakeConsole.error = donothing fakeConsole.debug = donothing fakeConsole.bot = donothing fakeConsole.verbose = donothing fakeConsole.verbose2 = donothing fakeConsole.console = donothing fakeConsole.warning = donothing fakeConsole.info = donothing fakeConsole.exception = donothing fakeConsole.critical = donothing joe.says('!tsauto on') unittest.main()
restricted_weapons: RPG-7, SMAW, M320, M26Mass [whitelist_gametypes] whitelist_gametypes: GunMaster0, ConquestLarge0, ConquestSmall0, RushLarge0, ConquestAssaultLarge0, ConquestAssaultSmall0, ConquestAssaultSmall1 """) # 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 ------------"
import time def sendsPM(self, msg, target): print "\n%s PM to %s : \"%s\"" % (self.name, msg, target) self.console.queueEvent(b3.events.Event(b3.events.EVT_CLIENT_PRIVATE_SAY, msg, self, target)) FakeClient.sendsPM = sendsPM p = ChatloggerPlugin(fakeConsole) p.onStartup() time.sleep(2) joe.connects(1) simon.connects(3) joe.says("sql injec;tion ' test") joe.sendsPM("sql; injection ' test", simon) joe.says("!help sql injection ' test;") joe.name = "j'oe" simon.name = "s;m'n" joe.says("sql injection test2") joe.sendsPM("sql injection test2", simon) joe.says("!help sql injection test2") joe.says("holas \" como va") joe.name = "Joe" simon.name = "Simon" joe.says("hello")
from b3.fake import joe, simon joe.team = b3.TEAM_BLUE simon.team = b3.TEAM_RED jack = FakeClient(fakeConsole, cid=42, name="Jack", exactName="Jack", guid="qsd654sqf", _maxLevel=1, authed=True, team=b3.TEAM_RED) ## initialize gametype fakeConsole.game.gameType = 'ctf' ############# END setup test environment ################## print "================= ROUND 1 ===================" joe.takesFlag() joe.says('!flag') simon.returnsFlag() simon.takesFlag() time.sleep(1.5) simon.capturesFlag() time.sleep(0.5) simon.says('!flag') jack.takesFlag() time.sleep(0.8) jack.capturesFlag() time.sleep(0.5) jack.says('!fs') simon.takesFlag()
from b3.fake import admin, joe import time from b3.config import XmlConfigParser conf = XmlConfigParser() conf.setXml(""" <configuration plugin="stats"> <settings name="settings"> <set name="logfile">admin.log</set> <set name="loglevel">40</set> <set name="log2console">false</set> </settings> </configuration> """) p = ActionloggerPlugin(fakeConsole, conf) p.onStartup() p.onLoadConfig() time.sleep(1) joe.connects(cid=3) joe.says("!help") admin.connects(cid=2) admin.says("hello all") admin.says("!help") admin.says("@admins") admin.says2team("&warn joe rule1")
You can use the following syntax as well 3d : purge all chat older than 3 days 2w : two weeks 6m : six month 1y : one year --> <set name="max_age">0</set> <!-- The purge action takes place once a day at the time define below. Default time is midnight --> <set name="hour">0</set> <!-- hour between 0 and 23 --> <set name="min">0</set> <!-- min between 0 and 59 --> </settings> </configuration> """) p = ChatloggerPlugin(fakeConsole, conf1) p.onStartup() joe.connects(1) simon.connects(3) while True: joe.says("hello") time.sleep(5) simon.says("hi") time.sleep(5) joe.says2team("team test") time.sleep(20)
Default time is midnight --> <set name="hour">0</set> <!-- hour between 0 and 23 --> <set name="min">0</set> <!-- min between 0 and 59 --> </settings> </configuration> """) p = ChatloggerPlugin(fakeConsole, conf1) p.onLoadConfig() p.onStartup() joe.connects(1) simon.connects(3) joe.says("sql injec;tion ' test") joe.sendsPM("sql; injection ' test", simon) joe.says("!help sql injection ' test;") joe.name = "j'oe" simon.name = "s;m'n" joe.says("sql injection test2") joe.sendsPM("sql injection test2", simon) joe.says("!help sql injection test2") joe.name = "Joe" simon.name = "Simon" while True: joe.says("hello") simon.says2team("team test")
t = threading.Timer(60, self.checkBadName, (client,)) t.start() return def clean(self, data): return re.sub(self._reClean, ' ', self.console.stripColors(data.lower())) if __name__ == '__main__': import time from b3.fake import fakeConsole from b3.fake import joe p = CensorPlugin(fakeConsole, '@b3/conf/plugin_censor.xml') p.onStartup() fakeConsole.noVerbose = True joe._maxLevel = 0 joe.connected = True #p.onEvent(b3.events.Event(b3.events.EVT_CLIENT_SAY, "f**k", joe)) joe.says('hello') joe.says('f**k') joe.says('nothing wrong') joe.says('ass') joe.says('shit') time.sleep(2)
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 "-------------------------"
<set name="pretext">News: </set> </settings> <ads> <ad>^2Big Brother Bot is watching you... www.BigBrotherBot.net</ad> <ad>@feed</ad> <ad>/spam#rule1</ad> <ad>@time</ad> <ad>@feed</ad> <ad>^2Do you like B3? Consider donating to the project at www.BigBrotherBot.net</ad> <ad>@nextmap</ad> </ads> </configuration> """) p = AdvPlugin(fakeConsole, conf) p.onStartup() p.adv() print "-----------------------------" time.sleep(2) joe.connects(1) joe._maxLevel = 100 joe.says('!advlist') time.sleep(2) joe.says('!advrem 0') time.sleep(2) joe.says('!advrate 5s') time.sleep(5) time.sleep(60)
while i < (len(log) - 2): line = log[i] logFile.write(line) i = i + 1 if line <> "": self._lastlinewritten = line logFile.close() httpFile.close() self._processing_file = False if __name__ == "__main__": from b3.fake import fakeConsole from b3.fake import joe p = AdvPlugin(fakeConsole, "@b3/conf/plugin_adv.xml") p.onStartup() p.adv() print "-----------------------------" time.sleep(2) joe._maxLevel = 100 joe.says("!advlist") time.sleep(2) joe.says("!advrem 0") time.sleep(2) joe.says("!advrate 1") time.sleep(5)
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")
client.message('^3Adv: ^7Item %s not found' % data) def cmd_advlist(self, data, client=None, cmd=None): if len(self._msg.items) > 0: i = 0 for msg in self._msg.items: i += 1 client.message('^3Adv: ^7[^2%s^7] %s' % (i, msg)) else: client.message('^3Adv: ^7No ads loaded') if __name__ == '__main__': from b3.fake import fakeConsole from b3.fake import joe p = AdvPlugin(fakeConsole, '@b3/conf/plugin_adv.xml') p.onStartup() p.adv() print "-----------------------------" time.sleep(2) joe._maxLevel = 100 joe.says('!advlist') time.sleep(2) joe.says('!advrem 0') time.sleep(2) joe.says('!advrate 1') time.sleep(5)
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")
<settings name="settings"> <set name="startPoints">100</set> <set name="resetscore">no</set> <set name="resetxp">no</set> </settings> </configuration> """) 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)
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")