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 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 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 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="commands"> <set name="changeteam">0</set> </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")
<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)
def _client_connected(self, client): if client.connected: self.debug("Warning client before kick") # this requires poweradmin to keep forced client.setvar(self, 'paforced', 'spectator') #self.console.write('mute %s' % (client.cid)) 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)
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)
if server_port: p.telnetPort = server_port if server_ip: p.telnetIp = server_ip p.onLoadConfig() p.onStartup() joe.connects(0) fakeConsole.storage.query( QueryBuilder(fakeConsole.storage.db).UpdateQuery( {"login": "******", "password": md5("test").hexdigest()}, "clients", {"id": joe.id} ) ) 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
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 "-------------------------"
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()