def testMessage1(): conf = XmlConfigParser() conf.loadFromString(""" <configuration plugin="makeroom"> <settings name="global_settings"> <!-- level under which players to kick will be chosen from (default: 2) --> <set name="non_member_level">2</set> </settings> <settings name="commands"> <!-- Command to free a slot --> <set name="makeroom-mr">20</set> </settings> </configuration> """) p = MakeroomPlugin(fakeConsole, conf) p.onStartup() jack = FakeClient(fakeConsole, name="Jack", guid="qsd654sqf", _maxLevel=0) jack.connects(1) moderator.connects(2) moderator.says('!makeroom')
def testPlugin5(): jack = FakeClient(fakeConsole, name="Jack", _maxLevel=0) jack.connects(1) time.sleep(1.1) joe = FakeClient(fakeConsole, name="Joe", _maxLevel=2) joe.connects(2) moderator.connects(0) moderator.says('!makeroom')
def testPlugin3(): jack = FakeClient(fakeConsole, name="Jack", guid="qsd654sqf", _maxLevel=0) jack.connects(1) moderator.connects(0) moderator.says('!makeroom')
def testMessage2(): conf = XmlConfigParser() conf.loadFromString(""" <configuration plugin="makeroom"> <settings name="global_settings"> <!-- level (inclusive) under which players to kick will be chosen from (default: 2) --> <set name="non_member_level">2</set> <!-- delay in seconds between the time the info_message is shown and the kick happens. If you set this to 0, then no info_message will be shown and kick will happen instantly --> <set name="delay">0</set> </settings> <settings name="commands"> <!-- Command to free a slot --> <set name="makeroom-mr">20</set> </settings> <settings name="messages"> <!-- You can use the following keywords in your messages : $clientname --> <!-- kick_message will be displayed to all players when a player is kicked to free a slot --> <set name="kick_message">kicking $clientname to make room for a member xxxxxxxxxx</set> <!-- kick_reason will be displayed to the player to be kicked --> <set name="kick_reason">to free a slot ! mlkjmlkj</set> </settings> </configuration> """) p = MakeroomPlugin(fakeConsole, conf) p.onStartup() jack = FakeClient(fakeConsole, name="Jack", guid="qsd654sqf", _maxLevel=0) jack.connects(1) moderator.connects(2) moderator.says('!makeroom')
def testPlugin2(): moderator.connects(0) moderator.says('!makeroom')
<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")
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)
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)
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 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")
</settings> <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")
p = TkPlugin(fakeConsole, "@b3/conf/plugin_tk.xml") p.onStartup() # register events, etc p._forgive_delay = 5 p._autoforgive_level = 0 joe.team = b3.TEAM_BLUE simon.team = b3.TEAM_BLUE joe.connects(cid=1) simon.connects(cid=2) moderator.connects(cid=3) time.sleep(5) joe.kills(simon) time.sleep(6) simon.kills(joe) time.sleep(2) time.sleep(2) joe.damages(simon) moderator.says('!forgiveinfo reg') time.sleep(2) joe.damages(simon) joe.damages(simon) moderator.says('!forgiveinfo reg') simon.kills(joe) time.sleep(2) joe.kills(simon) joe.says('!grudge simon') 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
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")